File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ private bool WrongCredentialUsage(ParameterAst parameter)
115115 var credentialAttribute = parameter . Attributes . FirstOrDefault ( paramAttribute => paramAttribute . TypeName . GetReflectionType ( ) == typeof ( CredentialAttribute ) ) ;
116116
117117 // check that both exists and pscredentialtype comes before credential attribute
118- if ( psCredentialType != null && credentialAttribute != null && psCredentialType . Extent . EndOffset < credentialAttribute . Extent . StartOffset )
118+ if ( psCredentialType != null && credentialAttribute != null && psCredentialType . Extent . EndOffset <= credentialAttribute . Extent . StartOffset )
119119 {
120120 return false ;
121121 }
Original file line number Diff line number Diff line change @@ -14,6 +14,21 @@ Describe "PSCredentialType" {
1414 It " has the correct description message" {
1515 $violations [0 ].Message | Should Be $violationMessage
1616 }
17+
18+ It " detects attributes on the same line without space" {
19+ $scriptDef = @'
20+ function Get-Credential
21+ {
22+ param(
23+ [PSCredential][System.Management.Automation.Credential()]
24+ $Credential
25+ )
26+ }
27+ '@
28+ $violations = Invoke-ScriptAnalyzer - ScriptDefinition $scriptDef - IncludeRule $violationName
29+ $violations.Count | Should Be 0
30+ }
31+
1732 }
1833
1934 $expectedViolationCount = 0
You can’t perform that action at this time.
0 commit comments