You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm getting a rule violation when we force Write-Verbose to have output like this:
Write-Verbose-Verbose "My Message"
Steps to reproduce
Invoke-ScriptAnalyzer-ScriptDefinition 'Write-Verbose -Verbose "Getting file list from $pwd"Write-Warning -Verbose "Getting file list from $pwd"Write-Error -Verbose "Getting file list from $pwd"Write-Error -ErrorAction SilentlyContinue "Getting file list from $pwd"'-IncludeRule PSUseCmdletCorrectly
Expected behavior
There are no violations.
Actual behavior
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSUseCmdletCorrectly Warning 2 Cmdlet 'Write-Verbose' may be used incorrectly. Please
check that all mandatory parameters are supplied.
PSUseCmdletCorrectly Warning 3 Cmdlet 'Write-Warning' may be used incorrectly. Please
check that all mandatory parameters are supplied.
I think it's significant that it has no problem with either of the Write-Error lines, but I have not looked at the code to understand what is happening ...
Thanks @Jaykul looks like PSUseCmdletCorrectly isn't very good at positional parameters, especially when a switch is also used...in this case I would expect to get only a warning of PSAvoidPositionalParameters (if that rule is turned on)
I remember seeing this behaviour the first time around 2 years ago as I think previous PSSA versions did not flag that, but I wasn't too concerned as it was easy resolve by having the switch at the end. I believe this regression was introduced in #963
I'm getting a rule violation when we force Write-Verbose to have output like this:
Steps to reproduce
Expected behavior
There are no violations.
Actual behavior
I think it's significant that it has no problem with either of the Write-Error lines, but I have not looked at the code to understand what is happening ...
Environment data
The text was updated successfully, but these errors were encountered: