Skip to content

Enforce SonarQube/Codacy rules and split platform_wrapper backends#171

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

Enforce SonarQube/Codacy rules and split platform_wrapper backends#171
JE-Chen merged 4 commits intomainfrom
dev

Conversation

@JE-Chen
Copy link
Copy Markdown
Member

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

Summary

  • Add a Static Analysis Compliance section to CLAUDE.md covering SonarQube / Codacy / Pylint / Bandit rules (complexity, exception chaining, security, resources, style, tests, verification commands).
  • Apply the rules across je_auto_control/: replace print() with autocontrol_logger, narrow broad except Exception to specific tuples, add raise ... from error for chain preservation, and rename shadowed exception variables.
  • Remove shell=True from ShellManager and normalize commands via shlex to an argv list (fixes Bandit B602). Drop sys.argv side effects from start_autocontrol_socket_server and bind default host to 127.0.0.1 for least privilege.
  • Replace wildcard Cocoa/Foundation imports in the macOS listener with explicit symbols (python:S2208).
  • Split the 1080-line wrapper/platform_wrapper.py monolith into _platform_linux.py, _platform_osx.py, _platform_windows.py to satisfy the new 750-line file limit.
  • Drop duplicated Auto Click tab code from AutoControlGUIWidget; AutoClickTabMixin is the single source of truth.

Test plan

  • py -m py_compile on every modified module passes (verified locally).
  • ruff check je_auto_control/ reports no new issues.
  • pylint je_auto_control/ reports no new issues.
  • bandit -r je_auto_control/ -x je_auto_control/test reports no new issues.
  • radon cc je_auto_control/ -a -nc flags no functions at complexity C or higher.
  • Unit tests: python -m pytest test/unit_test/ on Windows, macOS, Linux.
  • Socket server integration test: test/unit_test/socket_server_test/socket_server_test.py still starts server on default localhost:9938.
  • Manual GUI smoke test: Auto Click tab still renders and click/hotkey/write/scroll flows work.
  • ShellManager.exec_shell still runs commands on Windows without shell=True (argv or shlex-splittable string).

JE-Chen added 4 commits April 18, 2026 00:13
- Remove Python builtins injection into executor event_dict so only
  AC_-prefixed allowlist is callable via JSON/socket payloads.
- Pin core and platform dependencies in pyproject.toml and align
  PySide6 between pyproject, requirements, and dev_requirements.
- Make create_project_dir's lock module-level and cover all writes.
- Replace get_dir_files_as_list's mutable getcwd() default with None
  sentinel evaluated per call.
- Remove unused imports and deduplicate __all__.
Update example jsons
- CLAUDE.md: add Static Analysis Compliance section covering complexity,
  exception chaining, Bandit security, resource management, and naming.
- Replace print() in library code with autocontrol_logger across utils,
  wrapper, osx, and linux backends to satisfy python:S4792.
- Narrow bare `except Exception` to specific exception tuples and add
  `raise ... from error` for chain preservation (python:S5655).
- Remove shell=True from ShellManager; normalize commands via shlex to
  argv list, eliminating Bandit B602.
- Replace wildcard Cocoa/Foundation imports in osx_listener with
  explicit symbols (python:S2208).
- Drop sys.argv side effects from start_autocontrol_socket_server; bind
  default host to 127.0.0.1 for least privilege.
- Split platform_wrapper monolith into _platform_linux / _platform_osx /
  _platform_windows to satisfy the 750-line file limit.
AutoClickTabMixin owns the _build_auto_click_tab / _do_click / _send_*
methods; the copies in main_widget were dead duplicates.
@sonarqubecloud
Copy link
Copy Markdown

@codacy-production
Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 1 critical · 1 high

Alerts:
⚠ 2 issues (≤ 0 issues of at least minor severity)

Results:
2 new issues

Category Results
ErrorProne 1 high
Security 1 critical

View in Codacy

🟢 Metrics -33 complexity · 2 duplication

Metric Results
Complexity -33
Duplication 2

View in Codacy

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

@JE-Chen JE-Chen merged commit 2a9ab52 into main Apr 18, 2026
7 of 8 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