Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Enable suppression of custom rules when used together with -IncludeDefaultRules#1245

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@bergmeister
Copy link
Collaborator

@bergmeisterbergmeister commentedMay 30, 2019
edited
Loading

PR Summary

Fixes#1237
cc@Jaykul
In PSSA 1.17.1 and 1.18.1 I went through 3 test cases of using the following expressions as a custom rule name returned in theDiagnosticRecord of a custom rule:

  • $MyInvocation.MyCommand.Name (the name of the function name that returns theDiagnosticRecord)
  • '$MyInvocation.InvocationName (same as above but fully qualified, i.e. module name pre-pended to it
  • A custom string

All those scenarios are possible in both versions but when the-IncludeDefaultRules switch was used, then in PSSA 1.17.1 the 2nd test case and in PSSA 1.18.0 the 1st and 3rd test case were not working because PSSA throws a red-herring error. This PR makes PSSA not throw an error any more and therefore enabling all 3 scenarios.
The check that used to throw the error tried to check the rule name in the suppression against the available rule names. Unfortunately the conditional logic itself is a bit broken (this is why the errors only surfaced when the-IncludeDefaultRules was used due to properties likeScriptAnalyzer.Instance.ScriptRules not being null any more). The problem with the check is that only at runtime will we know the returnedRuleName of theDiagnosticRecord. People are encouraged to use expressions that mirror the function name that returns theDiagnosticRecord so that there is a match with whatGet-ScriptAnalyzer returns but the reality is that people can return what they want and actively want to do so, seehere. Therefore the check is removed as we cannot determine at this point in time if there is a match or not.
Comparing the functionality with C#: the compiler similarly cannot throw an error either when a suppression attribute does not match an existing code style rule violation, therefore we are removing a feature that was never meant to be complete.

PR Checklist

&&(ScriptAnalyzer.Instance.ExternalRules!=null
&&ScriptAnalyzer.Instance.ExternalRules.Count(item=>String.Equals(item.GetFullName(),_ruleName,StringComparison.OrdinalIgnoreCase))==0)
&&(ScriptAnalyzer.Instance.DSCResourceRules!=null
&&ScriptAnalyzer.Instance.DSCResourceRules.Count(item=>String.Equals(item.GetName(),_ruleName,StringComparison.OrdinalIgnoreCase))==0))
Copy link
CollaboratorAuthor

@bergmeisterbergmeisterMay 30, 2019
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

As one can see in the combination of all those statements is that we do not know whether the rule name to be suppressed is of type custom rule (where the rule name cannot be determined at design time) or not. Therefore it is not possible to make a statement whether the given rule name will be in one of the returned DiagnosticRecords, hence why the whole check is being removed.

@bergmeisterbergmeister marked this pull request as ready for reviewMay 30, 2019 07:43
@bergmeisterbergmeister added this to the1.18.1 milestoneMay 30, 2019
Copy link
Contributor

@JamesWTruherJamesWTruher left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

this looks good to me, did@Jaykul have an opportunity to comment on the tests to determine whether they captured his issue?

@bergmeister
Copy link
CollaboratorAuthor

I just sent@Jaykul and@ChrisLGardner a message on slack with a local build of1.18.1 from this branch

@bergmeisterbergmeister merged commitf99e1f4 intoPowerShell:developmentJun 11, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

2 more reviewers

@rjmholtrjmholtrjmholt approved these changes

@JamesWTruherJamesWTruherJamesWTruher approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

1.18.1

Development

Successfully merging this pull request may close these issues.

Custom Rule Consistency

3 participants

@bergmeister@rjmholt@JamesWTruher

[8]ページ先頭

©2009-2025 Movatter.jp