C#, Gendarme, Sonar and Jenkins : Exclude generated files from Gendarme

2.2k Views Asked by At

I'm working with gendarme for .net called by Sonar (launched by Jenkins). I've a lot of AvoidVisibleFieldsRule violations. The main violations are found in the generated files. As I can't do anything on it, i would like to exclude *.designer.cs from the scan.

I can't find a way to do that. There is a properties in Sonar to exclude generated files but it doesn't seem to be applied for gendarme.

Is there a way to do such a thing ?

Thanks for all

2

There are 2 best solutions below

2
On

Gendarme expects you provide an ignore list,

http://www.mono-project.com/Gendarme.FAQ

https://github.com/mono/mono-tools/blob/master/gendarme/self-test.ignore

The ignore file format is bit of weird, but you can learn it by experiments.

1
On

Indeed that is actually not normal at all. Generated code is excluded by the plugin with the standard configuration. What version of the C# plugins are you using ? Anyway, the configuration property you can try is "sonar.exclusions" (see http://docs.codehaus.org/display/SONAR/Advanced+parameters). If you do not solve your problem right away, the best thing would be to drop a mail to the user mailing list (see http://www.sonarsource.org/support/support/) and send the verbose output of your build. To get this output simply add "-X" to the command line. Hope it helps