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)
115
115
var credentialAttribute = parameter . Attributes . FirstOrDefault ( paramAttribute => paramAttribute . TypeName . GetReflectionType ( ) == typeof ( CredentialAttribute ) ) ;
116
116
117
117
// 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 )
119
119
{
120
120
return false ;
121
121
}
Original file line number Diff line number Diff line change @@ -14,6 +14,21 @@ Describe "PSCredentialType" {
14
14
It " has the correct description message" {
15
15
$violations [0 ].Message | Should Be $violationMessage
16
16
}
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
+
17
32
}
18
33
19
34
$expectedViolationCount = 0
You can’t perform that action at this time.
0 commit comments