Skip to content

chore: enforce CI quality gates -- flake8 blocks, ESLint added, security blocks (OPE-55)#262

Merged
DevanshuNEU merged 3 commits into
OpenCodeIntel:mainfrom
DevanshuNEU:chore/ci-quality-gates
Feb 25, 2026
Merged

chore: enforce CI quality gates -- flake8 blocks, ESLint added, security blocks (OPE-55)#262
DevanshuNEU merged 3 commits into
OpenCodeIntel:mainfrom
DevanshuNEU:chore/ci-quality-gates

Conversation

@DevanshuNEU

@DevanshuNEU DevanshuNEU commented Feb 25, 2026

Copy link
Copy Markdown
Collaborator

Problem

CI quality gates were fake:

  • flake8 ran with || true -- literally never failed
  • No ESLint step in frontend CI
  • Security scan had exit-code: '0' and continue-on-error: true
  • Contributors could merge code with syntax errors, unused imports, and secrets

Fix

Backend lint (flake8)

  • Added .flake8 config: checks pyflakes errors (unused imports, undefined names, shadowed vars)
  • Removed 44 unused imports + 4 unused variables via autoflake
  • Fixed f-string bug, unused global, redundant pass statements
  • flake8 now runs WITHOUT || true -- lint failures block merges
  • Zero errors on current codebase

Frontend lint (ESLint)

  • Added ESLint + React/TypeScript plugins to devDependencies
  • Added bun run lint script
  • ESLint step added to CI, runs before build (fail fast)

Security scan

  • Trivy exit-code changed from 0 to 1 -- CRITICAL/HIGH vulns block
  • Removed continue-on-error from trufflehog secret scanning
  • Scan conditional on path changes (saves CI minutes)

CI flow improvement

  • Lint runs before tests (fail fast on syntax issues)
  • Install flake8 in deps step (not separate step)

Test

289 backend tests pass. Zero flake8 errors.

Closes OPE-55

Summary by CodeRabbit

  • Tests

    • CI now runs backend flake8, frontend TypeScript checks and ESLint alongside unit tests
    • Security scanning enhanced: conditional runs when relevant changes detected, vulnerability scan fails on critical/high, and streamlined secret scanning
  • Chores

    • Added project linting configuration and frontend lint/lint:fix scripts
    • Broad cleanup of unused imports and minor code tidy-ups across backend modules

…ity scan blocks (OPE-55)

Backend:
- Added .flake8 config: checks F (pyflakes) + E9 (runtime) errors only,
  ignores style-only rules (whitespace, indentation, line length)
- Removed 44 unused imports and 4 unused variables via autoflake
- Fixed f-string without placeholders in dna_extractor.py
- Removed unused global declaration in user_limits.py
- Removed redundant 'pass' from exception classes and abstract methods
- Added metrics re-export with noqa comment in dependencies.py
- flake8 now passes with ZERO errors

Frontend:
- Added ESLint + plugins to devDependencies (eslint, @eslint/js, globals,
  eslint-plugin-react-hooks, eslint-plugin-react-refresh, typescript-eslint)
- Added 'lint' and 'lint:fix' scripts to package.json

CI workflow:
- Removed '|| true' from flake8 -- lint failures now block merges
- Added 'Lint (ESLint)' step to frontend job
- Moved lint before build (fail fast)
- Changed Trivy exit-code from '0' to '1' -- CRITICAL/HIGH vulns block
- Removed continue-on-error from trufflehog secret scanning
- Security scan now conditional on path changes (not every push)

289 tests pass. Zero flake8 errors.
@vercel

vercel Bot commented Feb 25, 2026

Copy link
Copy Markdown

@DevanshuNEU is attempting to deploy a commit to the Dev's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Feb 25, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds CI linting (flake8, ESLint, TypeScript checks), enhances security scans (Trivy, trufflehog) with conditional execution, introduces backend Flake8 config and frontend ESLint deps/scripts, and performs widespread import/unused-code cleanup across backend modules.

Changes

