NPath Difficulty

In this line:

public Map getAll(BusinessTargetPK pkBusinessTargetId) throws Exception 

I get this error:

NPath Difficulty - 32,768 (maximum allowable - 200)

And in this line:

 public Map getAll( Long RLE_ROLE_ID ) throws Exception { 

I get this error:

The getAll () method has complexity NPath 2048

I am completely unaware of what NPath Complexity is and what it means.

Can someone give some advice on how to avoid this type of error?

+6
source share
2 answers

This link: https://modess.io/npath-complexity-cyclomatic-complexity-explained/

explains it very well:

The complexity of the NPath method is the number of acyclic paths to execute this method.

This means that you should avoid long functions with lots of (nested) if / else statements.

So my advice is:

  • Divide your functions into smaller ones.
  • Eliminate useless if / else-statements where possible.
+12
source

This is an old thread, and Wolverine789 probably guessed the answer, but for those who still find this thread in Google search results, I found the following Niklas Modess error description:

https://modess.io/npath-complexity-cyclomatic-complexity-explained/

+1
source

Source: https://habr.com/ru/post/972011/


All Articles