Skip to content

chore: resolve code quality findings - #31

Merged
RyanMorash merged 2 commits into
mainfrom
chore/code-quality-findings
Jun 29, 2026
Merged

chore: resolve code quality findings#31
RyanMorash merged 2 commits into
mainfrom
chore/code-quality-findings

Conversation

@RyanMorash

@RyanMorash RyanMorash commented Jun 29, 2026

Copy link
Copy Markdown
Member

Resolves GitHub Code Quality findings (CodeQL quality suite + AI findings).

CodeQL quality finding

src/door_sync/civicrm/client.py:34_DEFAULT_ACTIVE_STATUSES flagged as an unused module variable. Verified true positive (defined once, referenced nowhere; the client uses self._config.active_statuses and the default lives in the config loader). Removed.

AI quality findings — tests/test_alert.py

  • Mailgun tests: assert resp.raise_for_status() is called, so the HTTP status is actually checked (a 4xx/5xx surfaces as a failure, not a silent success). Removed the no-op lambda that had blocked the assertion.
  • SMTP mock: dropped the redundant manual __enter__/__exit__mock_cls.return_value is already a MagicMock supporting the context-manager protocol (and __exit__ returns False, so it won't swallow exceptions); _send_smtp uses with server: (no as).

AI quality findings — tests/test_unifi_client.py

  • _patched_tls: use real ssl constants (CERT_NONE / PROTOCOL_TLS_CLIENT / TLSVersion) instead of magic 0s (PROTOCOL_TLS_CLIENT is actually 2).
  • FC-mismatch assertion: plain "expected 42" instead of f"expected {42}".
  • Moved local imports (replace, config.load) to module top.
  • Added an explicit non-ASCII decimal-digit case (Bengali ) to the _parse_sync_alias rejection test, verifying the isascii() guard (not just the superscript case).

All findings were verified against the code before applying; two of the AI suggestions were adjusted where their literal form was wrong (the raise_for_status assert needed the lambda removed first; "just use MagicMock" for the SMTP CM would have needed the redundant lines removed, not replaced).

Verification

  • uv run pytest343 passed
  • uv run pyrefly check → 0 errors
  • uv run ruff check . / ruff format --check . → clean

🤖 Generated with Claude Code

CodeQL's quality suite flagged src/door_sync/civicrm/client.py:34 as an
unused module variable. _DEFAULT_ACTIVE_STATUSES was defined but never
referenced: the client reads self._config.active_statuses, and the
config default ("Current","Grace","New") is defined independently in the
config loader. Removing the stale duplicate eliminates a second,
drift-prone "source of truth" for the default.

No behavior change; pyrefly/ruff/pytest green (343 passed).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 29, 2026 20:39
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

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

Next review available in: 21 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: a009e063-0e44-4909-bfe6-484c8cdbb06d

📥 Commits

Reviewing files that changed from the base of the PR and between adbdeeb and 30d6432.

📒 Files selected for processing (3)
  • src/door_sync/civicrm/client.py
  • tests/test_alert.py
  • tests/test_unifi_client.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/code-quality-findings

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.

@github-code-quality

github-code-quality Bot commented Jun 29, 2026

Copy link
Copy Markdown

Code Coverage Overview

Languages: Python

Python / code-coverage/pytest

The overall coverage remains at 93%, unchanged from the main branch.


Updated June 29, 2026 20:46 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Removes a stale, unused module-level constant in the CiviCRM client to address a GitHub Code Quality finding and reduce configuration drift risk (the active membership statuses default is already owned by the config loader).

Changes:

  • Removed unused _DEFAULT_ACTIVE_STATUSES constant from src/door_sync/civicrm/client.py.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

test_alert.py:
- Mailgun tests now assert resp.raise_for_status() is called (the HTTP
  status is checked, so a 4xx/5xx surfaces as a failure). Dropped the
  no-op lambda override that had blocked the assertion.
- Dropped redundant manual __enter__/__exit__ on the SMTP server mock:
  mock_cls.return_value is a MagicMock that already supports the context
  manager (and __exit__ returns False, so it won't swallow exceptions);
  _send_smtp uses `with server:` with no `as`.

test_unifi_client.py:
- _patched_tls uses real ssl constants (CERT_NONE / PROTOCOL_TLS_CLIENT /
  TLSVersion) instead of magic 0s (PROTOCOL_TLS_CLIENT is 2, not 0).
- Assert the FC-mismatch message with a plain "expected 42" string, not
  f"expected {42}".
- Moved local imports (replace, config.load) to module top.
- Added an explicit non-ASCII regular-digit case (Bengali ১) to the
  _parse_sync_alias rejection test, verifying the isascii() guard.

343 passed; pyrefly 0 errors; ruff clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@RyanMorash
RyanMorash merged commit a7fe67f into main Jun 29, 2026
6 checks passed
@RyanMorash
RyanMorash deleted the chore/code-quality-findings branch June 29, 2026 20:47
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.

2 participants