Whole file
Melevir/cognitive_complexity
The author described this change as “Fix counting for binary logical operators”. It counts as a record because the checks below fail on the code as it stood at aa428ca73 and pass on 3796e582e, with nothing else changed between the two runs.
ProjectMelevir/cognitive_complexity
Fix saved2020-07-05
Sharing licenceMIT · LICENSE
Change size+1 −1
What the code was meant to do, written into the code itself as a save note
Fix counting for binary logical operators
The change
| 85 | 85 | return increment_by, 0, True | |
| 86 | 86 | elif isinstance(node, ast.BoolOp): | |
| 87 | 87 | inner_boolops_amount = len([n for n in ast.walk(node) if isinstance(n, ast.BoolOp)]) | |
| 88 | - | base_complexity = inner_boolops_amount * max(increment_by, 1) | |
| 88 | + | base_complexity = inner_boolops_amount | |
| 89 | 89 | return increment_by, base_complexity, False | |
| 90 | 90 | elif isinstance(node, (ast.Break, ast.Continue)): | |
| 91 | 91 | return increment_by, max(1, increment_by), True |
The check that tells the two apart
fail→pass·tests/test_cognitive_complexity.py::test_nested_functions
fail→pass·tests/test_cognitive_complexity.py::test_real_function
Check file tests/test_cognitive_complexity.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before itaa428ca731bc0461cc9f95956ff4816154495729
Broken version dated2020-07-05
Modulecognitive_complexity.utils.ast
Units changedprocess_node_itself
Fingerprinte9eff94957120177
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.