-
Notifications
You must be signed in to change notification settings - Fork 230
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
Add more useful PSSA rules that should be enabled by default #669
Add more useful PSSA rules that should be enabled by default #669
Conversation
…e majority of people cannot or do not know how to customize them (yet)
That test failure happens intermittently. RE the PR, I'm a bit concerned that folks will see quite a few more warnings in their script after updating PSES. OTOH I'm sympathetic to having a good default experience. I was thinking that at one time we enabled more rules by default but in looking through the commit history I'm not seeing that. Regardless, I just want to point out that this PR will have a noticeable impact on users. BTW I thought that using |
@bergmeister I was watching your PSConf EU talk yesterday and was thinking about exactly this |
Yes, the lack of default rules annoyed me at my talk because after the first 2 rules that I had to enable at my talk I could not be bothered to enable |
In general I'm with you. But be careful about this:
I've been through this with other languages/linters in the past. With our .NET development, the initial crush of warnings from FxCop was so bad most folks wanted it turned off. Fortunately, we prevailed by the efforts of a few folks who went in and did a fair amount configuration i.e. turning off rules we did not care about. There's a phenomenon known as "broken window" theory that states (when applied to sw) roughly that if you have too many warnings for too long, it will be hard to see new warnings and people will stop caring about fixing warnings. IOW we don't want folks to go and set |
FYI we had a discussion related to this several years ago on the PSSA project. See PowerShell/PSScriptAnalyzer#214 |
Yeah, I know what you mean @rkeithhill but FXCop has really a lot of nonsense rules when it is not configured and moans even about the style of a new default class file as produced by VS... |
|
…idDefaultValueForMandatoryParameter should be part of it. Therefore removing the others. But also adding the new PSAvoidTrailingWhitespace and PossibleIncorrectUsageOfRedirectionOperator rule
OK, as per feedback, we all agree that |
Is there a simple way to find out what each rule does? Is it worth documenting in the comments what the default rules do and a rationale for their inclusion by default? |
@bergmeister Good idea. Do the rules record such a hyperlink within themselves at runtime? |
@rjmholt Unfortunately no, there is PowerShell/PSScriptAnalyzer#816 and PowerShell/PSScriptAnalyzer#730 for that, at the moment, PSSA has only a |
The new ruleset looks good to me. BTW why isn't |
@rkeithhill Thanks for spotting the typo, I fixed it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…orServices into DefaultPSSARules
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, love the addition of PSPossibleIncorrectUsageOfRedirectionOperator :)
Thanks @bergmeister!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM :) merging this 👍
Great, and PSSA just re-released as 1.17.1 |
Since the majority of people do not customize the PSSA settings inside VSCode and just use the vs code extension how it comes out of the box, therefore enabling more useful PSSA rules by default, especially
PSPossibleIncorrectComparisonWithNull
(this was what drove me to change the defaults because I really expected this to be on by default when I was doing a demo)The parallel nature of PSSA (that executes all rules in parallel) means that the time to analyse a script will be always bound by the slowest rule.