Skip to content

fix: resolve open Sonar and Codacy findings; ship stable publish workflow#37

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

fix: resolve open Sonar and Codacy findings; ship stable publish workflow#37
JE-Chen merged 3 commits intomainfrom
dev

Conversation

@JE-Chen
Copy link
Copy Markdown
Member

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

Summary

  • Lint compliance: Address all 16 open SonarCloud issues and the actionable Codacy findings (Prospector unused imports, Bandit B105/B110/B404/B603). Suppress Bandit B101 in the test/ directory via .bandit and [tool.bandit] in pyproject.toml since assert is the standard pytest idiom.
  • Library hardening: drop redundant isinstance checks (S2589), prefer literals over list()/dict() (S7498), remove redundant json.JSONDecodeError from except tuple (S5713), iterate result via .values() (S7512), extract repeated content-file path into a constant (S1192), widen execute_action type hint to Union[list, dict] (S5655).
  • Test cleanup: replace hardcoded credential literals with secrets.token_hex (S2068/B105), remove unused imports/variables, replace try/except/pass with logged OSError handling, mark CLI subprocess test calls with # nosec since args are test-controlled constants.
  • Build/CI: bump dev.toml setuptools floor to match pyproject.toml and add the publish_stable.yml workflow that releases to PyPI on pushes to main.

Test plan

  • pytest — 55/55 passing locally on Python 3.14
  • bandit -c pyproject.toml -r je_mail_thunder — only one residual low-severity false positive on password: None literal default
  • Confirm SonarCloud quality gate passes after next analysis
  • Confirm Codacy issue count drops on the next scan
  • publish_stable.yml triggers correctly on the merge to main

JE-Chen added 2 commits April 25, 2026 15:42
Address the open issues reported by SonarCloud and Codacy on the
current branch so the quality gates pass on the next scan.

Library:
- Drop redundant isinstance(env_info, dict) checks in SMTP/IMAP
  credential resolution (S2589); get_mail_thunder_os_environ always
  returns a dict.
- Replace list()/dict() constructor calls with literals in
  imap_wrapper for hot-path readability (S7498).
- Remove json.JSONDecodeError from the except tuple in json_file
  since it is already a ValueError subclass (S5713).
- Iterate execute_action results via .values() in the socket server
  handler (S7512).
- Extract the "/mail_thunder_content.json" literal into a module
  constant in mail_thunder_content_save (S1192).
- Widen execute_action type hint to Union[list, dict] so dict
  payloads with auto_control are correctly typed (S5655).

Tests:
- Generate fake credentials with secrets.token_hex instead of
  hardcoded literals (S2068, B105).
- Drop unused result assignment, unused threading/tempfile/shutil
  imports (S1481, F401).
- Replace try/except/pass with logged OSError handling in the
  socket server teardown (B110).
- Mark CLI subprocess test calls with nosec since arguments are
  test-controlled constants (B404, B603).

Tooling:
- Add .bandit and [tool.bandit] in pyproject.toml so Bandit skips
  the test directory and B101, which is the standard pytest assert
  pattern, eliminating ~85 noise findings.
Align dev.toml with the setuptools floor already on pyproject.toml
and add the GitHub Actions workflow that publishes the stable
package to PyPI on pushes to main.
@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented Apr 25, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 2 duplication

Metric Results
Complexity 0
Duplication 2

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Move contents:write from workflow scope to the publish job and
restrict the test job to contents:read so the broad write capability
is only granted where the version-bump commit, tag push, and
release creation actually need it (githubactions:S8233).
@sonarqubecloud
Copy link
Copy Markdown

@JE-Chen JE-Chen merged commit b805743 into main Apr 25, 2026
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