Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Engine/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ public bool PositionalParameterUsed(CommandAst cmdAst, bool moreThanThreePositio
arguments += 1;
}

if (moreThanThreePositional && arguments < 3)
// if we are only checking for 3 or more positional parameters, check that arguments < parameters + 3
if (moreThanThreePositional && (arguments - parameters) < 3)
{
return false;
}
Expand Down
4 changes: 3 additions & 1 deletion Tests/Rules/AvoidPositionalParametersNoViolations.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ Get-Content Test
Get-ChildItem Tests
Write-Output "I don't want to use positional parameters"
Split-Path "RandomPath" -Leaf
Get-Process | ForEach-Object {Write-Host $_.name -foregroundcolor cyan}
Get-Process | ForEach-Object {Write-Host $_.name -foregroundcolor cyan}

$srvc = Get-WmiObject Win32_Service -ComputerName $computername -Filter "name=""$service""" -Credential $credential