@@ -48,9 +48,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
48
48
{
49
49
continue ;
50
50
}
51
-
52
- string cmdletName = Microsoft . Windows . PowerShell . ScriptAnalyzer . Helper . Instance . GetCmdletNameFromAlias ( aliasName ) ;
53
-
51
+ string cmdletName = Helper . Instance . GetCmdletNameFromAlias ( aliasName ) ;
54
52
if ( ! String . IsNullOrEmpty ( cmdletName ) )
55
53
{
56
54
yield return new DiagnosticRecord (
@@ -68,24 +66,26 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
68
66
/// <summary>
69
67
/// Creates a list containing suggested correction
70
68
/// </summary>
71
- /// <param name="cmdAst"></param>
72
- /// <param name="cmdletName"></param>
73
- /// <returns>Returns a list of suggested corrections</returns>
69
+ /// <param name="cmdAst">Command AST of an alias </param>
70
+ /// <param name="cmdletName">Full name of the alias </param>
71
+ /// <returns>Retruns a list of suggested corrections</returns>
74
72
private List < CorrectionExtent > GetCorrectionExtent ( CommandAst cmdAst , string cmdletName )
75
73
{
76
74
var corrections = new List < CorrectionExtent > ( ) ;
77
75
var ext = cmdAst . Extent ;
78
- var alias = cmdAst . GetCommandName ( ) ;
79
- var startColumnNumber = ext . StartColumnNumber + ext . Text . IndexOf ( alias ) ;
80
- var endColumnNumber = startColumnNumber + alias . Length ;
81
- string description = string . Format ( "Replace {0} with {1}" , alias , cmdletName ) ;
76
+ var alias = cmdAst . GetCommandName ( ) ;
77
+ string description = string . Format (
78
+ CultureInfo . CurrentCulture ,
79
+ Strings . AvoidUsingCmdletAliasesCorrectionDescription ,
80
+ alias ,
81
+ cmdletName ) ;
82
82
corrections . Add ( new CorrectionExtent (
83
83
ext . StartLineNumber ,
84
84
ext . EndLineNumber ,
85
- startColumnNumber ,
86
- endColumnNumber ,
85
+ cmdAst . CommandElements [ 0 ] . Extent . StartColumnNumber ,
86
+ cmdAst . CommandElements [ 0 ] . Extent . EndColumnNumber ,
87
87
cmdletName ,
88
- ext . File ,
88
+ ext . File ,
89
89
description ) ) ;
90
90
return corrections ;
91
91
}
0 commit comments