Skip to content
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

Enhance check for assignment by rather checking if assigned variable is used in assignment block #1

Prev Previous commit
Next Next commit
add simple test case for new improvemeent
  • Loading branch information
bergmeister committed Feb 13, 2018
commit 4f7dbe685d3262c325e45a8e9cdd57d33b781b76
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ Describe "PossibleIncorrectUsageOfComparisonOperator" {
$warnings.Count | Should Be 0
}

It "returns no violations when the variable assigned on the LHS is used" {
$warnings = Invoke-ScriptAnalyzer -ScriptDefinition 'if ($a = $b){ $a.DoSomething() }' | Where-Object {$_.RuleName -eq $ruleName}
$warnings.Count | Should Be 0
}

It "returns no violations when there is an evaluation on the RHS" {
$warnings = Invoke-ScriptAnalyzer -ScriptDefinition 'if ($a = Get-ChildItem){}' | Where-Object {$_.RuleName -eq $ruleName}
$warnings.Count | Should Be 0
Expand Down