Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I tell NDepend to ignore a single result?

I'm running NDepend against my C# project in VS 2012. There is a particular "critical rule violation" that I have looked at and have decided that I want to leave as-is. I want to tell NDepend to ignore this one violation and NOT count it against my critical rule violation count, so that I can get the dot at the bottom to be no longer red.

If it matters: It's a "function with too many parameters". The purpose of function is to make a log entry into a database table, and I need to pass in all of the values (11 of them) to populate the table (after applying some logic to them). I suppose I could put all the values into a struct or class and pass that in as a single value, but there would be no other use for the struct/class than to call this one function, so that seems kind of silly to me.

So, I was looking for a way to just do something like right-clicking on the result and choosing "permanently ignore this result", like you might do with a spell checker, but I don't see any such option.

Is there a way to do this?

I don't want to exclude the entire rule or modify it to increase the max number of parameters, as there may be other instances where I DO agree that the function should be modified.

like image 201
JoeMjr2 Avatar asked Dec 07 '13 22:12

JoeMjr2


People also ask

How to ignore a test method in Java?

If you want to ignore a test method, use @Ignore along with @Test annotation. If you want to ignore all the tests of class, use @Ignore annotation at the class level.

What is the difference between explicit and mandatory ID in NDepend?

This Id is mandatory to suppress issues of an NDepend rule by rule Id. The Explicit Id is optional both in the rule definition and for each SuppressMessage. The Id must be formatted with one or two uppercase letters (usually ND) followed by 4 digits. The Explicit Id is a camel case string inferred from the rule name.

How do I ignore a test In JUnit?

Junit Test Example - Ignore. As discussed in above definition, you can use @Ignore annotation to ignore a test or group of the test. Let's understand it using simple example and in below given scenarios: Creating a simple test class without ignoring a test. Ignore a test method using @Ignore annotation.

What is the use of @ignore Test annotation?

The @Ignore test annotation is used to ignore particular tests or group of tests in order to skip the build failure. @Ignore annotation can be used in two scenarios as given below:


1 Answers

You can modify the CQLinq rule body this way:

// <Name>Methods with too many parameters</Name>
warnif count > 0 from m in JustMyCode.Methods
.WithFullNameNotIn("MyNamespace.MyType.MyMethod1(String,Int32,Int32,Boolean,String,Int32,Int32,Boolean,String,Int32,Int32,Boolean)", 
                   "MyNamespace.MyType.MyMethod2(String,Int32,Int32,Boolean,String,Int32,Int32,Boolean,String,Int32,Int32,Boolean)",
                   ...)
where 
  m.NbParameters > 5 
  orderby m.NbParameters descending
select new { m, m.NbParameters }

Notice that the rule body contains the method(s) to exclude full names. To get the method full name, just right click the method in the result and choose the menu Copy name to clipboard.

Exclude method from NDepend code rule result

Alternatively, if you wish to suppress a method from all rules results, you can use the JustMyCode/notmycode facility.

like image 150
Patrick from NDepend team Avatar answered Nov 09 '22 20:11

Patrick from NDepend team