Skip to content

Commit 3499681

Browse files
committed
Add StyleCop.Analyzers to provide feedback on formatting issues in the inner loop
1 parent 61889b2 commit 3499681

File tree

6 files changed

+88
-18
lines changed

6 files changed

+88
-18
lines changed

.editorconfig

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,78 @@ dotnet_diagnostic.CA2012.severity = none
88

99
# CA1826: Do not use Enumerable methods on indexable collections
1010
dotnet_diagnostic.CA1826.severity = none
11+
12+
# StyleCopAnalyzers
13+
dotnet_diagnostic.SA0001.severity = none
14+
dotnet_diagnostic.SA1002.severity = none
15+
dotnet_diagnostic.SA1003.severity = none
16+
dotnet_diagnostic.SA1005.severity = none
17+
dotnet_diagnostic.SA1008.severity = none
18+
dotnet_diagnostic.SA1009.severity = none
19+
dotnet_diagnostic.SA1023.severity = none
20+
dotnet_diagnostic.SA1025.severity = none
21+
dotnet_diagnostic.SA1100.severity = none
22+
dotnet_diagnostic.SA1101.severity = none
23+
dotnet_diagnostic.SA1102.severity = none
24+
dotnet_diagnostic.SA1105.severity = none
25+
dotnet_diagnostic.SA1107.severity = none
26+
dotnet_diagnostic.SA1108.severity = none
27+
dotnet_diagnostic.SA1111.severity = none
28+
dotnet_diagnostic.SA1114.severity = none
29+
dotnet_diagnostic.SA1115.severity = none
30+
dotnet_diagnostic.SA1116.severity = none
31+
dotnet_diagnostic.SA1118.severity = none
32+
dotnet_diagnostic.SA1120.severity = none
33+
dotnet_diagnostic.SA1122.severity = none
34+
dotnet_diagnostic.SA1123.severity = none
35+
dotnet_diagnostic.SA1124.severity = none
36+
dotnet_diagnostic.SA1127.severity = none
37+
dotnet_diagnostic.SA1128.severity = none
38+
dotnet_diagnostic.SA1129.severity = none
39+
dotnet_diagnostic.SA1131.severity = none
40+
dotnet_diagnostic.SA1132.severity = none
41+
dotnet_diagnostic.SA1133.severity = none
42+
dotnet_diagnostic.SA1134.severity = none
43+
dotnet_diagnostic.SA1139.severity = none
44+
dotnet_diagnostic.SA1200.severity = none
45+
dotnet_diagnostic.SA1201.severity = none
46+
dotnet_diagnostic.SA1202.severity = none
47+
dotnet_diagnostic.SA1203.severity = none
48+
dotnet_diagnostic.SA1204.severity = none
49+
dotnet_diagnostic.SA1205.severity = none
50+
dotnet_diagnostic.SA1206.severity = none
51+
dotnet_diagnostic.SA1214.severity = none
52+
dotnet_diagnostic.SA1306.severity = none
53+
dotnet_diagnostic.SA1310.severity = none
54+
dotnet_diagnostic.SA1401.severity = none
55+
dotnet_diagnostic.SA1402.severity = none
56+
dotnet_diagnostic.SA1500.severity = none
57+
dotnet_diagnostic.SA1501.severity = none
58+
dotnet_diagnostic.SA1502.severity = none
59+
dotnet_diagnostic.SA1503.severity = none
60+
dotnet_diagnostic.SA1507.severity = none
61+
dotnet_diagnostic.SA1512.severity = none
62+
dotnet_diagnostic.SA1513.severity = none
63+
dotnet_diagnostic.SA1514.severity = none
64+
dotnet_diagnostic.SA1515.severity = none
65+
dotnet_diagnostic.SA1516.severity = none
66+
dotnet_diagnostic.SA1519.severity = none
67+
dotnet_diagnostic.SA1600.severity = none
68+
dotnet_diagnostic.SA1601.severity = none
69+
dotnet_diagnostic.SA1602.severity = none
70+
dotnet_diagnostic.SA1611.severity = none
71+
dotnet_diagnostic.SA1615.severity = none
72+
dotnet_diagnostic.SA1618.severity = none
73+
dotnet_diagnostic.SA1619.severity = none
74+
dotnet_diagnostic.SA1623.severity = none
75+
dotnet_diagnostic.SA1633.severity = none
76+
dotnet_diagnostic.SA1634.severity = none
77+
dotnet_diagnostic.SA1635.severity = none
78+
dotnet_diagnostic.SA1636.severity = none
79+
dotnet_diagnostic.SA1637.severity = none
80+
dotnet_diagnostic.SA1638.severity = none
81+
dotnet_diagnostic.SA1640.severity = none
82+
dotnet_diagnostic.SA1641.severity = none
83+
dotnet_diagnostic.SA1642.severity = none
84+
dotnet_diagnostic.SA1643.severity = none
85+
dotnet_diagnostic.SA1649.severity = none

