A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/PowerShell/PSScriptAnalyzer/issues/2054 below:

`Invoke-ScriptAnalyzer -EnableExit` sets exit code based on the last evaluated file with piped input · Issue #2054 · PowerShell/PSScriptAnalyzer · GitHub

Before submitting a bug report:

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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4