Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Add support for pre-commit #225

Closed
Freed-Wu opened this issue Sep 22, 2021 · 5 comments
Closed

[feature] Add support for pre-commit #225

Freed-Wu opened this issue Sep 22, 2021 · 5 comments

Comments

@Freed-Wu
Copy link

https://pre-commit.com/

@rubik
Copy link
Owner

rubik commented Feb 23, 2022

@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.

@tzmara
Copy link

tzmara commented Jun 8, 2022

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.

@Freed-Wu
Copy link
Author

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.

@rubik
Copy link
Owner

rubik commented Sep 3, 2022

@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.

@rubik rubik closed this as completed Sep 3, 2022
@izikeros
Copy link

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.

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

No branches or pull requests

4 participants