Skip to content

Commit

Permalink
Static analysis cruft
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveGilham committed Jul 16, 2024
1 parent 1e9a86d commit 3c60ccc
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 14 deletions.
3 changes: 2 additions & 1 deletion AltCover.Base/AltCover.Base.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>AltCover</RootNamespace>
<AssemblyName>AltCover.Base</AssemblyName>
<GlobalDefineConstants>RUNNER</GlobalDefineConstants>
<GlobalDefineConstants>RUNNER;LITEVERSION</GlobalDefineConstants>
</PropertyGroup>

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

<ItemGroup>
<Compile Include="..\_Generated\AssemblyVersion.cs" Link="AssemblyVersion.cs" />
<Compile Include="..\_Generated\VisibleToTest.cs" Link="VisibleToTest.cs" />
<Compile Include="..\AltCover.Recorder\Base.cs" Link="Base.cs" />
<None Include="..\AltCover.Recorder\Base.fs" Link="Base.fs" />
Expand Down
87 changes: 74 additions & 13 deletions AltCover.Recorder/Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,24 @@ internal enum ReportFormat
Zipped = 128,
};

[SuppressMessage("Gendarme.Rules.Performance",
"AvoidUncalledPrivateCodeRule",
Justification = "Internals Visible To")]
[SuppressMessage("Gendarme.Rules.Performance",
"AvoidUninstantiatedInternalClassesRule",
Justification = "Internals Visible To")]
internal enum Sampling
{
All = 0,
Single = 1,
};

[SuppressMessage("Gendarme.Rules.Performance",
"AvoidUncalledPrivateCodeRule",
Justification = "Internals Visible To")]
[SuppressMessage("Gendarme.Rules.Performance",
"AvoidUninstantiatedInternalClassesRule",
Justification = "Internals Visible To")]
internal enum Tag
{
Null = 0,
Expand All @@ -64,11 +76,23 @@ internal enum Tag
}

[ExcludeFromCodeCoverage]
[SuppressMessage("Gendarme.Rules.Performance",
"ImplementEqualsTypeRule",
Justification = "No use case")]
[SuppressMessage("Gendarme.Rules.Design",
"OperatorEqualsShouldBeOverloadedRule",
Justification = "No use case")]
internal struct Pair
{
public long Time;
public int Call;

[SuppressMessage("Gendarme.Rules.Performance",
"AvoidUncalledPrivateCodeRule",
Justification = "Internals Visible To")]
[SuppressMessage("Gendarme.Rules.Performance",
"OverrideValueTypeDefaultsRule",
Justification = "You what, mate?")]
public static Pair Create(long time, int call)
{
return new Pair { Time = time, Call = call };
Expand Down Expand Up @@ -97,10 +121,13 @@ public override int GetHashCode()
}
}

[SuppressMessage("Gendarme.Rules.Performance",
"ImplementEqualsTypeRule",
Justification = "abstract type, No use case")]
internal abstract class Track
{
internal static readonly string Entry = "\u2611"; // BALLOT BOX WITH CHECK
internal static readonly string Exit = "\u2612"; // BALLOT BOX WITH X
internal const string Entry = "\u2611"; // BALLOT BOX WITH CHECK
internal const string Exit = "\u2612"; // BALLOT BOX WITH X

public override bool Equals(object obj)
{
Expand All @@ -113,6 +140,9 @@ public override int GetHashCode()
}
}

[SuppressMessage("Gendarme.Rules.Performance",
"ImplementEqualsTypeRule",
Justification = "No use case")]
internal class Null : Track
{
public override string ToString()
Expand All @@ -131,6 +161,9 @@ public override int GetHashCode()
}
}

[SuppressMessage("Gendarme.Rules.Performance",
"ImplementEqualsTypeRule",
Justification = "No use case")]
internal class Time : Track
{
public readonly long Value;
Expand All @@ -142,9 +175,9 @@ public Time(long time)

public override bool Equals(object obj)
{
if (obj is Time)
if (obj is Time t)
{
return Value == ((Time)obj).Value;
return Value == t.Value;
}

return false;
Expand All @@ -161,7 +194,10 @@ public override string ToString()
}
}

internal class Call : Track
[SuppressMessage("Gendarme.Rules.Performance",
"ImplementEqualsTypeRule",
Justification = "No use case")]
internal sealed class Call : Track
{
public readonly int Value;

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

public override bool Equals(object obj)
{
if (obj is Call)
if (obj is Call c)
{
return Value == ((Call)obj).Value;
return Value == c.Value;
}

return false;
Expand All @@ -191,7 +227,10 @@ public override string ToString()
}
}

internal class Both : Track
[SuppressMessage("Gendarme.Rules.Performance",
"ImplementEqualsTypeRule",
Justification = "No use case")]
internal sealed class Both : Track
{
public readonly Pair Value;

Expand Down Expand Up @@ -222,7 +261,7 @@ public override string ToString()
}
}

internal class Table : Track
internal sealed class Table : Track
{
public readonly Dictionary<string, Dictionary<int, PointVisit>> Value;

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

internal class PointVisit
[SuppressMessage("Gendarme.Rules.Performance",
"ImplementEqualsTypeRule",
Justification = "No use case")]
internal sealed class PointVisit
{
public long Count;
public readonly List<Track> Tracks;
Expand Down Expand Up @@ -300,6 +342,9 @@ internal long Total

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

// <summary>
Expand Down Expand Up @@ -327,7 +372,8 @@ internal static class Counter

internal static class I
#else
static private class I

private static class I
#endif
{
internal struct coverXml
Expand Down Expand Up @@ -482,6 +528,12 @@ private static XmlDocument readXDocument(Stream stream)
private static void writeXDocument(XmlDocument coverageDocument, Stream stream)
{ coverageDocument.Save(stream); }

[SuppressMessage("Gendarme.Rules.Smells",
"AvoidLongMethodsRule",
Justification = "Well tested code")]
[SuppressMessage("Gendarme.Rules.Smells",
"AvoidLongParameterListsRule",
Justification = "Stable code")]
public static DateTime updateReport(
Action<XmlDocument> postProcess,
PointProcessor pointProcess,
Expand Down Expand Up @@ -605,6 +657,9 @@ out var vc
return flushStart;
}

[SuppressMessage("Gendarme.Rules.Smells",
"AvoidLongParameterListsRule",
Justification = "Stable code")]
public static TimeSpan doFlush(
Action<XmlDocument> postProcess,
PointProcessor pointProcess,
Expand Down Expand Up @@ -644,6 +699,9 @@ Track context

#if RUNNER

[SuppressMessage("Gendarme.Rules.Performance",
"AvoidUncalledPrivateCodeRule",
Justification = "Internals Visible To")]
internal static long addVisit(
Dictionary<string, Dictionary<int, PointVisit>> counts,
string moduleId,
Expand All @@ -660,9 +718,12 @@ Track context
return 1;
}

[SuppressMessage("Gendarme.Rules.Performance",
"AvoidUncalledPrivateCodeRule",
Justification = "Internals Visible To")]
[SuppressMessage("Gendarme.Rules.Smells",
"AvoidLongParameterListsRule",
Justification = "Most of this gets curried away")]
"AvoidLongParameterListsRule",
Justification = "Stable code")]
public static TimeSpan doFlushStream(
Action<XmlDocument> postProcess,
PointProcessor pointProcess,
Expand Down

0 comments on commit 3c60ccc

Please sign in to comment.