Address CA1829 (Avoiding Count LINQ method calls when equivalent + more efficient properties exist) (#1961)

* Address CA1829 (Avoid Count LINQ Method Calls)

* Remove other change

* CA1829 removal

* CA1829 (remove whitespace)
This commit is contained in:
Chris LaFreniere
2023-03-23 21:06:49 -07:00
committed by GitHub
parent 3ef3a0f022
commit cccdbf0bef
15 changed files with 25 additions and 27 deletions

View File

@@ -4,7 +4,6 @@
//
using System.Collections.Generic;
using System.Linq;
using Kusto.Language;
using Kusto.Language.Editor;
using Microsoft.Kusto.ServiceLayer.DataSource.Intellisense;
@@ -59,7 +58,7 @@ namespace Microsoft.Kusto.ServiceLayer.DataSource.Kusto
// build a list of Kusto script file markers from the errors.
List<ScriptFileMarker> markers = new List<ScriptFileMarker>();
if (parseResult != null && parseResult.Count() > 0)
if (parseResult != null && parseResult.Count > 0)
{
foreach (var error in parseResult)
{

View File

@@ -177,7 +177,7 @@ namespace Microsoft.Kusto.ServiceLayer.ObjectExplorer.Nodes
private void DoSort()
{
List<TreeNode> sorted = this.OrderBy(x => x).ToList();
for (int i = 0; i < sorted.Count(); i++)
for (int i = 0; i < sorted.Count; i++)
{
int index = IndexOf(sorted[i]);
if (index != i)

View File

@@ -54,7 +54,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
ServiceResponse<TResult>[] resultList = new ServiceResponse<TResult>[inputList.Count];
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
var tasks = Enumerable.Range(0, inputList.Count())
var tasks = Enumerable.Range(0, inputList.Count)
.Select(async i =>
{
ServiceResponse<TResult> result = await GetResult(config, inputList[i], lookupKey, cancellationToken,

View File

@@ -184,7 +184,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
private void DoSort()
{
List<TreeNode> sorted = this.OrderBy(x => x).ToList();
for (int i = 0; i < sorted.Count(); i++)
for (int i = 0; i < sorted.Count; i++)
{
int index = IndexOf(sorted[i]);
if (index != i)

View File

@@ -399,7 +399,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Scripting
// extract full object name from quickInfo text
string[] tokens = quickInfoText.Split(' ');
List<string> tokenList = tokens.Where(el => el.IndexOf(tokenText, caseSensitivity) >= 0).ToList();
return (tokenList?.Count() > 0) ? tokenList[0] : null;
return (tokenList?.Count > 0) ? tokenList[0] : null;
}
/// <summary>
@@ -418,7 +418,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Scripting
// extract string denoting the token type from quickInfo text
string[] tokens = quickInfoText.Split(' ');
List<int> indexList = tokens.Select((s, i) => new { i, s }).Where(el => (el.s).IndexOf(tokenText, caseSensitivity) >= 0).Select(el => el.i).ToList();
return (indexList?.Count() > 0) ? String.Join(" ", tokens.Take(indexList[0])) : null;
return (indexList?.Count > 0) ? String.Join(" ", tokens.Take(indexList[0])) : null;
}

View File

@@ -1033,7 +1033,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
indexVM.FilterPredicate.Value = index.FilterPredicate;
indexVM.FilterPredicate.Enabled = !index.IsClustered || index.FilterPredicate != null;
indexVM.IncludedColumns.Enabled = !index.IsClustered || index.IncludedColumns.Count() > 0;
indexVM.IncludedColumns.Enabled = !index.IsClustered || index.IncludedColumns.Count > 0;
indexVM.IncludedColumns.CanAddRows = !index.IsClustered;
foreach (var column in index.IncludedColumns)
@@ -1058,7 +1058,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
indexVM.IsClustered.Checked = index.IsClustered;
indexVM.FilterPredicate.Value = index.FilterPredicate;
indexVM.FilterPredicate.Enabled = !index.IsClustered || index.FilterPredicate != null;
indexVM.Columns.Enabled = !index.IsClustered || index.Columns.Count() > 0;
indexVM.Columns.Enabled = !index.IsClustered || index.Columns.Count > 0;
indexVM.Columns.CanAddRows = !index.IsClustered;
indexVM.ColumnsDisplayValue.Enabled = false;