Skip to content

Commit 3c60ccc

Browse files
committed
Static analysis cruft
1 parent 1e9a86d commit 3c60ccc

File tree

2 files changed

+76
-14
lines changed

2 files changed

+76
-14
lines changed

AltCover.Base/AltCover.Base.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<RootNamespace>AltCover</RootNamespace>
66
<AssemblyName>AltCover.Base</AssemblyName>
7-
<GlobalDefineConstants>RUNNER</GlobalDefineConstants>
7+
<GlobalDefineConstants>RUNNER;LITEVERSION</GlobalDefineConstants>
88
</PropertyGroup>
99

1010
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
@@ -15,6 +15,7 @@
1515
</PropertyGroup>
1616

1717
<ItemGroup>
18+
<Compile Include="..\_Generated\AssemblyVersion.cs" Link="AssemblyVersion.cs" />
1819
<Compile Include="..\_Generated\VisibleToTest.cs" Link="VisibleToTest.cs" />
1920
<Compile Include="..\AltCover.Recorder\Base.cs" Link="Base.cs" />
2021
<None Include="..\AltCover.Recorder\Base.fs" Link="Base.fs" />

AltCover.Recorder/Base.cs

Lines changed: 74 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,24 @@ internal enum ReportFormat
4848
Zipped = 128,
4949
};
5050

51+
[SuppressMessage("Gendarme.Rules.Performance",
52+
"AvoidUncalledPrivateCodeRule",
53+
Justification = "Internals Visible To")]
54+
[SuppressMessage("Gendarme.Rules.Performance",
55+
"AvoidUninstantiatedInternalClassesRule",
56+
Justification = "Internals Visible To")]
5157
internal enum Sampling
5258
{
5359
All = 0,
5460
Single = 1,
5561
};
5662

63+
[SuppressMessage("Gendarme.Rules.Performance",
64+
"AvoidUncalledPrivateCodeRule",
65+
Justification = "Internals Visible To")]
66+
[SuppressMessage("Gendarme.Rules.Performance",
67+
"AvoidUninstantiatedInternalClassesRule",
68+
Justification = "Internals Visible To")]
5769
internal enum Tag
5870
{
5971
Null = 0,
@@ -64,11 +76,23 @@ internal enum Tag
6476
}
6577

6678
[ExcludeFromCodeCoverage]
79+
[SuppressMessage("Gendarme.Rules.Performance",
80+
"ImplementEqualsTypeRule",
81+
Justification = "No use case")]
82+
[SuppressMessage("Gendarme.Rules.Design",
83+
"OperatorEqualsShouldBeOverloadedRule",
84+
Justification = "No use case")]
6785
internal struct Pair
6886
{
6987
public long Time;
7088
public int Call;
7189

90+
[SuppressMessage("Gendarme.Rules.Performance",
91+
"AvoidUncalledPrivateCodeRule",
92+
Justification = "Internals Visible To")]
93+
[SuppressMessage("Gendarme.Rules.Performance",
94+
"OverrideValueTypeDefaultsRule",
95+
Justification = "You what, mate?")]
7296
public static Pair Create(long time, int call)
7397
{
7498
return new Pair { Time = time, Call = call };
@@ -97,10 +121,13 @@ public override int GetHashCode()
97121
}
98122
}
99123

124+
[SuppressMessage("Gendarme.Rules.Performance",
125+
"ImplementEqualsTypeRule",
126+
Justification = "abstract type, No use case")]
100127
internal abstract class Track
101128
{
102-
internal static readonly string Entry = "\u2611"; // BALLOT BOX WITH CHECK
103-
internal static readonly string Exit = "\u2612"; // BALLOT BOX WITH X
129+
internal const string Entry = "\u2611"; // BALLOT BOX WITH CHECK
130+
internal const string Exit = "\u2612"; // BALLOT BOX WITH X
104131

105132
public override bool Equals(object obj)
106133
{
@@ -113,6 +140,9 @@ public override int GetHashCode()
113140
}
114141
}
115142

143+
[SuppressMessage("Gendarme.Rules.Performance",
144+
"ImplementEqualsTypeRule",
145+
Justification = "No use case")]
116146
internal class Null : Track
117147
{
118148
public override string ToString()
@@ -131,6 +161,9 @@ public override int GetHashCode()
131161
}
132162
}
133163

164+
[SuppressMessage("Gendarme.Rules.Performance",
165+
"ImplementEqualsTypeRule",
166+
Justification = "No use case")]
134167
internal class Time : Track
135168
{
136169
public readonly long Value;
@@ -142,9 +175,9 @@ public Time(long time)
142175

143176
public override bool Equals(object obj)
144177
{
145-
if (obj is Time)
178+
if (obj is Time t)
146179
{
147-
return Value == ((Time)obj).Value;
180+
return Value == t.Value;
148181
}
149182

150183
return false;
@@ -161,7 +194,10 @@ public override string ToString()
161194
}
162195
}
163196

