Skip to content

Add tests, coverage, line-count hooks, and pip-audit - #2

Merged
kgrizz-git merged 5 commits into
mainfrom
harness/tests-coverage-audit
Jul 31, 2026
Merged

Add tests, coverage, line-count hooks, and pip-audit#2
kgrizz-git merged 5 commits into
mainfrom
harness/tests-coverage-audit

Conversation

@kgrizz-git

@kgrizz-git kgrizz-git commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Summary

  • Unit tests for session, deps, and disks (13 cases); coverage fail-under 70% on core modules (gui/runner/__main__ omitted)
  • Ruff C901 complexity (max 12); hooks/check_file_size.py on pre-commit + pre-push
  • CI: pytest+coverage, pip-audit on a clean [dev] install, existing Ruff/path/gitleaks checks
  • Bump to 0.1.3

Test plan

  • Clean venv: pip install -e ".[dev]" && pytest --cov && pip-audit (no vulns)
  • pre-commit run --all-files
  • CI green on this PR (lint + test + coverage, pip-audit, gitleaks)

Made with Cursor

Summary by CodeRabbit

  • New Features

    • Added automated coverage reporting, dependency auditing, Semgrep scans, and code-quality checks.
    • Added configurable file-size and line-count validation for source and documentation files.
    • Added SonarCloud automatic analysis configuration.
    • Expanded automated tests for dependencies, disks, session persistence, and validation rules.
  • Documentation

    • Updated project documentation and changelogs for version 0.1.3.
    • Documented new development checks and quality standards.
  • Chores

    • Updated the project version to 0.1.3.
    • Added testing and auditing tools to the development setup.
    • Added pre-commit and pre-push quality checks.

Gate complexity with Ruff C901 and keep runtime stdlib-only while expanding optional [dev] tooling.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@kgrizz-git, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 49 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c401205c-8c98-4f6b-8e6d-56d3a6f14d08

📥 Commits

Reviewing files that changed from the base of the PR and between e2d5516 and 7ff09fe.

📒 Files selected for processing (3)
  • .github/workflows/ci.yml
  • CHANGELOG.dev.md
  • CHANGELOG.md
📝 Walkthrough

Walkthrough

The project adds file-size checks, pytest coverage, Ruff complexity enforcement, dependency auditing, Semgrep scanning, SonarCloud configuration, expanded tests, and version 0.1.3 release documentation.

Changes

Project quality gates

Layer / File(s) Summary
File-size validation implementation and tests
hooks/check_file_size.py, tests/test_check_file_size.py, .pre-commit-config.yaml
Adds configurable byte and line-count validation for tracked or supplied source and documentation files. Tests cover ignored paths, overrides, source and documentation caps, and byte limits. Pre-commit and pre-push hooks run the checker.
Quality check configuration and CI wiring
pyproject.toml, .github/workflows/ci.yml, .semgrepignore
Adds development tools, coverage settings, Ruff complexity limits, CI coverage checks, dependency auditing, Semgrep scanning, pinned action SHAs, and scan exclusions.
Core module test coverage
tests/test_deps.py, tests/test_disks.py, tests/test_session.py
Adds tests for dependency discovery, disk helpers, disk errors, and session persistence edge cases.
SonarCloud and release documentation
.sonarcloud.properties, AGENTS.md, README.md, CHANGELOG.md, CHANGELOG.dev.md, VERSION
Documents SonarCloud Automatic Analysis and quality constraints, updates project checks, records release 0.1.3, and updates the project version.

Estimated code review effort: 3 (Moderate) | ~25 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: tests, coverage, line-count hooks, and dependency auditing.
Description check ✅ Passed The description explains the main changes, documents testing, and notes that CI validation is still pending.
Docstring Coverage ✅ Passed Docstring coverage is 90.63% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch harness/tests-coverage-audit

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.

Use .sonarcloud.properties so SonarCloud can analyze via the GitHub App without a CI token.

Co-authored-by: Cursor <cursoragent@cursor.com>
@kgrizz-git

Copy link
Copy Markdown
Owner Author

Follow-up on this PR:

  • Source hard line-count cap is now 800 (soft still 600).
  • SonarCloud path is Automatic Analysis (.sonarcloud.properties) — no SONAR_TOKEN / no Actions Sonar job. After importing the repo in SonarCloud, turn on Administration → Analysis Method → Automatic Analysis.

@kgrizz-git

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: 4

🧹 Nitpick comments (1)
hooks/check_file_size.py (1)

116-154: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add unit tests for the line-count checker logic.

_check_file has several branches: byte-size limits, doc vs. source cap selection, per-file override parsing, and ignore rules. None of this logic has tests. Since hooks/ is outside the source = ["dislocker_ui"] coverage scope, this gap will not surface in the coverage report.

