fix: resolve ZeroDivisionError false positives via AST-based detection#360
fix: resolve ZeroDivisionError false positives via AST-based detection#360Prakhar54-byte wants to merge 15 commits into
Conversation
- Removed broad and noisy ZeroDivisionError regex from rule-based engine - Migrated ZeroDivisionError detection to ast_analyzer.py for higher precision - Added support for detecting literal 0 passed to function divisor parameters - Enhanced AST analyzer issues with line-numbered code context - Added regression tests for both direct and parameter-based zero division
|
@Prakhar54-byte update your branch with the latest main changes |
|
Hi @imDarshanGK, I've updated the branch with the latest main changes and all checks are passing cleanly. Since the |
|
@Prakhar54-byte CI failing |
…o fix/zero-division-ast-338
…to expect literal zero divisor
|
@imDarshanGK ci failing resolved pls check |
|
Hi @imDarshanGK, I've updated the branch with the latest main changes and all checks are passing cleanly. Since the |
|
@Prakhar54-byte update the branch with the latest main changes |
Description
This PR resolves the false positive ZeroDivisionError reports by replacing the broad regex-based detection with a high-precision
AST-based analyzer. This significantly reduces noise in the analysis results and adds the capability to track zero-division
risks through function parameters.
Key Changes:
2.
divisors.
Related Issue
Fixes #338
Type of change
Checklist
Test evidence
10 tests/test_ast_analyzer.py::test_unused_argument PASSED [ 23%]
11 tests/test_ast_analyzer.py::test_clean_code_no_false_positives PASSED [ 30%]
12 tests/test_ast_analyzer.py::test_correct_line_number_unreachable PASSED [ 38%]
13 tests/test_ast_analyzer.py::test_self_not_flagged_as_unused PASSED [ 46%]
14 tests/test_ast_analyzer.py::test_underscore_param_not_flagged PASSED [ 53%]
15 tests/test_ast_analyzer.py::test_used_alias_not_flagged PASSED [ 61%]
16 tests/test_ast_analyzer.py::test_too_many_returns_exact_boundary PASSED [ 69%]
17 tests/test_ast_analyzer.py::test_unreachable_only_flags_after_not_before PASSED [ 76%]
18 tests/test_ast_analyzer.py::test_nested_function_returns_not_counted_in_outer PASSED [ 84%]
19 tests/test_ast_analyzer.py::test_deep_nesting_exact_boundary PASSED [ 92%]
20 tests/test_ast_analyzer.py::test_zero_division PASSED [100%]
21
22 ============================== 13 passed in 0.03s ==============================