Skip to content

Commit a5c12c0

Browse files
author
Kapil Borle
committed
Make UseCmdletCorreclty use updated getcommandinfo
1 parent b5620bd commit a5c12c0

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Rules/UseCmdletCorrectly.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
5555
if (cmdAst.GetCommandName() == null) continue;
5656

5757
// Checks mandatory parameters.
58-
if (!IsMandatoryParameterExisted(cmdAst))
58+
if (!MandatoryParameterExists(cmdAst))
5959
{
6060
yield return new DiagnosticRecord(String.Format(CultureInfo.CurrentCulture, Strings.UseCmdletCorrectlyError, cmdAst.GetCommandName()),
6161
cmdAst.Extent, GetName(), DiagnosticSeverity.Warning, fileName);
@@ -68,7 +68,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
6868
/// </summary>
6969
/// <param name="cmdAst"></param>
7070
/// <returns></returns>
71-
private bool IsMandatoryParameterExisted(CommandAst cmdAst)
71+
private bool MandatoryParameterExists(CommandAst cmdAst)
7272
{
7373
CommandInfo cmdInfo = null;
7474
List<ParameterMetadata> mandParams = new List<ParameterMetadata>();
@@ -88,9 +88,7 @@ private bool IsMandatoryParameterExisted(CommandAst cmdAst)
8888

8989
#region Compares parameter list and mandatory parameter list.
9090

91-
cmdInfo = Helper.Instance.GetCommandInfo(Helper.Instance.GetCmdletNameFromAlias(cmdAst.GetCommandName()))
92-
?? Helper.Instance.GetCommandInfo(cmdAst.GetCommandName());
93-
91+
cmdInfo = Helper.Instance.GetCommandInfo(cmdAst.GetCommandName());
9492
if (cmdInfo == null || (cmdInfo.CommandType != System.Management.Automation.CommandTypes.Cmdlet))
9593
{
9694
return true;
@@ -109,7 +107,7 @@ private bool IsMandatoryParameterExisted(CommandAst cmdAst)
109107
// If cannot find any mandatory parameter, it's not necessary to do a further check for current cmdlet.
110108
try
111109
{
112-
int noOfParamSets = cmdInfo.ParameterSets.Count;
110+
int noOfParamSets = cmdInfo.ParameterSets.Count;
113111
foreach (ParameterMetadata pm in cmdInfo.Parameters.Values)
114112
{
115113
int count = 0;
@@ -163,7 +161,7 @@ private bool IsMandatoryParameterExisted(CommandAst cmdAst)
163161

164162
return returnValue;
165163
}
166-
164+
167165
/// <summary>
168166
/// GetName: Retrieves the name of this rule.
169167
/// </summary>

0 commit comments

Comments
 (0)