Skip to content

UsePSCredentialType rule incorrect behaviour #659

@kapilmb

Description

@kapilmb
  • Violation extent includes the entire function
  • Incorrectly flags $Credential type on PSv5 and above
PS> Invoke-ScriptAnalyzer -ScriptDefinition 'function foo ([PSCredential]$credential) {write-host foo}' -IncludeRule PSUsePSCredentialT
ype | fl *


Line                 : 1
Column               : 1
Message              : The Credential parameter in 'foo' must be of type PSCredential. For PowerShell 4.0 and earlier, please define
                       a credential transformation attribute, e.g. [System.Management.Automation.Credential()], after the
                       PSCredential type attribute.
Extent               : function foo ([PSCredential]$credential) {write-host foo}
RuleName             : PSUsePSCredentialType
Severity             : Warning
ScriptName           :
ScriptPath           :
RuleSuppressionID    :
SuggestedCorrections :

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions