-
Notifications
You must be signed in to change notification settings - Fork 394
New rule - ReviewUnusedParameter #1382
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
Changes from 1 commit
929ae14
0b5cba3
d6b38f0
aaa4f41
f360fdc
cdbce04
938a283
79c24c7
67b4846
34379ab
e8d56c1
9f61f2e
00d882d
8c06a41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,13 @@ Describe "ReviewUnusedParameter" { | |
} | ||
|
||
It "has no violations when parameter is called in child scope" -skip { | ||
$ScriptDefinition = 'function Param { param ($Param1) function Child { $Param1 } }' | ||
$ScriptDefinition = 'function foo { param ($Param1) function Child { $Param1 } }' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would think of this as a violation. Since PowerShell has dynamic, rather than lexical, scope, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rather avoid violations that are going to be false positives in most cases in order to avoid similar problems to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think fair enough we want to not emit when at the boundary of our heuristic. Ideally we'd change this to an actual false case, but it's not that important. |
||
$Violations = Invoke-ScriptAnalyzer -ScriptDefinition $ScriptDefinition -IncludeRule $RuleName | ||
$Violations.Count | Should -Be 0 | ||
} | ||
|
||
It "has no violations when case of parameter and variable usage do not match" -skip { | ||
$ScriptDefinition = 'function foo { param ($Param1, $param2) $param1; $Param2}' | ||
$Violations = Invoke-ScriptAnalyzer -ScriptDefinition $ScriptDefinition -IncludeRule $RuleName | ||
$Violations.Count | Should -Be 0 | ||
} | ||
|
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.
@rjmholt Your recently added
complex.psm1
test actually caught an edge case that happened when I first addedStringComparer.OrdinalIgnoreCase
only on.ToDictionary
, which caused items of different cases (due to groupby originally being case sensitive) to to be added to the case insensitive dictionary, which then gave the error that the same item had already been added. Therefore I had to add it to GroupBy as well. Chapeau 👏Uh oh!
There was an error while loading. Please reload this page.
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.
Makes me think that PowerShell and other PowerShell tools should have a few real-world test cases too