Repository navigation
Commit 2a294b1
committed
feat: audit-driven precision pass (0.4.1) — kill more false positives, fix correctness/output bugs
Verified follow-ups from the multi-agent audit, validated against the 32-package
PyPI corpus benchmark. The `elif` fix alone cuts no-deep-nesting findings on
respected code from ~6040 to ~1638.
False positives removed / narrowed
- no-deep-nesting no longer counts `elif` branches as deeper nesting.
- Library rules are now gated per-file on an actual import of the library
(pandas rules never fire on a file that doesn't import pandas, etc.) instead of
running project-wide from the dependency manifest — this also activates a
framework's own rules on its own code, which dependency detection missed.
- http-missing-timeout scoped to requests.<method>() (dict/object .get(), httpx,
and requests.Session() no longer flagged).
- logging f-string / exc-info checks only fire on real logger receivers; any
truthy exc_info satisfies the traceback check. (LoggingRules was previously
dead — never activated — and is now wired up via imports.)
- FastAPI: a return-type annotation satisfies response_model; only app/router
receivers count as routes (not @cache.get); the sync-endpoint message is now
accurate (threadpool, not "blocks the event loop").
- Django: raw-SQL requires an actual SQL keyword; N+1 suppressed when
select_related/prefetch_related is already used.
- Flask/SQLAlchemy: placeholder-free f-strings are static, not injection; Flask
detects SQL f-strings passed directly to execute().
- pandas chained-indexing / NaN-comparison require a real DataFrame/Series base.
- no-string-concat-in-loop is scope-aware (no longer flags numeric accumulators).
Correctness / robustness
- _count_lines no longer crashes the whole scan on a non-UTF-8 file.
- Score is clamped to [0, 100] and negative max-deduction overrides are clamped.
- Per-category display sub-scores come from a single source in score.py and honour
config/profile max-deduction overrides (display no longer diverges from the score).
- cli profile suppresses the rule IDs the rules actually emit (no-os-system /
no-subprocess-shell).
- complexity counts match/case arms; type-coverage counts posonly/kwonly/*args.
- run_ruff_fix matches modern ruff output; --fix status goes to stderr (keeps
--json/--score/--sarif stdout clean).
- SARIF omits region for project-level (line 0) findings; JSON output includes profile.
- Badge URL escapes the score slash; pre-commit installer no longer corrupts a
foreign hook.
Packaging / docs / tests
- Ship py.typed (the Typing :: Typed classifier now holds).
- Accept the documented [per-file-ignores] config key; fix invalid TOML and
inaccurate pre-commit/profile/CLI docs.
- Stop tracking committed __pycache__ bytecode.
- Add tests/test_audit_fixes.py; full suite green (253), ruff clean, self-scan
passes --fail-on error.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016vrB7VNXwJeCKUeh378zJh1 parent 8c7c895 commit 2a294b1
35 files changed
Lines changed: 664 additions & 212 deletions
File tree
- skills/pycodegate
- src/pycodegate
- __pycache__
- rules
- utils
- tests
- __pycache__
- rules
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
259 | | - | |
260 | | - | |
| 259 | + | |
261 | 260 | | |
262 | 261 | | |
263 | 262 | | |
| |||
294 | 293 | | |
295 | 294 | | |
296 | 295 | | |
297 | | - | |
| 296 | + | |
| 297 | + | |
298 | 298 | | |
299 | 299 | | |
300 | | - | |
| 300 | + | |
301 | 301 | | |
302 | 302 | | |
303 | | - | |
| 303 | + | |
| 304 | + | |
304 | 305 | | |
305 | 306 | | |
306 | 307 | | |
307 | 308 | | |
308 | 309 | | |
309 | 310 | | |
310 | 311 | | |
311 | | - | |
| 312 | + | |
312 | 313 | | |
313 | 314 | | |
314 | 315 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
Binary file not shown.
Binary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | | - | |
| 63 | + | |
63 | 64 | | |
64 | | - | |
| 65 | + | |
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
84 | 89 | | |
85 | 90 | | |
86 | 91 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | 82 | | |
118 | 83 | | |
119 | 84 | | |
| |||
152 | 117 | | |
153 | 118 | | |
154 | 119 | | |
155 | | - | |
156 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
157 | 123 | | |
158 | 124 | | |
159 | 125 | | |
| |||
187 | 153 | | |
188 | 154 | | |
189 | 155 | | |
| 156 | + | |
190 | 157 | | |
191 | 158 | | |
192 | 159 | | |
| |||
231 | 198 | | |
232 | 199 | | |
233 | 200 | | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
234 | 213 | | |
235 | 214 | | |
236 | 215 | | |
237 | 216 | | |
238 | 217 | | |
239 | 218 | | |
240 | 219 | | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
| 220 | + | |
252 | 221 | | |
253 | 222 | | |
254 | 223 | | |
| |||
319 | 288 | | |
320 | 289 | | |
321 | 290 | | |
| 291 | + | |
322 | 292 | | |
323 | 293 | | |
324 | 294 | | |
325 | | - | |
326 | | - | |
327 | 295 | | |
328 | 296 | | |
329 | 297 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
Whitespace-only changes.
0 commit comments