-
Notifications
You must be signed in to change notification settings - Fork 402
Closed
Labels
Description
Steps to reproduce
This was reported in the UK PowerShell Slack user group get-psuguk by @pauby
This bug was initially reported for version 1.16.1 but even with the recent PR 909 that was merged today, this strange behaviour happens.
cd $PSScriptAnalyzerCheckout
Invoke-ScriptAnalyzer -ScriptDefinition gci -Settings (join-path ((get-location).path) 'Engine\Settings\ScriptingStyle.psd1') -VerboseExpected behavior
No warning and only the 2 rules in the settings file are being used.
VERBOSE: Using settings file at C:\Users\cberg\git\PSScriptAnalyzer\Engine\Settings\ScriptingStyle.psd1.
VERBOSE: Analyzing Script Definition.
VERBOSE: Running PSAvoidUsingWriteHost rule.
VERBOSE: Running PSProvideCommentHelp rule.
Actual behavior
The settings file is ignored and all rules are being applied
VERBOSE: Cannot find a settings file.
VERBOSE: Analyzing Script Definition.
VERBOSE: Running PSAvoidAssignmentToAutomaticVariable rule.
VERBOSE: Running PSAvoidUsingCmdletAliases rule.
VERBOSE: Running PSAvoidDefaultValueSwitchParameter rule.
VERBOSE: Running PSAvoidUsingEmptyCatchBlock rule.
VERBOSE: Running PSAvoidGlobalAliases rule.
VERBOSE: Running PSAvoidGlobalFunctions rule.
VERBOSE: Running PSAvoidGlobalVars rule.
VERBOSE: Running PSAvoidInvokingEmptyMembers rule.
VERBOSE: Running PSAvoidNullOrEmptyHelpMessageAttribute rule.
VERBOSE: Running PSAvoidDefaultValueForMandatoryParameter rule.
VERBOSE: Running PSReservedCmdletChar rule.
VERBOSE: Running PSAvoidUsingPositionalParameters rule.
VERBOSE: Running PSAvoidShouldContinueWithoutForce rule.
VERBOSE: Running PSAvoidTrailingWhitespace rule.
VERBOSE: Running PSAvoidUsingUserNameAndPassWordParams rule.
VERBOSE: Running PSAvoidUsingComputerNameHardcoded rule.
VERBOSE: Running PSAvoidUsingConvertToSecureStringWithPlainText rule.
VERBOSE: Running PSAvoidUsingDeprecatedManifestFields rule.
VERBOSE: Running PSAvoidUsingInvokeExpression rule.
VERBOSE: Running PSAvoidUsingPlainTextForPassword rule.
VERBOSE: Running PSAvoidUsingWMICmdlet rule.
VERBOSE: Running PSAvoidUsingWriteHost rule.
VERBOSE: Running PSMisleadingBacktick rule.
VERBOSE: Running PSMissingModuleManifestField rule.
VERBOSE: Running PSPossibleIncorrectComparisonWithNull rule.
VERBOSE: Running PSPossibleIncorrectUsageOfAssignmentOperator rule.
VERBOSE: Running PSReservedParams rule.
VERBOSE: Running PSProvideCommentHelp rule.
VERBOSE: Running PSUseBOMForUnicodeEncodedFile rule.
VERBOSE: Running PSUseCmdletCorrectly rule.
VERBOSE: Running PSUseCompatibleCmdlets rule.
VERBOSE: Running PSUseDeclaredVarsMoreThanAssignments rule.
VERBOSE: Running PSUseLiteralInitializerForHashtable rule.
VERBOSE: Running PSUseOutputTypeCorrectly rule.
VERBOSE: Running PSUseApprovedVerbs rule.
VERBOSE: Running PSUsePSCredentialType rule.
VERBOSE: Running PSUseShouldProcessForStateChangingFunctions rule.
VERBOSE: Running PSUseSingularNouns rule.
VERBOSE: Running PSUseSupportsShouldProcess rule.
VERBOSE: Running PSUseToExportFieldsInManifest rule.
VERBOSE: Running PSUseUTF8EncodingForHelpFile rule.
VERBOSE: Running PSShouldProcess rule.
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSAvoidUsingCmdletAliases Warning 1 'gci' 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.
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.16299.248
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.16299.248
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Name Value
---- -----
PSVersion 6.0.1
PSEdition Core
GitCommitId v6.0.1
OS Microsoft Windows 10.0.16299
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.16.1 # Happens also using latest code at hash d4ba9470fa5677ea95266b8334ebaf8681650b6cRemarks
What is weird is the fact that this does not happen if the object being passed to the cmdlet is specified as a string "$((join-path ((get-location).path) 'Engine\Settings\ScriptingStyle.psd1'))". This is weird because the object is already a string and when assigning the object to a variable and doing an equal comparison to its literal string, then it reports true...