Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Suppress Gendarme Defects?

Is it possible to suppress a specific gendarme defect message? I would like to do this in the source code with a flag or something like it.

like image 809
Juergen Avatar asked Apr 14 '10 13:04

Juergen


1 Answers

As poupou already noted, version 2.10 supports the [SuppressMessage] attribute.

For example, to suppress the AvoidNonAlphanumericIdentifierRule rule, do this:

[SuppressMessage("Gendarme.Rules.Naming", "AvoidNonAlphanumericIdentifierRule")]
protected void Application_Start()
{
     ...
}

Note that you need to specify the name of the assembly where the rule lives... in this case, AvoidNonAlphanumericIdentifierRule lives in Gendarme.Rules.Naming.dll. The full list of rules and their assembly names are here.

like image 115
Lee Harold Avatar answered Oct 01 '22 20:10

Lee Harold