Cohort / File(s) Summary
CI & Security
.github/workflows/ci.yml
Adds backend flake8, frontend TypeScript check and ESLint steps; reworks security-scan to run Trivy (fail on HIGH/CRITICAL) and trufflehog conditionally when frontend/backend change; removes prior standalone "Check code quality" step.
Flake8 config
backend/.flake8
Adds Flake8 project config (120 char limit, selected error classes, excludes, per-file ignores).
Frontend linting
frontend/package.json, frontend/eslint.config.js
Adds ESLint devDependencies and lint/lint:fix scripts; replaces ESLint config export shape, adds plugins/rules and top-level ignores.
Backend imports & re-exports
backend/dependencies.py, backend/main.py
Adjusts imported/re-exported symbols (swap dependency imports, remove API_VERSION import).
Route cleanup
backend/routes/...
backend/routes/auth.py, backend/routes/github.py, backend/routes/repos.py, backend/routes/search.py, backend/routes/ws_playground.py
Removes unused imports/assignments (e.g., unused status, RedirectResponse, unused repo variable, Optional).
Service import & small logic cleanups
backend/services/*, backend/services/search_v2/*, backend/services/search_v3/*
Widespread removal of unused imports, removed trivial pass statements, small exception init addition, simplified exception handling, and minor refactors (no behavioral changes). Files include auth.py, dependency_analyzer.py, dna_extractor.py, indexer_optimized.py, indexing_events.py, input_validator.py, rate_limiter.py, repo_manager.py, search_enhancer.py, search_v2/summary_generator.py, search_v3/*, style_analyzer.py, supabase_service.py, user_limits.py, exceptions.py.

Sequence Diagram(s)

sequenceDiagram
    participant GH as GitHub Actions
    participant Repo as Repository
    participant Backend as Backend job
    participant Frontend as Frontend job
    participant Trivy as Trivy scanner
    participant Trufflehog as Trufflehog

    GH->>Repo: push / PR event
    GH->>Backend: run install (incl. flake8) -> lint -> tests -> build
    GH->>Frontend: run install -> typescript check -> eslint -> tests -> build
    Backend->>Trivy: run container/image scan (fail on HIGH/CRITICAL)
    Backend->>Trufflehog: run secrets scan
    Frontend->>Trivy: conditional scan if frontend changed
    Frontend->>Trufflehog: conditional secrets check
    Trivy-->>GH: report / exit non-zero on issues
    Trufflehog-->>GH: report findings
    GH-->>Repo: status checks updated
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 I hopped through CI with lint in tow,

Flake8 trimmed whiskers, ESLint set to go,
Secrets scanned and tests all passed,
Imports tucked in, the burrow's fast,
A tidy code-hop, quick and light 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly summarizes the main objectives of the PR: enforcing CI quality gates through flake8 checks, ESLint setup, and security blocking.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
backend/services/dna_extractor.py (1)

826-826: Remove the no-op list comprehension.

Line 826 computes a list and discards it, so this check currently has no effect.

♻️ Proposed cleanup
-        # Check for test directory structure
-        [d for d in ['tests', 'test'] if (repo_path / d).exists()]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@backend/services/dna_extractor.py` at line 826, The list comprehension "[d
for d in ['tests', 'test'] if (repo_path / d).exists()]" is a no-op because its
result is discarded; replace it with a meaningful check such as using any(...)
to test presence (e.g. if any((repo_path / d).exists() for d in
['tests','test']): ...) or assign the list to a variable (e.g. tests_dirs = [d
for d in ['tests','test'] if (repo_path / d).exists()]) and use that variable
where needed; reference the existing repo_path and exists() calls to locate and
update the logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/ci.yml:
- Around line 109-110: Remove the job-level conditional that gates the entire
security job on backend/frontend changes (the "if: ${{
needs.changes.outputs.backend == 'true' || needs.changes.outputs.frontend ==
'true' }}" line) so the security job always runs; instead, keep any path-based
gating at the step level (e.g., inside the Trivy/scan step) so only the scanner
step skips when irrelevant, ensuring other security checks and secret scans
still execute for all commits.

In `@backend/.flake8`:
- Line 2: The flake8 config currently sets max-line-length = 120 but excludes
E501 by using "select = E9,F,W6" (and only listed E501 in extend-ignore), so
line-too-long checks aren’t enforced; update the config to include E501 in the
selected codes (e.g., add E to the select or include E501 explicitly) or remove
the restrictive "select = E9,F,W6" so the default E codes (including E501) are
checked, and keep "max-line-length = 120" as the enforced limit.

---

Nitpick comments:
In `@backend/services/dna_extractor.py`:
- Line 826: The list comprehension "[d for d in ['tests', 'test'] if (repo_path
/ d).exists()]" is a no-op because its result is discarded; replace it with a
meaningful check such as using any(...) to test presence (e.g. if any((repo_path
/ d).exists() for d in ['tests','test']): ...) or assign the list to a variable
(e.g. tests_dirs = [d for d in ['tests','test'] if (repo_path / d).exists()])
and use that variable where needed; reference the existing repo_path and
exists() calls to locate and update the logic.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 27643fb and 63d71f4.

📒 Files selected for processing (28)
  • .github/workflows/ci.yml
  • backend/.flake8
  • backend/dependencies.py
  • backend/main.py
  • backend/routes/auth.py
  • backend/routes/github.py
  • backend/routes/repos.py
  • backend/routes/search.py
  • backend/routes/ws_playground.py
  • backend/services/auth.py
  • backend/services/dependency_analyzer.py
  • backend/services/dna_extractor.py
  • backend/services/exceptions.py
  • backend/services/indexer_optimized.py
  • backend/services/indexing_events.py
  • backend/services/input_validator.py
  • backend/services/rate_limiter.py
  • backend/services/repo_manager.py
  • backend/services/search_enhancer.py
  • backend/services/search_v2/summary_generator.py
  • backend/services/search_v3/code_graph_ranker.py
  • backend/services/search_v3/embedding_provider.py
  • backend/services/search_v3/query_understanding.py
  • backend/services/search_v3/search_engine.py
  • backend/services/style_analyzer.py
  • backend/services/supabase_service.py
  • backend/services/user_limits.py
  • frontend/package.json
💤 Files with no reviewable changes (6)
  • backend/services/input_validator.py
  • backend/routes/github.py
  • backend/services/search_v3/embedding_provider.py
  • backend/routes/ws_playground.py
  • backend/services/auth.py
  • backend/services/exceptions.py

Comment thread .github/workflows/ci.yml
Comment thread backend/.flake8
… comprehension

1. .flake8: removed dead extend-ignore (select already filters). Clarified
   that style codes are intentionally excluded, only bugs checked.
2. dna_extractor.py: removed discarded list comprehension on line 826 that
   checked for test directories but never used the result.

Skipped: removing security job path gate (trufflehog already scans diff
only, Trivy on docs-only PRs wastes CI minutes for zero value).

289 tests pass. Zero flake8 errors.
…ing issues to warnings

The existing eslint.config.js used reactHooks.configs.flat.recommended
which doesn't exist in eslint-plugin-react-hooks@5.x. Rewrote config
using tseslint.config() flat config pattern with explicit plugin
registration.

92 pre-existing issues (43 no-explicit-any, 34 no-unused-vars, etc.)
downgraded from error to warn. ESLint now passes with 0 errors,
92 warnings. These will be fixed incrementally -- not in a CI gates PR.

Verified locally:
- bun run lint: 0 errors, 92 warnings (exit 0)
- bun run tsc --noEmit: clean
- bun run build: clean
- bun run test: 13 passed
- Backend: 289 passed, 0 flake8 errors

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
frontend/eslint.config.js (1)

31-31: varsIgnorePattern not set alongside argsIgnorePattern.

Variables prefixed with _ (e.g., _unused) will still trigger warnings; only function-argument names are silenced. Adding varsIgnorePattern: '^_' is the conventional pairing.

♻️ Proposed fix
-      '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
+      '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/eslint.config.js` at line 31, The rule configuration for
'@typescript-eslint/no-unused-vars' only sets argsIgnorePattern and therefore
still warns for variables prefixed with '_' (e.g., _unused); update the rule
object for '@typescript-eslint/no-unused-vars' to include varsIgnorePattern:
'^_' alongside argsIgnorePattern so both function arguments and variables
prefixed with '_' are ignored. Locate the '@typescript-eslint/no-unused-vars'
entry in eslint.config.js and add the varsIgnorePattern property to the same
rule configuration.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@frontend/eslint.config.js`:
- Line 31: The rule configuration for '@typescript-eslint/no-unused-vars' only
sets argsIgnorePattern and therefore still warns for variables prefixed with '_'
(e.g., _unused); update the rule object for '@typescript-eslint/no-unused-vars'
to include varsIgnorePattern: '^_' alongside argsIgnorePattern so both function
arguments and variables prefixed with '_' are ignored. Locate the
'@typescript-eslint/no-unused-vars' entry in eslint.config.js and add the
varsIgnorePattern property to the same rule configuration.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8c29d54 and 6c75af1.

⛔ Files ignored due to path filters (1)
  • frontend/bun.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • frontend/eslint.config.js

@vercel

vercel Bot commented Feb 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
opencodeintel Ready Ready Preview, Comment Feb 25, 2026 3:59am

@DevanshuNEU DevanshuNEU merged commit 1de8893 into OpenCodeIntel:main Feb 25, 2026
7 checks passed
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.

1 participant