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

Allow enable/disable all via config file #153

Closed
anderseknert opened this issue Jun 8, 2023 · 3 comments
Closed

Allow enable/disable all via config file #153

anderseknert opened this issue Jun 8, 2023 · 3 comments
Assignees

Comments

@anderseknert
Copy link
Member

Since some users may want to only run a few rules in their repo, having to manually disable all the rules they don't care for is a bit of a chore. It'd be good if we allowed enabling/disabling all, or per category from the config as well.

@anderseknert anderseknert added the good first issue Good for newcomers label Sep 26, 2023
@anderseknert
Copy link
Member Author

anderseknert commented Feb 7, 2024

Expanding on the scope a bit here as this was requested today, or at least something that is close enough. It'd be good if there was a way to freeze configuration of rules at any given point, so that updates wouldn't necessarily mean new rules automatically enabled. Some prefer to have them enabled manually, and that's obviously fine. I imagine this would look like:

  1. Add a command to print the de-facto configuration used, i.e. the built-in default configuration merged with the user's custom config file. This configuration would be the one we freeze from updates.
  2. Add a mode to Regal (settable via cia CLI args or config file) that'll have rules not mentioned in config ignored.
  3. Log any rules ignored above so that it's easy for a user to see which rules they are missing from having frozen their rules config.

Definitely open to alternative approaches if anyone has suggestions!

@anderseknert anderseknert self-assigned this Feb 15, 2024
@anderseknert
Copy link
Member Author

I've been thinking some more about this, and I think a better design would be to mirror the regal lint flags for disabling/enabling all rules, or all per category, and allow more specific overrides, but via configuration rather than CLI args. I imagine it might look something like this:

rules:
  '*':
    level: ignore
  bugs:
    '*':
      level: error
    constant-condition:
      level: ignore
  testing:
    print-or-trace-call:
      level: error

Disabling (i.e. setting level to ignore for) all rules at the top level, and then allow more specific overrides to enable (setting level to warning or error for) categories or rules would provide a way to "freeze" configuration for those who don't want new Regal versions to automatically add new rules, and it would also be a pretty convenient way to easily enable/disable all, categories and individual rules.

I'm not too fond of using '*' to mean "all" as the required quoting makes it rather ugly... but I'm not sure what would be a better option. We could call it "all" or "default", but it could easily be mistaken for a category/rule name. '*' while ugly at least clearly stands out from regular names. So might be that I go with that, but if anyone has better ideas, I'm listening 🙂

@anderseknert anderseknert removed the good first issue Good for newcomers label Feb 15, 2024
charlieegan3 added a commit that referenced this issue Mar 6, 2024
This PR implements an approach to rule defaulting described in:
#153 (comment)

Signed-off-by: Charlie Egan <charlie@styra.com>
charlieegan3 added a commit that referenced this issue Mar 6, 2024
This PR implements an approach to rule defaulting described in:
#153 (comment)

Signed-off-by: Charlie Egan <charlie@styra.com>
charlieegan3 added a commit that referenced this issue Mar 11, 2024
This PR implements an approach to rule defaulting described in:
#153 (comment)

Signed-off-by: Charlie Egan <charlie@styra.com>
charlieegan3 added a commit that referenced this issue Mar 11, 2024
* config: Support the defaulting of rules in config

This PR implements an approach to rule defaulting described in:
#153 (comment)

Signed-off-by: Charlie Egan <charlie@styra.com>

* Address linter and refactor

Signed-off-by: Charlie Egan <charlie@styra.com>

* Add e2e test for config defaulting and flag use

Signed-off-by: Charlie Egan <charlie@styra.com>

* Add new notes for defaulting in README

Signed-off-by: Charlie Egan <charlie@styra.com>

---------

Signed-off-by: Charlie Egan <charlie@styra.com>
@anderseknert
Copy link
Member Author

Fixed in #587

srenatus pushed a commit to srenatus/regal that referenced this issue Oct 1, 2024
* config: Support the defaulting of rules in config

This PR implements an approach to rule defaulting described in:
StyraInc#153 (comment)

Signed-off-by: Charlie Egan <charlie@styra.com>

* Address linter and refactor

Signed-off-by: Charlie Egan <charlie@styra.com>

* Add e2e test for config defaulting and flag use

Signed-off-by: Charlie Egan <charlie@styra.com>

* Add new notes for defaulting in README

Signed-off-by: Charlie Egan <charlie@styra.com>

---------

Signed-off-by: Charlie Egan <charlie@styra.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

2 participants