Skip to content

refactor: enforce SonarQube/Codacy linter compliance#36

Merged
JE-Chen merged 3 commits intomainfrom
dev
Apr 18, 2026
Merged

refactor: enforce SonarQube/Codacy linter compliance#36
JE-Chen merged 3 commits intomainfrom
dev

Conversation

@JE-Chen
Copy link
Copy Markdown
Member

@JE-Chen JE-Chen commented Apr 18, 2026

Summary

  • Adds a Linter Compliance section to CLAUDE.md encoding the SonarQube, Codacy, Pylint, Flake8, and Bandit rules this codebase must satisfy (complexity limits, naming, exception handling, mutable defaults, Bandit security hotspots, imports, formatting, docstrings).
  • Brings the existing library into compliance: flattens nested login flows in SMTPWrapper / IMAPWrapper via a shared _resolve_credentials helper, chains re-raises with from, replaces manual Lock.acquire() / release() with with _lock:, narrows broad except Exception to specific exceptions, drops redundant (object) inheritance and empty-placeholder f-strings, and stops shadowing the stdlib socket name in the socket handler.
  • Also bundles in the earlier additions on this branch: CLAUDE.md project guide and the filename/socket-payload hardening.

Test plan

  • py -m pytest test/ — 53 passed (the 2 socket.gaierror failures in test_socket_server are pre-existing environment issues unrelated to this change, reproducible on main).
  • Reviewer: spot-check SonarQube / Codacy scan on the PR to confirm the flagged rules no longer trigger.

JE-Chen added 3 commits April 18, 2026 00:46
- sanitize SUBJECT-derived filenames in output_all_mail_as_file and
  reject path traversal via basename, separator stripping, and a
  commonpath check so writes cannot escape cwd
- validate socket server JSON payloads (shape, size, command-name
  types) before dispatching to the executor, and guard recv against
  buffer overflow and undecodable bytes
- route library-code diagnostics through mail_thunder_logger instead
  of print(), and correct docstring placement in the IMAP wrapper
Add a Linter Compliance section to CLAUDE.md documenting the SonarQube,
Codacy, Pylint, Flake8, and Bandit rules the codebase must satisfy, and
bring existing modules into compliance: flatten deeply nested login
flows, replace broad except swallows with specific exceptions, chain
raises with `from` to preserve tracebacks, switch manual lock
acquire/release to `with` blocks, remove redundant `object` inheritance
and empty-placeholder f-strings, replace `dict()`/`list()` literals,
and stop shadowing stdlib names. No behavioral changes; existing tests
(53) still pass.
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
14.1% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 13 complexity · 0 duplication

Metric Results
Complexity 13
Duplication 0

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

@JE-Chen JE-Chen merged commit a349ebb into main Apr 18, 2026
25 of 26 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