radon
radon copied to clipboard
[feature] Add support for pre-commit
@Freed-Wu What would this support entail? From a quick read it would seem all configuration is created in each repository where pre-commit is installed.
As Freed-Wui didn't react. It's actually only a yaml config on how to use radon in a project. E.g: black: https://github.com/psf/black/blob/main/.pre-commit-hooks.yaml isort: https://github.com/PyCQA/isort/blob/main/.pre-commit-hooks.yaml
After that I (and others) could implement radon in our pre-commit hooks and let it fail on one of those metrics.
Edit: this would also mean, that we get some kind of exit code != 0, when metrics N (e.g. mccabe) is above a given threshold.
Hey, sorry for late.
Just add a .pre-commit-config.yaml
in the root directory of the repository is OK. Like https://github.com/PyCQA/doc8.
@tzmara @Freed-Wu In that case, since the exit code is important, xenon is the program to use. Radon is meant for human use, Xenon is for programmatic use. It already has a pre-commit hook. You can configure it to fail when specific thresholds are surpassed.
Here is a snippet to be put in .pre-commit-config.yaml to use xenon:
# monitor code’s complexity
- repo: https://github.com/rubik/xenon
rev: v0.9.0
hooks:
- id: xenon
args: [ --max-absolute B, --max-modules A, --max-average A ]
Maybe someone will find it useful.