src/TfvcMigrator/AsyncParallelQueue.AtomicOperations.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,5 +174,4 @@ private NextOperation TryComplete()
174174
}
175175
}
176176
}
177-
178177
}

src/TfvcMigrator/CommonUtils.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ namespace TfvcMigrator
77
{
88
internal static class CommonUtils
99
{
10-
/// <exception cref="ArgumentNullException">
11-
/// Thrown when <paramref name="enumerable"/> is <see langword="null"/>.
12-
/// </exception>
1310
public static bool TryGetCollectionCount<T>(IEnumerable<T> enumerable, out int count)
1411
{
1512
switch (enumerable)
@@ -35,12 +32,6 @@ public static bool TryGetCollectionCount<T>(IEnumerable<T> enumerable, out int c
3532
}
3633
}
3734

38-
/// <exception cref="ArgumentOutOfRangeException">
39-
/// Thrown when <paramref name="minCapacity"/> is less than zero.
40-
/// </exception>
41-
/// <exception cref="OutOfMemoryException">
42-
/// Thrown when <paramref name="minCapacity"/> is greater than the maximum available array length.
43-
/// </exception>
4435
public static void EnsureCapacity<T>([NotNull] ref T[]? array, int minCapacity)
4536
{
4637
if (minCapacity < 0)

src/TfvcMigrator/Program.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
using LibGit2Sharp;
2-
using Microsoft.TeamFoundation.SourceControl.WebApi;
3-
using Microsoft.VisualStudio.Services.Common;
4-
using Microsoft.VisualStudio.Services.WebApi;
5-
using System;
1+
using System;
62
using System.Collections.Generic;
73
using System.Collections.Immutable;
84
using System.CommandLine;
@@ -13,6 +9,10 @@
139
using System.Text;
1410
using System.Threading;
1511
using System.Threading.Tasks;
12+
using LibGit2Sharp;
13+
using Microsoft.TeamFoundation.SourceControl.WebApi;
14+
using Microsoft.VisualStudio.Services.Common;
15+
using Microsoft.VisualStudio.Services.WebApi;
1616
using TfvcMigrator.Operations;
1717

1818
namespace TfvcMigrator
@@ -38,13 +38,13 @@ public static Task Main(string[] args)
3838
parseArgument: result => result.Tokens.Select(token => ParseRootPathChange(token.Value)).ToImmutableArray())
3939
{
4040
Arity = ArgumentArity.OneOrMore,
41-
Description = "Followed by one or more arguments with the format CS1234:$/New/Path. Changes the path that is mapped as the Git repository root to a new path during a specified changeset."
41+
Description = "Followed by one or more arguments with the format CS1234:$/New/Path. Changes the path that is mapped as the Git repository root to a new path during a specified changeset.",
4242
},
4343
new Option<string?>("--pat") { Description = "Optional PAT, required to access TFVC repositories hosted on Azure DevOps Services. If not provided Default Client Credentials will be used, these are only suitable for on-premise TFS/Azure DevOps Server." },
4444
};
4545

4646
command.SetHandler(
47-
new Func<Uri, string, string, string?, int?, int?, ImmutableArray<RootPathChange>, string?, Task >(MigrateAsync));
47+
new Func<Uri, string, string, string?, int?, int?, ImmutableArray<RootPathChange>, string?, Task>(MigrateAsync));
4848

4949
return command.InvokeAsync(args);
5050
}

src/TfvcMigrator/TfvcMigrator.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
<ItemGroup>
2828
<PackageReference Include="LibGit2Sharp" Version="0.27.0-preview-0175" />
2929
<PackageReference Include="Microsoft.TeamFoundationServer.Client" Version="16.170.0" />
30+
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.406">
31+
<PrivateAssets>all</PrivateAssets>
32+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
33+
</PackageReference>
3034
<PackageReference Include="System.CommandLine" Version="2.0.0-beta2.21617.1" />
3135
<PackageReference Include="TaskTupleAwaiter" Version="2.0.0" />
3236
</ItemGroup>

src/TfvcMigrator/TopologicalSortExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ bool MoveNext()
7474

7575
if (dependentItemInfo.OutstandingDependencies.Count == 1)
7676
{
77-
Debug.Assert(comparer.Equals(recursionStack.Peek().CompletedItemKey, dependentItemInfo.OutstandingDependencies[0]));
77+
if (!comparer.Equals(recursionStack.Peek().CompletedItemKey, dependentItemInfo.OutstandingDependencies[0]))
78+
throw new ArgumentException("A consistency error was detected in the comparer.", nameof(comparer));
7879

7980
completedItem = dependentItemInfo.Item;
8081
completedItemKey = dependentItemInfo.Key;

0 commit comments

Comments
 (0)