@@ -126,25 +126,29 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
126
126
fileName ,
127
127
commandName ,
128
128
suggestedCorrections : GetCorrectionExtent ( cmdAst , cmdletNameIfCommandNameWasAlias ) ) ;
129
+ // do not continue the search, but go to the next command
130
+ continue ;
131
+ }
132
+
133
+ // If we find match of any kind, do not continue with the Get-{commandname} check
134
+ if ( Helper . Instance . GetCommandInfo ( commandName ) != null ) {
135
+ continue ;
129
136
}
130
137
131
- var isNativeCommand = Helper . Instance . GetCommandInfo ( commandName , CommandTypes . Application | CommandTypes . ExternalScript ) != null ;
132
- if ( ! isNativeCommand )
138
+ var commdNameWithGetPrefix = $ "Get-{ commandName } ";
139
+ var cmdletNameIfCommandWasMissingGetPrefix = Helper . Instance . GetCommandInfo ( commdNameWithGetPrefix ) ;
140
+ if ( cmdletNameIfCommandWasMissingGetPrefix != null )
133
141
{
134
- var commdNameWithGetPrefix = $ "Get-{ commandName } ";
135
- var cmdletNameIfCommandWasMissingGetPrefix = Helper . Instance . GetCommandInfo ( $ "Get-{ commandName } ") ;
136
- if ( cmdletNameIfCommandWasMissingGetPrefix != null )
137
- {
138
- yield return new DiagnosticRecord (
139
- string . Format ( CultureInfo . CurrentCulture , Strings . AvoidUsingCmdletAliasesMissingGetPrefixError , commandName , commdNameWithGetPrefix ) ,
140
- GetCommandExtent ( cmdAst ) ,
141
- GetName ( ) ,
142
- DiagnosticSeverity . Warning ,
143
- fileName ,
144
- commandName ,
145
- suggestedCorrections : GetCorrectionExtent ( cmdAst , commdNameWithGetPrefix ) ) ;
146
- }
142
+ yield return new DiagnosticRecord (
143
+ string . Format ( CultureInfo . CurrentCulture , Strings . AvoidUsingCmdletAliasesMissingGetPrefixError , commandName , commdNameWithGetPrefix ) ,
144
+ GetCommandExtent ( cmdAst ) ,
145
+ GetName ( ) ,
146
+ DiagnosticSeverity . Warning ,
147
+ fileName ,
148
+ commandName ,
149
+ suggestedCorrections : GetCorrectionExtent ( cmdAst , commdNameWithGetPrefix ) ) ;
147
150
}
151
+
148
152
}
149
153
}
150
154
@@ -264,4 +268,4 @@ public string GetSourceName()
264
268
return string . Format ( CultureInfo . CurrentCulture , Strings . SourceName ) ;
265
269
}
266
270
}
267
- }
271
+ }
0 commit comments