habit-hooks-python 1.4.0rc2__tar.gz → 1.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {habit_hooks_python-1.4.0rc2 → habit_hooks_python-1.5.0}/PKG-INFO +1 -1
- {habit_hooks_python-1.4.0rc2 → habit_hooks_python-1.5.0}/pyproject.toml +1 -1
- {habit_hooks_python-1.4.0rc2 → habit_hooks_python-1.5.0}/src/habit_hooks_python/guides/high-complexity.md +2 -2
- {habit_hooks_python-1.4.0rc2 → habit_hooks_python-1.5.0}/.gitignore +0 -0
- {habit_hooks_python-1.4.0rc2 → habit_hooks_python-1.5.0}/README.md +0 -0
- {habit_hooks_python-1.4.0rc2 → habit_hooks_python-1.5.0}/docs/python-plugin.spec.md +0 -0
- {habit_hooks_python-1.4.0rc2 → habit_hooks_python-1.5.0}/src/habit_hooks_python/__init__.py +0 -0
- {habit_hooks_python-1.4.0rc2 → habit_hooks_python-1.5.0}/src/habit_hooks_python/config.toml +0 -0
- {habit_hooks_python-1.4.0rc2 → habit_hooks_python-1.5.0}/src/habit_hooks_python/guides/swallowed-exception.md +0 -0
- {habit_hooks_python-1.4.0rc2 → habit_hooks_python-1.5.0}/src/habit_hooks_python/ruff.toml +0 -0
- {habit_hooks_python-1.4.0rc2 → habit_hooks_python-1.5.0}/src/habit_hooks_python/sensors/deptry.toml +0 -0
- {habit_hooks_python-1.4.0rc2 → habit_hooks_python-1.5.0}/src/habit_hooks_python/sensors/deptry_sensor.py +0 -0
- {habit_hooks_python-1.4.0rc2 → habit_hooks_python-1.5.0}/src/habit_hooks_python/sensors/ruff.toml +0 -0
- {habit_hooks_python-1.4.0rc2 → habit_hooks_python-1.5.0}/src/habit_hooks_python/sensors/ruff_sensor.py +0 -0
- {habit_hooks_python-1.4.0rc2 → habit_hooks_python-1.5.0}/tests/conftest.py +0 -0
- {habit_hooks_python-1.4.0rc2 → habit_hooks_python-1.5.0}/tests/test_a_crashing_ruff_fails_the_run.py +0 -0
- {habit_hooks_python-1.4.0rc2 → habit_hooks_python-1.5.0}/tests/test_a_project_declaring_no_dependencies_is_clean.py +0 -0
- {habit_hooks_python-1.4.0rc2 → habit_hooks_python-1.5.0}/tests/test_a_sensor_spawns_the_tool_it_was_handed.py +0 -0
- {habit_hooks_python-1.4.0rc2 → habit_hooks_python-1.5.0}/tests/test_the_python_files_leave_installed_packages_alone.py +0 -0
- {habit_hooks_python-1.4.0rc2 → habit_hooks_python-1.5.0}/tests/test_the_ruff_pipeline_maps_codes_to_smells.py +0 -0
- {habit_hooks_python-1.4.0rc2 → habit_hooks_python-1.5.0}/tests/test_the_ruff_sensor_runs_the_real_tool.py +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
High
|
|
1
|
+
High complexity means one function is making too many decisions at once. The smell is not the number, it is that the function has quietly taken on more than one job. The count is the symptom, tangled responsibilities are the cause.
|
|
2
2
|
|
|
3
3
|
Work through it in order:
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ Work through it in order:
|
|
|
6
6
|
2. **Lift the guards out first.** Turn early-exit conditions into guard clauses (`if not user: return None`) so the happy path stays flat and left-aligned. Most of the count is preconditions wrapped around the real work.
|
|
7
7
|
3. **Change the shape, do not just move it.** When every branch is the same kind of decision, reshape it: a long `if/elif` on a value is often a dict dispatch or polymorphism, a nested loop often a comprehension or a generator. When polymorphism is not the right fit and the branches are genuinely separate jobs, extract one named method per branch, each named for the responsibility it handles. The goal is fewer decisions in one place, not the same tangle split into `_part1` / `_part2` behind worse names.
|
|
8
8
|
|
|
9
|
-
Reducing the number without reducing the tangle is not a fix. Do not merge conditions with `and`/`or` just to drop a branch, and do not rewrite `if` statements as ternaries to slip under the check.
|
|
9
|
+
Reducing the number without reducing the tangle is not a fix. Do not merge conditions with `and`/`or` just to drop a branch, and do not rewrite `if` statements as ternaries to slip under the check. The condition is still there for a human to hold in their head.
|
|
10
10
|
|
|
11
11
|
The test is not whether the number dropped. It is whether someone reading the function for the first time can hold it in their head at once. If not, it is still doing too much.
|
|
12
12
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{habit_hooks_python-1.4.0rc2 → habit_hooks_python-1.5.0}/src/habit_hooks_python/sensors/deptry.toml
RENAMED
|
File without changes
|
|
File without changes
|
{habit_hooks_python-1.4.0rc2 → habit_hooks_python-1.5.0}/src/habit_hooks_python/sensors/ruff.toml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{habit_hooks_python-1.4.0rc2 → habit_hooks_python-1.5.0}/tests/test_a_crashing_ruff_fails_the_run.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|