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
Make sure you are able to repro it on the latest released version
Perform a quick search for existing issues to check if this bug has already been reported
Steps to reproduce
$null= mkdir analyzer
cd .\analyzer\
$PSNativeCommandUseErrorActionPreference=$false'function fn() {ls}'>1.psm1
'function fn() {}'>2.psm1
# exits with code 0, because the last evaluated file (2.psm1) does not have any violations
pwsh -noprofile {gi .\1.psm1, .\2.psm1 |Invoke-ScriptAnalyzer-EnableExit}
$LastExitCode# exits with code 1
pwsh -noprofile {gi .\2.psm1, .\1.psm1 |Invoke-ScriptAnalyzer-EnableExit}
$LastExitCode
Expected behavior
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSAvoidUsingCmdletAliases Warning 1.psm1 1 'ls' is an alias of 'Get-ChildItem'. Alias can introduce
possible problems and make scripts hard to maintain. Please
consider changing alias to its full content.
1
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSAvoidUsingCmdletAliases Warning 1.psm1 1 'ls' is an alias of 'Get-ChildItem'. Alias can introduce
possible problems and make scripts hard to maintain. Please
consider changing alias to its full content.
1
Actual behavior
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSAvoidUsingCmdletAliases Warning 1.psm1 1 'ls' is an alias of 'Get-ChildItem'. Alias can introduce
possible problems and make scripts hard to maintain. Please
consider changing alias to its full content.
0
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSAvoidUsingCmdletAliases Warning 1.psm1 1 'ls' is an alias of 'Get-ChildItem'. Alias can introduce
possible problems and make scripts hard to maintain. Please
consider changing alias to its full content.
1
If an unexpected error was thrown then please report the full error details using e.g. $error[0] | Select-Object *
Environment data
>$PSVersionTable
Name Value
---------
PSVersion 7.6.0-preview.2
PSEdition Core
GitCommitId 7.6.0-preview.2
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0,2.0,3.0,4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0> (Get-Module-ListAvailable PSScriptAnalyzer).Version |ForEach-Object { $_.ToString() }
1.23.0
The text was updated successfully, but these errors were encountered:
Imo, Invoke-ScriptAnalyzer should set exit code based on the total number of violations, not just based on the last file – if there are 2 file paths piped in and each file has 2 violations, the exit should be set to 4. If you agree, I can make a PR.
Before submitting a bug report:
Steps to reproduce
Expected behavior
Actual behavior
If an unexpected error was thrown then please report the full error details using e.g.
$error[0] | Select-Object *
Environment data
The text was updated successfully, but these errors were encountered: