Skip to content

chore(project): adopt the recommended ruff thresholds and enforce them in CI#74

Merged
devill merged 1 commit into
habit-hooks:mainfrom
LiinaSuoniemi:python-adopt-recommended-thresholds
Jul 6, 2026
Merged

chore(project): adopt the recommended ruff thresholds and enforce them in CI#74
devill merged 1 commit into
habit-hooks:mainfrom
LiinaSuoniemi:python-adopt-recommended-thresholds

Conversation

@LiinaSuoniemi

@LiinaSuoniemi LiinaSuoniemi commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What

habit-hooks recommends max-complexity = 10, max-args = 3, max-statements = 12 (the python plugin's ruff.toml), but the project did not apply them to its own code. This makes the project follow its own recommendation and enforces it in CI.

Changes

  • pyproject.toml: add the three thresholds under [tool.ruff.lint.*], plus extend-select = ["C901", "PLR0913", "PLR0915"]. The extend-select is required. Without it the thresholds are inert, because those checks are off by ruff's defaults.
  • ci.yml: add a uv run ruff check src step so the values are actually enforced on pushes to main and on pull requests.
  • mapper.py: adopting the thresholds flagged one real violation in the project's own code. render_markdown had four arguments. It only used plugins + resolver to build a jinja Environment, so it now takes the Environment (three args). Behaviour unchanged, mapper tests green.

Notes

  1. The CI lint is scoped to src on purpose. A repo-wide ruff check . currently fails, because ruff tries to parse the python plugin's sensor ruff.toml (a sensor definition, command = """...""") as a ruff config. Widening the lint to the plugins would need that handled first (rename, or exclude it from config discovery). Happy to follow up separately.
  2. This only touches the project's own config and one small internal refactor in the mapper (the flagged function and its single call site). It does not change the plugin's recommendation mechanism. That is the separate init question.
  3. The ruff check src CI step is a suggestion, to keep the values from sitting decorative. If you would rather carry the config without enforcing it in CI yet, say the word and I will drop that step.

Verified

  • uv run ruff check src passes.
  • The config is active, not decorative: a 4-argument probe is caught (PLR0913, 4 > 3), then removed.
  • uv run pytest plugins/python tests green (37 passed, 1 skipped); mapper tests green (15 passed).

…m in CI

habit-hooks recommends max-complexity=10, max-args=3, max-statements=12 (the
python plugin's ruff.toml) but did not apply them to its own code. Add them to
the project's own ruff config and lint src in CI so the project follows its own
recommendation.

extend-select enables C901/PLR0913/PLR0915; without it the thresholds are inert.
The CI step is scoped to src because a repo-wide `ruff check .` currently fails:
ruff tries to parse the python plugin's sensor ruff.toml (a sensor definition,
not ruff config) as configuration.

Adopting the thresholds surfaced one violation in the project's own code:
render_markdown took four arguments. It only needed plugins+resolver to build a
jinja Environment, so pass the Environment instead (three args, behaviour
unchanged). The mapper's own tests still pass.
@devill
devill merged commit f87cdd8 into habit-hooks:main Jul 6, 2026
2 checks passed
@devill

devill commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the PR! Merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants