If there are two defects in a target, only the first one is recognized. Thats why a Gendarme run on Nunit-Money example shows 16 defects on console and in XML, but Jenkins-Violations plugin only reports 14 defects.
The following is extracted from the generated XML:
{{
<rule Name="AvoidRepetitiveCastsRule" Uri="https://github.com/spouliot/gendarme/wiki/Gendarme.Rules.Performance.AvoidRepetitiveCastsRule(2.10)">
<problem>The method seems to repeat the same cast operation multiple times.</problem>
<solution>Change the logic to ensure the (somewhat expensive) cast is done once.</solution>
<target Name="System.Boolean NUnit.Samples.Money.Money::Equals(System.Object)" Assembly="cs-money, Version=2.2.0.0, Culture=neutral, PublicKeyToken=null">
<defect Severity="Medium" Confidence="Normal" Location="System.Boolean NUnit.Samples.Money.Money::Equals(System.Object)" Source="c:\test\money\Money.cs(≈60)">'anObject' is casted 2 times for type 'NUnit.Samples.Money.IMoney'.</defect>
<defect Severity="Medium" Confidence="Normal" Location="System.Boolean NUnit.Samples.Money.Money::Equals(System.Object)" Source="c:\test\money\Money.cs(≈62)">'anObject' is casted 2 times for type 'NUnit.Samples.Money.Money'.</defect>
</target>
<target Name="System.Boolean NUnit.Samples.Money.MoneyBag::Equals(System.Object)" Assembly="cs-money, Version=2.2.0.0, Culture=neutral, PublicKeyToken=null">
<defect Severity="Medium" Confidence="Normal" Location="System.Boolean NUnit.Samples.Money.MoneyBag::Equals(System.Object)" Source="c:\test\money\MoneyBag.cs(≈93)">'anObject' is casted 2 times for type 'NUnit.Samples.Money.IMoney'.</defect>
<defect Severity="Medium" Confidence="Normal" Location="System.Boolean NUnit.Samples.Money.MoneyBag::Equals(System.Object)" Source="c:\test\money\MoneyBag.cs(≈96)">'anObject' is casted 2 times for type 'NUnit.Samples.Money.MoneyBag'.</defect>
</target>
</rule>
}}
Code changed in jenkins
User: Erik Ramfelt
Path:
src/main/java/hudson/plugins/violations/types/gendarme/GendarmeParser.java
src/test/java/hudson/plugins/violations/types/gendarme/GendarmeParserTest.java
src/test/resources/hudson/plugins/violations/types/gendarme/gendarme-2.xml
src/test/resources/hudson/plugins/violations/types/gendarme/gendarme-2_unix.xml
http://jenkins-ci.org/commit/violations-plugin/8a6c7321f62c5803a3b477c4b5bf385cfe4ff35d
Log:
[FIXED JENKINS-11227] Fixed so the gendarme parser support multiple defects in a rule target, and Type and Method rule violations get the correct source file