Add a tests/test_check_file_size.py covering: override cap parsing, hard vs. soft threshold boundaries, and _ignored path matching.
Do you want me to generate this test file?

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@hooks/check_file_size.py` around lines 116 - 154, The line-count checker
lacks unit coverage for its key branching behavior. Add tests in
tests/test_check_file_size.py covering _override_cap parsing, _check_file hard
and soft threshold boundaries for source and documentation files, and _ignored
path matching, including relevant byte-size and override cases exposed by the
implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci.yml:
- Around line 46-63: Update the actions/checkout@v4 steps in the audit job and
every other checkout step in this workflow to set persist-credentials to false,
while preserving their existing checkout behavior.

In @.sonarcloud.properties:
- Line 11: Update the sonar.exclusions configuration in .sonarcloud.properties
to remove the unsupported wildcard exclusions for Automatic Analysis. Configure
these paths through SonarQube Cloud Analysis Scope or its API instead, or
migrate to CI-based analysis if retaining wildcard patterns is required.

In `@CHANGELOG.dev.md`:
- Around line 13-14: Correct only the pytest suite entry in CHANGELOG.dev.md by
adding the full tests/ prefix to test_deps.py and test_disks.py, matching
tests/test_session.py; leave the Ruff C90 entry unchanged.

In `@hooks/check_file_size.py`:
- Around line 48-49: Update the extension classification used by _check_file so
.toml files, including pyproject.toml, use SOFT_LINE_CAP and HARD_LINE_CAP
rather than the DOC_* caps. Move .toml from DOC_EXTS to SOURCE_EXTS, preserving
the existing handling for other documentation extensions.

---

Nitpick comments:
In `@hooks/check_file_size.py`:
- Around line 116-154: The line-count checker lacks unit coverage for its key
branching behavior. Add tests in tests/test_check_file_size.py covering
_override_cap parsing, _check_file hard and soft threshold boundaries for source
and documentation files, and _ignored path matching, including relevant
byte-size and override cases exposed by the implementation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5faec74a-ca98-46e8-883a-3551af9aaaa6

📥 Commits

Reviewing files that changed from the base of the PR and between 8c1caf6 and f00c574.

📒 Files selected for processing (14)
  • .github/workflows/ci.yml
  • .pre-commit-config.yaml
  • .sonarcloud.properties
  • AGENTS.md
  • CHANGELOG.dev.md
  • CHANGELOG.md
  • README.md
  • VERSION
  • hooks/check_file_size.py
  • pyproject.toml
  • tests/.gitkeep
  • tests/test_deps.py
  • tests/test_disks.py
  • tests/test_session.py
💤 Files with no reviewable changes (1)
  • tests/.gitkeep

Comment thread .github/workflows/ci.yml
Comment thread .sonarcloud.properties Outdated
Comment thread CHANGELOG.dev.md Outdated
Comment thread hooks/check_file_size.py Outdated
kgrizz-git and others added 2 commits July 31, 2026 00:28
Disable checkout credential persistence, drop unsupported Sonar wildcard exclusions, treat .toml as source for line caps, and cover the size hook.

Co-authored-by: Cursor <cursoragent@cursor.com>
Local Semgrep flagged mutable Action tags; SHA pins clear that and
harden CI. Also split a Sonar composite assert in the file-size hook test.

Co-authored-by: Cursor <cursoragent@cursor.com>

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci.yml:
- Around line 72-73: Update the container image in the workflow’s container
configuration to use the intended Semgrep version pinned by its immutable digest
instead of the untagged semgrep/semgrep reference, and add a readable comment
identifying the pinned version.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 18e8dd8b-fa08-434a-b945-ec53f742b421

📥 Commits

Reviewing files that changed from the base of the PR and between f00c574 and e2d5516.

📒 Files selected for processing (9)
  • .github/workflows/ci.yml
  • .semgrepignore
  • .sonarcloud.properties
  • AGENTS.md
  • CHANGELOG.dev.md
  • CHANGELOG.md
  • README.md
  • hooks/check_file_size.py
  • tests/test_check_file_size.py
🚧 Files skipped from review as they are similar to previous changes (6)
  • .sonarcloud.properties
  • AGENTS.md
  • CHANGELOG.md
  • CHANGELOG.dev.md
  • README.md
  • hooks/check_file_size.py

Comment thread .github/workflows/ci.yml Outdated
Addresses CodeRabbit/zizmor unpinned-images on the mutable semgrep/semgrep tag.

Co-authored-by: Cursor <cursoragent@cursor.com>
@sonarqubecloud

Copy link
Copy Markdown

@kgrizz-git
kgrizz-git merged commit 006abfe into main Jul 31, 2026
9 checks passed
@kgrizz-git
kgrizz-git deleted the harness/tests-coverage-audit branch July 31, 2026 14:16
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