-
Notifications
You must be signed in to change notification settings - Fork 756
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
Implement: Finalize default levels for linting rules #8013
Comments
For I currently have this implemented by having our azure devops task fail if anything is written to stdout, but this has proven problematic before (See #3638) so a native method on the build command would be preferred. |
Nice work @StephenWeatherford I'd really like to see the ability to set the level for all rules in a category easily in one go from either the command line, as suggested above, and also in the bicepconfig.json file; and say the command line wins/takes preference (following parameter value input logic today for deployment). If this is enabled I think warnings as errors can be removed/not implemented as the flexibility will be there if enabled in both command line and bicepconfig.json files. Maybe if there was a keyword lookup for something like "allCategories" as well this provides a single input option to configure individual categories or all in one go. Instead of a conflicting additional option to configure.
Thanks Jack |
As stated before for me rule no-loc-expr-outside-params should be off by default. It just generates a lot of noise. Even when you use for example resourceGroup().location in module name or on variable you get a warning. Also it does not fits well in best practices as usually if the resource is not global it is recommended that your resources are in the same location as the location of the resource group - https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/best-practices#resource-group. The rule is even triggered when you use deployment().location. I really do not get why this rule exists at all. |
My biggest issue with
So, unless there is a sensible pattern here for something like a "global location" those warnings feel like a loop leading to more verbosity for some users. And I'm not sure if I am really against this, it just feels like we are somehow running circles here :) @majastrz nicely summarized it in #6210 Edit: the globals idea was also mentioned here #399 (comment) by @anthony-c-martin |
@StephenWeatherford -- do we need more discussion on this one? Otherwise, can I remove the "discussion" label? |
Removed "discussion" for now.
|
@jtracey93 I've asked about this in the past and seen little interest. It wouldn't be hard to add, if you think it should be configurable, please enter an issue so we can gauge interest. |
Changed: Location rules moved to (theoretical) portability category, will be turned off by default. |
Updated due to community call: Security rules will default to "warning", not "error". |
Fixes #8013 NOTE: breaking change (changes 3 rules that were warning by default to off by default): - explicit-values-for-loc-params - no-hardcoded-location - no-loc-expr-outside-params - [ ] QUESTION: Should the "no unused..." rules be in the category "best practice"? "style"? something else? ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/13847) --------- Co-authored-by: Stephen Weatherford <Stephen.Weatherford.com> Co-authored-by: Bicep Automation <bicep@noreply.github.com>
Tracking subissues:
Proposal - Change default levels for linting rules
Problem statement
While developing linter rules, we have deliberately enabled all new rules by default (almost all of them set to Warning by default). Now that we have a growing list of rules, it's time to set more appropriate defaults. Some should be off by default, other warning, and still others error. (It seems questionable that 'Info' is an appropriate default for any rule.)
Guiding principles
I believe the best way to determine which level each rule should default to is to consider the type/category of the rule. In the future, it might make sense to be able to easily set defaults for all rules in a category, or to allow importing a user-defined set of defaults. For now though, the categories are intended only for guidance and are not proposed to be an official part of anything in the linter or rules. (If official categories should be higher priority, please let us know.)
Warnings vs errors
Principal agreed on in community call is that if a triggered linter rule would definitely cause an actual deployment failure it should default to "error". Otherwise it should default to "warning".
Types of rules
I see the rules as falling into these approximate categories:
Again, for now these categories are just to help determine default level, nothing official.
Default level for each category
Default levels for current rules
errorwarningerrorwarningerrorwarningerrorwarningerrorwarningwarning (not likely to cause a lot of noise)Best practice/correctness (location) - Ensures an explicit value is passed in to modules' location parameters (not left as default)warning (++see note)Best practice (location)warning (++see note)Best practice (location)Note
These two we aleady know are controversial. I suggest they default to "warning" rather than "off" because:1) They can help avoid bugs, for example:a) one resource accidentally placed in a different region, especially with copy/paste, or
, as they generate a lot of noise
b) portability issue if some resources are not supported in the current resource group's location
2) They can easily be turned off in a bicepconfig.json file (or soon in a #disable-in-file pragma)
Documentation
CONSIDER: Document each rule's default level in online docs
CONSIDER: Document each rule's default value in its Intellisense description
Do we need an easy way to adjust default levels for rules?
Do we need the ability to:
In particular, would the following be useful?
The text was updated successfully, but these errors were encountered: