diff --git a/Engine/Generic/RuleSuppression.cs b/Engine/Generic/RuleSuppression.cs index 279eec58f..d16b356fb 100644 --- a/Engine/Generic/RuleSuppression.cs +++ b/Engine/Generic/RuleSuppression.cs @@ -340,7 +340,7 @@ public static List GetSuppressions(IEnumerable at if (targetAsts != null) { - if (targetAsts.Count() == 0) + if (!targetAsts.Any()) { if (String.IsNullOrWhiteSpace(scopeAst.Extent.File)) { diff --git a/Engine/ScriptAnalyzer.cs b/Engine/ScriptAnalyzer.cs index c564dc8fa..46e267fc6 100644 --- a/Engine/ScriptAnalyzer.cs +++ b/Engine/ScriptAnalyzer.cs @@ -267,9 +267,9 @@ internal bool ParseProfile(object profileObject, PathIntrinsics path, IOutputWri return false; } - this.severity = (severityList.Count() == 0) ? null : severityList.ToArray(); - this.includeRule = (includeRuleList.Count() == 0) ? null : includeRuleList.ToArray(); - this.excludeRule = (excludeRuleList.Count() == 0) ? null : excludeRuleList.ToArray(); + this.severity = (severityList.Count == 0) ? null : severityList.ToArray(); + this.includeRule = (includeRuleList.Count == 0) ? null : includeRuleList.ToArray(); + this.excludeRule = (excludeRuleList.Count == 0) ? null : excludeRuleList.ToArray(); if (settings != null && settings.ContainsKey("Rules")) { @@ -609,7 +609,7 @@ private bool ParseProfileString(string profile, PathIntrinsics path, IOutputWrit IEnumerable hashTableAsts = profileAst.FindAll(item => item is HashtableAst, false); // no hashtable, raise warning - if (hashTableAsts.Count() == 0) + if (!hashTableAsts.Any()) { writer.WriteError(new ErrorRecord(new ArgumentException(string.Format(CultureInfo.CurrentCulture, Strings.InvalidProfile, profile)), Strings.ConfigurationFileHasNoHashTable, ErrorCategory.ResourceUnavailable, profile)); diff --git a/Engine/Settings.cs b/Engine/Settings.cs index 124e5488a..0d37a3a78 100644 --- a/Engine/Settings.cs +++ b/Engine/Settings.cs @@ -453,7 +453,7 @@ private void parseSettingsFile(string settingsFilePath) IEnumerable hashTableAsts = profileAst.FindAll(item => item is HashtableAst, false); // no hashtable, raise warning - if (hashTableAsts.Count() == 0) + if (!hashTableAsts.Any()) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Strings.InvalidProfile, settingsFilePath)); } diff --git a/Rules/AvoidMultipleTypeAttributes.cs b/Rules/AvoidMultipleTypeAttributes.cs index 77f63de21..590a058d9 100644 --- a/Rules/AvoidMultipleTypeAttributes.cs +++ b/Rules/AvoidMultipleTypeAttributes.cs @@ -37,7 +37,7 @@ public IEnumerable AnalyzeScript(Ast ast, string fileName) // Iterates all ParamAsts and check the number of its types. foreach (ParameterAst paramAst in paramAsts) { - if (paramAst.Attributes.Where(typeAst => typeAst is TypeConstraintAst).Count() > 1) + if (paramAst.Attributes.OfType().Skip(1).Any()) { yield return new DiagnosticRecord( String.Format(CultureInfo.CurrentCulture, Strings.AvoidMultipleTypeAttributesError, paramAst.Name),