164-
internal class Call : Track
197+
[SuppressMessage("Gendarme.Rules.Performance",
198+
"ImplementEqualsTypeRule",
199+
Justification = "No use case")]
200+
internal sealed class Call : Track
165201
{
166202
public readonly int Value;
167203

@@ -172,9 +208,9 @@ public Call(int call)
172208

173209
public override bool Equals(object obj)
174210
{
175-
if (obj is Call)
211+
if (obj is Call c)
176212
{
177-
return Value == ((Call)obj).Value;
213+
return Value == c.Value;
178214
}
179215

180216
return false;
@@ -191,7 +227,10 @@ public override string ToString()
191227
}
192228
}
193229

194-
internal class Both : Track
230+
[SuppressMessage("Gendarme.Rules.Performance",
231+
"ImplementEqualsTypeRule",
232+
Justification = "No use case")]
233+
internal sealed class Both : Track
195234
{
196235
public readonly Pair Value;
197236

@@ -222,7 +261,7 @@ public override string ToString()
222261
}
223262
}
224263

225-
internal class Table : Track
264+
internal sealed class Table : Track
226265
{
227266
public readonly Dictionary<string, Dictionary<int, PointVisit>> Value;
228267

@@ -232,7 +271,10 @@ public Table(Dictionary<string, Dictionary<int, PointVisit>> table)
232271
}
233272
}
234273

235-
internal class PointVisit
274+
[SuppressMessage("Gendarme.Rules.Performance",
275+
"ImplementEqualsTypeRule",
276+
Justification = "No use case")]
277+
internal sealed class PointVisit
236278
{
237279
public long Count;
238280
public readonly List<Track> Tracks;
@@ -300,6 +342,9 @@ internal long Total
300342

301343
internal static class Counter
302344
{
345+
[SuppressMessage("Gendarme.Rules.Design.Generic",
346+
"AvoidDeclaringCustomDelegatesRule",
347+
Justification = "Net Framework 2.0")]
303348
public delegate void PointProcessor(XmlElement doc, IEnumerable<Track> tracking);
304349

305350
// <summary>
@@ -327,7 +372,8 @@ internal static class Counter
327372

328373
internal static class I
329374
#else
330-
static private class I
375+
376+
private static class I
331377
#endif
332378
{
333379
internal struct coverXml
@@ -482,6 +528,12 @@ private static XmlDocument readXDocument(Stream stream)
482528
private static void writeXDocument(XmlDocument coverageDocument, Stream stream)
483529
{ coverageDocument.Save(stream); }
484530

531+
[SuppressMessage("Gendarme.Rules.Smells",
532+
"AvoidLongMethodsRule",
533+
Justification = "Well tested code")]
534+
[SuppressMessage("Gendarme.Rules.Smells",
535+
"AvoidLongParameterListsRule",
536+
Justification = "Stable code")]
485537
public static DateTime updateReport(
486538
Action<XmlDocument> postProcess,
487539
PointProcessor pointProcess,
@@ -605,6 +657,9 @@ out var vc
605657
return flushStart;
606658
}
607659

660+
[SuppressMessage("Gendarme.Rules.Smells",
661+
"AvoidLongParameterListsRule",
662+
Justification = "Stable code")]
608663
public static TimeSpan doFlush(
609664
Action<XmlDocument> postProcess,
610665
PointProcessor pointProcess,
@@ -644,6 +699,9 @@ Track context
644699

645700
#if RUNNER
646701

702+
[SuppressMessage("Gendarme.Rules.Performance",
703+
"AvoidUncalledPrivateCodeRule",
704+
Justification = "Internals Visible To")]
647705
internal static long addVisit(
648706
Dictionary<string, Dictionary<int, PointVisit>> counts,
649707
string moduleId,
@@ -660,9 +718,12 @@ Track context
660718
return 1;
661719
}
662720

721+
[SuppressMessage("Gendarme.Rules.Performance",
722+
"AvoidUncalledPrivateCodeRule",
723+
Justification = "Internals Visible To")]
663724
[SuppressMessage("Gendarme.Rules.Smells",
664-
"AvoidLongParameterListsRule",
665-
Justification = "Most of this gets curried away")]
725+
"AvoidLongParameterListsRule",
726+
Justification = "Stable code")]
666727
public static TimeSpan doFlushStream(
667728
Action<XmlDocument> postProcess,
668729
PointProcessor pointProcess,

0 commit comments

Comments
 (0)