Skip to content

feat: add incremental analysis endpoint#706

Open
bhavyajain0810 wants to merge 1 commit into
imDarshanGK:mainfrom
bhavyajain0810:feature/incremental-analysis-670
Open

feat: add incremental analysis endpoint#706
bhavyajain0810 wants to merge 1 commit into
imDarshanGK:mainfrom
bhavyajain0810:feature/incremental-analysis-670

Conversation

@bhavyajain0810
Copy link
Copy Markdown

Description

Adds backend support for incremental analysis so the app can analyze only changed files or changed code hunks instead of re-analyzing the full project every time.

Implemented:

  • Added a new POST /analyze/incremental/ endpoint
  • Added request/response schemas for incremental analysis
  • Added diff-based changed line detection using difflib.SequenceMatcher
  • Added support for added, modified, renamed, deleted, and unchanged files
  • Skips unchanged files and deleted files where no new code needs analysis
  • Handles renamed files using previous_path
  • Falls back to full-file analysis when a large portion of the file has changed
  • Returns metadata such as changed line ranges, changed line count, analyzed/skipped file count, and analysis time
  • Added backend tests for modified, added, deleted, and renamed file cases

Related Issue

Fixes #670

Type of change

  • Bug fix
  • New feature / enhancement
  • Documentation update
  • Test addition
  • Refactor

Checklist

  • I have read CONTRIBUTING.md
  • My branch is up to date with main
  • I have run pytest -v and all tests pass
  • I have not introduced duplicate issues or features
  • My PR title follows the format: feat/fix/docs/test: short description
  • I have added tests for new features (Level 2 and 3 issues)
  • No hardcoded secrets or API keys in my code
  • This PR is linked to a GSSoC 2026 issue

Screenshots (if frontend change)

Not applicable. This PR adds a backend API endpoint and tests only.

Test evidence

python -m ruff format backend/app/schemas.py backend/app/services/incremental_analysis.py backend/app/routers/analyze.py backend/tests/test_endpoints.py
# 4 files reformatted

python -m ruff check backend/app --select E,F,W --ignore E501 --fix
# All checks passed!

python -m ruff check backend/app --select E,F,W --ignore E501
# All checks passed!

cd backend
pytest -v
# 376 passed, 2 warnings in 14.19s

Ruff check evidence:
image

Pytest evidence:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for incremental analysis (only analyze changed files)

1 participant