coverlet icon indicating copy to clipboard operation
coverlet copied to clipboard

Branches can be reported when they are unconditional

Open SteveGilham opened this issue 7 years ago • 1 comments

In passing, I noticed that in the code in issue #82, the method Normal that was tested reported a branch (1 out of 1 covered). This turns out to be a point where the IL has an unconditional jump (and thus no decision point in the control flow) that leads to the next instruction.

83

The IL for the method is

.method public hidebysig static 
	int32 Normal () cil managed 
{
	// Method begins at RVA 0x208c
	// Code size 19 (0x13)
	.maxstack 1
	.locals init (
		[0] valuetype [netstandard]System.DateTime,
		[1] int32
	)

	// (no C# code)
	IL_0000: nop
	// return DateTime.Now.Hour;
	IL_0001: call valuetype [netstandard]System.DateTime [netstandard]System.DateTime::get_Now()
	IL_0006: stloc.0
	// (no C# code)
	IL_0007: ldloca.s 0
	IL_0009: call instance int32 [netstandard]System.DateTime::get_Hour()
	IL_000e: stloc.1
	IL_000f: br.s IL_0011

	IL_0011: ldloc.1
	IL_0012: ret
} // end of method Class1::Normal

The full XML report for the method is as follows

            <Method cyclomaticComplexity="0" nPathComplexity="0" sequenceCoverage="1" branchCoverage="1" isConstructor="False" isGetter="False" isSetter="False" isStatic="True">
              <Summary numSequencePoints="3" visitedSequencePoints="3" numBranchPoints="1" visitedBranchPoints="1" sequenceCoverage="1" branchCoverage="1" maxCyclomaticComplexity="0" minCyclomaticComplexity="0" visitedClasses="0" numClasses="0" visitedMethods="1" numMethods="1" />
              <MetadataToken />
              <Name>System.Int32 ClassLibrary1.Class1::Normal()</Name>
              <FileRef uid="1" />
              <SequencePoints>
                <SequencePoint vc="1" upsid="31" ordinal="0" sl="31" sc="1" el="31" ec="2" bec="0" bev="0" fileid="1" />
                <SequencePoint vc="1" upsid="32" ordinal="1" sl="32" sc="1" el="32" ec="2" bec="0" bev="0" fileid="1" />
                <SequencePoint vc="1" upsid="33" ordinal="2" sl="33" sc="1" el="33" ec="2" bec="0" bev="0" fileid="1" />
              </SequencePoints>
              <BranchPoints>
                <BranchPoint vc="1" upsid="33" ordinal="0" path="" offset="0" offsetend="0" sl="33" fileid="1" />
              </BranchPoints>
              <MethodPoint vc="3" upsid="0" p8:type="SequencePoint" ordinal="1" offset="1" sc="0" sl="31" ec="1" el="33" bec="0" bev="0" fileid="1" xmlns:p8="xsi" />
            </Method>

SteveGilham avatar May 03 '18 16:05 SteveGilham

I also notice in passing that the start-column and end-column attributes (sc and ec) for the method are not what one would expect (the expected values being like 9,10; 13,38 and 9,10 respectively)

SteveGilham avatar May 03 '18 17:05 SteveGilham

The issue might be out-dated because new releases are available.

Please reopen the issue if the bug still exists and can be reproduced with latest preview from coverlet nightly build.

see Consume nightly build

Bertk avatar Jan 22 '24 08:01 Bertk