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

Ability to have user-defined rules disabled by default #396

Closed
carlescufi opened this issue Dec 20, 2022 · 2 comments
Closed

Ability to have user-defined rules disabled by default #396

carlescufi opened this issue Dec 20, 2022 · 2 comments

Comments

@carlescufi
Copy link
Contributor

This is sort of an alternative to #395, but both could be implemented. The idea is that one could set some sort of disabled = True in the user-defined class implementation so that, although present in the extra-path, it would not run by default unless explicitly enabled in the command-line or .gitlint.

@jorisroovers
Copy link
Owner

I'm not necessarily against this, but it seems like a niche use-case.

Also, this behavior can already be implemented today: Add a boolean disabled option to you user-defined rule that defaults to False. You can then check at the start of your validate method whether the rule is disabled and return early.
Technically, gitlint still runs these rules, but they will then be no-op.

If you really want to not have gitlint run these rules in the first place, you can also write a user-defined ConfigurationRule that filters out all config.rules that have an attribute disabled=False

@carlescufi
Copy link
Contributor Author

Also, this behavior can already be implemented today: Add a boolean disabled option to you user-defined rule that defaults to False. You can then check at the start of your validate method whether the rule is disabled and return early.
Technically, gitlint still runs these rules, but they will then be no-op.

This should be enough to cover my use case, thanks for the suggestion.

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

2 participants