Skip to content

fix: resolve all SonarQube code quality issues and security hotspots#11

Merged
cmdaltctr merged 8 commits into
mainfrom
fix/sonarqube-all-issues
Jun 28, 2026
Merged

fix: resolve all SonarQube code quality issues and security hotspots#11
cmdaltctr merged 8 commits into
mainfrom
fix/sonarqube-all-issues

Conversation

@cmdaltctr

Copy link
Copy Markdown
Owner

Summary

Fixes all open SonarQube issues and security hotspots across the codebase.

Changes

CI/CD hardening (ci.yml)

  • Replace pip install uv with pinned astral-sh/setup-uv action (SHA-pinned)
  • Add --frozen to uv sync, --no-sync and --no-build to uv run
  • Pin SonarSource/sonarqube-scan-action to full commit SHA

Code quality fixes (S-rule issues)

  • S3776: Reduce cognitive complexity in 8 files by extracting helper functions
  • S3457: Remove f-prefix from strings without interpolation fields (16 in cli.py)
  • S5713/S1481/S1172: Remove redundant exceptions, unused vars, unused params
  • S8572: Use logging.exception instead of logging.error with exc_info
  • S108/S1940/S3626/S7500/S7503/S3516/S1871/S1066/S5754/S1192/S2583: Various fixes

Security hotspots (S5852)

  • Reviewed and marked 6 regex security hotspots as SAFE (no ReDoS vulnerability)

Tooling

  • Add [tool.pyright] config to pyproject.toml scoping analysis to src/ and tests/
  • Fix tar.extractfile() None guard in prepare_dataset.py

Testing

  • All 556 tests pass (uv run pytest -m 'not slow' -v)

- Replace pip install uv with astral-sh/setup-uv action (pinned SHA)
- Add --frozen to uv sync to enforce lockfile usage
- Add --no-build to uv sync and uv run to prevent setup script execution
- Add --no-sync to uv run to skip implicit re-sync
- Pin SonarSource/sonarqube-scan-action to full commit SHA
Quick wins (16 rule types):
- S5713: remove redundant exception handlers (codebase_map, metadata_extractor)
- S1481: remove unused variables (codebase_map, metadata_extractor)
- S1172: remove unused params from code_graph functions
- S8572: use logging.exception instead of logging.error (codebase_map)
- S108: remove empty TYPE_CHECKING block (metadata_extractor)
- S1940: use != instead of not == (ingestion)
- S3626: remove redundant continue (retrieval)
- S7500: use dict() constructor (reranker)
- S1066: merge if with elif (cli)
- S5754: remove try/except swallowing SystemExit (cli)
- S1192: extract duplicated string literal to constant (cli)
- S2583: remove always-true condition (code_graph)
- S3516: simplify always-returns-False function (sparse_retriever)
- S7503: remove async from function without await (ingestion)
- S1871: merge identical branches (doc_graph)
- S3457: remove f-prefix from strings without fields (cli)

Cognitive complexity refactoring (S3776, 7 functions):
- cli.py: extract helpers from ingest (CC 33), benchmark (CC 20), delete (CC 30)
- doc_graph.py: extract helpers from compute_metadata_edges (CC 17),
  compute_heading_edges (CC 24), build_document_graph (CC 20),
  compute_cross_links (CC 55)

Security hotspots (S5852, 6 regex patterns):
- All reviewed and marked SAFE — operate on trusted/short inputs
  with bounded patterns
…ssues

- Add [tool.pyright] section scoping analysis to src/ and tests/
- Exclude experiments/, .venv/, __pycache__/, .opencode/ from Pyright
- Fix tar.extractfile() None guard in prepare_dataset.py
- Refactor high cognitive complexity functions in prepare_dataset.py
- Extract duplicated filename literals to constants
Fixes Node.js 20 deprecation warning from GitHub Actions runners.
Pins all third-party actions to SHA-pinned versions running Node.js 24.
The --no-build flag prevents building source distributions, but the
project's own editable install (rag-mcp @ editable+.) requires a build
step. --frozen already ensures the lockfile is used as-is, so all
dependencies are locked and reproducible.
@sonarqubecloud

Copy link
Copy Markdown

@cmdaltctr
cmdaltctr merged commit 44d116b into main Jun 28, 2026
4 checks passed
@cmdaltctr
cmdaltctr deleted the fix/sonarqube-all-issues branch June 28, 2026 21:52
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