Skip to content

Commit 8d25c79

Browse files
author
Kapil Borle
committed
Remove redundant count check
1 parent b9a114f commit 8d25c79

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

Rules/UseIdenticalMandatoryParametersDSC.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ public IEnumerable<DiagnosticRecord> AnalyzeDSCResource(Ast ast, string fileName
4949

5050
var functionDefinitionAsts = Helper.Instance.DscResourceFunctions(ast).Cast<FunctionDefinitionAst>();
5151

52+
// todo update logic to take keys into consideration
53+
// todo write tests for same
54+
// todo update documentation
5255
var keys = GetKeys(fileName);
56+
5357
// Dictionary to keep track of Mandatory parameters and their presence in Get/Test/Set TargetResource cmdlets
5458
var mandatoryParameters = new Dictionary<string, List<FunctionDefinitionAst>>(StringComparer.OrdinalIgnoreCase);
5559

@@ -99,26 +103,22 @@ public IEnumerable<DiagnosticRecord> AnalyzeDSCResource(Ast ast, string fileName
99103

100104
// Get the mandatory parameter names that do not appear in all the DSC Resource cmdlets
101105
IEnumerable<string> paramNames = mandatoryParameters.Where(x => x.Value.Count < expectedTargetResourceFunctionNames.Count).Select(x => x.Key);
102-
103-
if (paramNames.Count() > 0)
106+
foreach (string paramName in paramNames)
104107
{
105-
foreach (string paramName in paramNames)
106-
{
107-
var functionsNotContainingParam = functionDefinitionAsts.Except(mandatoryParameters[paramName]);
108+
var functionsNotContainingParam = functionDefinitionAsts.Except(mandatoryParameters[paramName]);
108109

109-
foreach (var funcDefnAst in functionsNotContainingParam)
110-
{
111-
yield return new DiagnosticRecord(
112-
string.Format(
113-
CultureInfo.InvariantCulture,
114-
Strings.UseIdenticalMandatoryParametersDSCError,
115-
paramName,
116-
funcDefnAst.Name),
117-
Helper.Instance.GetScriptExtentForFunctionName(funcDefnAst),
118-
GetName(),
119-
DiagnosticSeverity.Error,
120-
fileName);
121-
}
110+
foreach (var funcDefnAst in functionsNotContainingParam)
111+
{
112+
yield return new DiagnosticRecord(
113+
string.Format(
114+
CultureInfo.InvariantCulture,
115+
Strings.UseIdenticalMandatoryParametersDSCError,
116+
paramName,
117+
funcDefnAst.Name),
118+
Helper.Instance.GetScriptExtentForFunctionName(funcDefnAst),
119+
GetName(),
120+
DiagnosticSeverity.Error,
121+
fileName);
122122
}
123123
}
124124
}

0 commit comments

Comments
 (0)