FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Enable suppression of PSAvoidAssignmentToAutomaticVariable for specific variable or parameter by fflaten · Pull Request #1896 · PowerShell/PSScriptAnalyzer · GitHub

Enable suppression of PSAvoidAssignmentToAutomaticVariable for specific variable or parameter - #1896

Merged
Christoph Bergmeister (bergmeister) merged 2 commits into
PowerShell:masterfrom
fflaten:autovariable-ruleid
Sep 17, 2023
Merged

Enable suppression of PSAvoidAssignmentToAutomaticVariable for specific variable or parameter#1896
Christoph Bergmeister (bergmeister) merged 2 commits into
PowerShell:masterfrom
fflaten:autovariable-ruleid

Conversation

Frode Flaten (fflaten) commented Feb 27, 2023
edited
Loading

Copy link
Copy Markdown
Contributor

PR Summary

Enables suppression for specific variable/parameter with rule PSAvoidAssignmentToAutomaticVariable.
Fix #1589

PR Checklist

Enables suppression for specific variable/parameter.
Fix PowerShell#1589

Christoph Bergmeister (bergmeister) left a comment
edited
Loading

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Awesome, thanks for improving it, change looks good to me, can you please add one test case for it though?
If possible a test case for each line that was changed, that can return a diagnostic record, but I can understand if that is too much for you, therefore consider this optional.

Copy link
Copy Markdown
Contributor Author

Intentionally skipped it because suppression was only tested in a general test and not per rule.

Can try to add some later today if you want.

$testCases_ReadOnlyAutomaticVariables = $testCases_AutomaticVariables | Where-Object { $_.IsReadonly }

It "Variable <VariableName> produces warning of Severity <ExpectedSeverity>" -TestCases $testCases_AutomaticVariables {
param ($VariableName, $ExpectedSeverity)

Frode Flaten (fflaten) Feb 28, 2023
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Tip: Param-blocks are no longer needed in Pester v5. Some keep them to make the testcase-contract visible so didn't remove them :)


Describe "AvoidAssignmentToAutomaticVariables" {
Context "ReadOnly Variables" {
BeforeDiscovery {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Added per best practice in Pester v5. Only cosmetic and more explicit in this case.

Frode Flaten (fflaten) commented Mar 16, 2023
edited
Loading

Copy link
Copy Markdown
Contributor Author

In case it didn't show up - ready for review again 🙂

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This is great - thank you.
Christoph Bergmeister (@bergmeister)

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot Suppress Messages About a Specific Automatic Variable

3 participants


Back | FazBrowse Home | New Git URL