Skip to content

Commit 49a3c88

Browse files
committed
Clear SonarCloud and Codacy findings across package and tests
Address the full current SonarCloud queue (43 issues) and the Codacy backlog (166 issues) so new analyzer runs start from a clean baseline. - rest_server: stop echoing user-controlled paths/errors; log server-side and return generic messages (fixes reflected-XSS blocker) - KeypressHandler: stop inheriting Thread and rename the callback to handle_reply; Thread.run signature mismatch was a latent override bug - Drop NotImplementedError / NotADirectoryError / UnicodeDecodeError / JSONDecodeError from except tuples that already catch their parent - change_xml_structure: split the two recursive helpers by responsibility to bring cognitive complexity back under the 15-line limit - Replace stdlib xml.etree/xml.dom.minidom parsing with defusedxml across xml_file, change_xml_structure, and generate_xml_report - Extract repeated string literals (JSON filter, {temp} placeholder, keycode error, calculator image paths) into module constants - Validate package names before importlib.import_module; use argv lists and timeouts for every subprocess call; drop shell=True - Add .codacy.yaml excluding test/** from bandit and [tool.bandit] in pyproject.toml so pytest assertions stop tripping B101 - Fix stale README TOC anchors (EN/zh-CN/zh-TW) and the Sphinx copyright builtin rebind - Iterate dict.values() directly in socket_server, use slice copy for language listeners, tighten regex to \w, drop stray list()/dict() - Refresh test fixtures (unused imports, loop-once, opposite-operator, positional-args mismatch) so the tests stop generating findings
1 parent 508e45b commit 49a3c88

46 files changed

Lines changed: 319 additions & 338 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.codacy.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
# Codacy repository configuration.
3+
# Docs: https://docs.codacy.com/repositories-configure/codacy-configuration-file/
4+
5+
engines:
6+
bandit:
7+
enabled: true
8+
exclude_paths:
9+
# Test code legitimately uses `assert` (B101); pytest depends on it.
10+
# Library/non-test code is constrained by CLAUDE.md "no assert outside tests".
11+
- "test/**"
12+
13+
# Drop generated docs / build outputs from analysis entirely.
14+
exclude_paths:
15+
- "docs/build/**"
16+
- ".venv/**"
17+
- "build/**"
18+
- "dist/**"

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,16 @@
1818
- [Installation](#installation)
1919
- [Requirements](#requirements)
2020
- [Quick Start](#quick-start)
21-
- [API Reference](#api-reference)
2221
- [Mouse Control](#mouse-control)
2322
- [Keyboard Control](#keyboard-control)
2423
- [Image Recognition](#image-recognition)
2524
- [Accessibility Element Finder](#accessibility-element-finder)
2625
- [AI Element Locator (VLM)](#ai-element-locator-vlm)
2726
- [OCR (Text on Screen)](#ocr-text-on-screen)
2827
- [Clipboard](#clipboard)
29-
- [Screen Operations](#screen-operations)
28+
- [Screenshot](#screenshot)
3029
- [Action Recording & Playback](#action-recording--playback)
31-
- [Action Scripting (JSON Executor)](#action-scripting-json-executor)
30+
- [JSON Action Scripting](#json-action-scripting)
3231
- [Scheduler (Interval & Cron)](#scheduler-interval--cron)
3332
- [Global Hotkey Daemon](#global-hotkey-daemon)
3433
- [Event Triggers](#event-triggers)

README/README_zh-CN.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@
1717
- [安装](#安装)
1818
- [系统要求](#系统要求)
1919
- [快速开始](#快速开始)
20-
- [API 参考](#api-参考)
2120
- [鼠标控制](#鼠标控制)
2221
- [键盘控制](#键盘控制)
2322
- [图像识别](#图像识别)
2423
- [Accessibility 元件搜索](#accessibility-元件搜索)
2524
- [AI 元件定位(VLM)](#ai-元件定位vlm)
2625
- [OCR 屏幕文字识别](#ocr-屏幕文字识别)
2726
- [剪贴板](#剪贴板)
28-
- [屏幕操作](#屏幕操作)
27+
- [截图](#截图)
2928
- [动作录制与回放](#动作录制与回放)
3029
- [JSON 脚本执行器](#json-脚本执行器)
3130
- [调度器(Interval & Cron)](#调度器interval--cron)

README/README_zh-TW.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@
1717
- [安裝](#安裝)
1818
- [系統需求](#系統需求)
1919
- [快速開始](#快速開始)
20-
- [API 參考](#api-參考)
2120
- [滑鼠控制](#滑鼠控制)
2221
- [鍵盤控制](#鍵盤控制)
2322
- [圖像辨識](#圖像辨識)
2423
- [Accessibility 元件搜尋](#accessibility-元件搜尋)
2524
- [AI 元件定位(VLM)](#ai-元件定位vlm)
2625
- [OCR 螢幕文字辨識](#ocr-螢幕文字辨識)
2726
- [剪貼簿](#剪貼簿)
28-
- [螢幕操作](#螢幕操作)
27+
- [截圖](#截圖)
2928
- [動作錄製與回放](#動作錄製與回放)
3029
- [JSON 腳本執行器](#json-腳本執行器)
3130
- [排程器(Interval & Cron)](#排程器interval--cron)

dev.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Rename to build dev version
22
# This is dev version
33
[build-system]
4-
requires = ["setuptools"]
4+
requires = ["setuptools>=82.0.1"]
55
build-backend = "setuptools.build_meta"
66

77
[project]

dev_requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ sphinx-rtd-theme
77
PySide6==6.11.0
88
qt-material==2.17
99
mss==10.1.0
10+
defusedxml==0.7.1

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# -- Project information -----------------------------------------------------
1212

1313
project = 'AutoControl'
14-
copyright = '2020 ~ Now, JE-Chen'
14+
copyright = '2020 ~ Now, JE-Chen' # noqa: A001 # reason: Sphinx-required name
1515
author = 'JE-Chen'
1616
release = '0.0.179'
1717

je_auto_control/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
from je_auto_control.wrapper.auto_control_image import locate_all_image
139139
from je_auto_control.wrapper.auto_control_image import locate_and_click
140140
from je_auto_control.wrapper.auto_control_image import locate_image_center
141-
# import keyboard
141+
# Keyboard wrappers
142142
from je_auto_control.wrapper.auto_control_keyboard import check_key_is_press
143143
from je_auto_control.wrapper.auto_control_keyboard import get_keyboard_keys_table
144144
from je_auto_control.wrapper.auto_control_keyboard import hotkey
@@ -148,7 +148,7 @@
148148
from je_auto_control.wrapper.auto_control_keyboard import send_key_event_to_window
149149
from je_auto_control.wrapper.auto_control_keyboard import type_keyboard
150150
from je_auto_control.wrapper.auto_control_keyboard import write
151-
# import mouse
151+
# Mouse wrappers
152152
from je_auto_control.wrapper.auto_control_mouse import click_mouse
153153
from je_auto_control.wrapper.auto_control_mouse import get_mouse_position
154154
from je_auto_control.wrapper.auto_control_mouse import mouse_keys_table
@@ -162,7 +162,7 @@
162162
# record
163163
from je_auto_control.wrapper.auto_control_record import record
164164
from je_auto_control.wrapper.auto_control_record import stop_record
165-
# import screen
165+
# Screen wrappers
166166
from je_auto_control.wrapper.auto_control_screen import screen_size
167167
from je_auto_control.wrapper.auto_control_screen import screenshot
168168
from je_auto_control.wrapper.auto_control_screen import get_pixel

je_auto_control/gui/language_wrapper/multi_language_wrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def reset_language(self, language: str) -> None:
4949
return
5050
self.language = language
5151
self.language_word_dict = self._merged(language)
52-
for listener in list(self._listeners):
52+
for listener in self._listeners[:]:
5353
try:
5454
listener(language)
5555
except (OSError, RuntimeError) as error:

je_auto_control/gui/main_widget.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
from je_auto_control.utils.file_process.get_dir_file_list import get_dir_files_as_list
3434

3535

36+
_JSON_FILE_FILTER = "JSON (*.json)"
37+
38+
3639
def _t(key: str) -> str:
3740
"""language_wrapper shorthand"""
3841
return language_wrapper.translate(key, key)
@@ -499,15 +502,15 @@ def _save_record(self):
499502
if not self._record_data:
500503
QMessageBox.warning(self, "Warning", "No recorded data")
501504
return
502-
path, _ = QFileDialog.getSaveFileName(self, _t("save_record"), "", "JSON (*.json)")
505+
path, _ = QFileDialog.getSaveFileName(self, _t("save_record"), "", _JSON_FILE_FILTER)
503506
if path:
504507
write_action_json(path, self._record_data)
505508
except (OSError, ValueError, TypeError, RuntimeError) as error:
506509
QMessageBox.warning(self, "Error", str(error))
507510

508511
def _load_record(self):
509512
try:
510-
path, _ = QFileDialog.getOpenFileName(self, _t("load_record"), "", "JSON (*.json)")
513+
path, _ = QFileDialog.getOpenFileName(self, _t("load_record"), "", _JSON_FILE_FILTER)
511514
if path:
512515
self._record_data = read_action_json(path)
513516
self.record_list_text.setText(json.dumps(self._record_data, indent=2, ensure_ascii=False))
@@ -560,7 +563,7 @@ def _build_script_tab(self) -> QWidget:
560563
return tab
561564

562565
def _browse_script(self):
563-
path, _ = QFileDialog.getOpenFileName(self, _t("load_script"), "", "JSON (*.json)")
566+
path, _ = QFileDialog.getOpenFileName(self, _t("load_script"), "", _JSON_FILE_FILTER)
564567
if path:
565568
self.script_path_input.setText(path)
566569
try:

0 commit comments

Comments
 (0)