Tagged Questions

Cyclomatic complexity is a number used to express the complexity of source code (e.g. of a method). It is calculated based on the number of different possible paths through the source code. A low cyclomatic complexity is one factor to improve readability, maintainability and testability of code.

Their wiki only says the obvious (average complexity of the class), but what does it actually mean? I know for method complexity, 15-20 is usually the upper bound for a testable and maintainable code. ...

I like to work with unittests and I think they help me alot.
I use dotcover to analyze my coverage but as you know code coverage is not everything but I think it's still a vital tool.
Right now I'm ...

I have got 5 different sources of data(request, lsitCC, listSEDI, listSEDIFees and XMLRoot loaded into respective C# Array list objects). I need to construct a JSON request by combining the data from ...

So pretty much I was taught to work out the cyclomatic complexity like this site does
But then recently I found this thing that says Cyclomatic Complexity = ( 1 + ifs + loops + cases ). Are they the ...

Assume a method chooses an action depending on a value from a fairly large enum.
Our Sonar now complains about a high cyclomatic complexity (of about the number of case statements, naturally) of this ...

I have this below mentioned code and I need to draw a McCabe flow graph of this. I know how to draw a McCabe flow graph for a single method. But How can I draw a graph for a code set having multiple ...

I want a tool to analyse my code quality and after a bit of googling I think I understand that Cyclomatic Complexity could be something to start with here. I have tried to get several tools working ...

This question: Custom threshold for CA1502
discusses how to set up custom thresholds for code metrics rules in code analysis.
I have the same problem, but think that the old question is out of date.
...

Sonar gives a major violation error ("Cyclomatic Complexity") for the following code.Following method is used to get the date in a special format .eg :-14-02-3 (Year-month-weekid).What are the steps ...

I found this site claiming that Cyclomatic Complexity = ( 2 + ifs + loops +cases - return ) and I also found out that Cyclomatic Complexity can be calculate by the number of conditional statement + 1 ...

I'm trying to understand how Cyclomatic Complexity works and how I can avoid the warnings. Yes, I understand that the goal of writing code is not to avoid arbitrary warnings, but I'd at least like to ...

I want to start measuring what Michael Feathers has referred to as the turbulence of code, namely churn vs. complexity.
To do this, I need to measure the complexity of a C++ or Java file. So I found ...

i am trying to calculate the cyclomatic complexity of my software but i am a bit confused. From what i understand it is the amounts of paths that are needed to be tested to cover the whole software. ...

Whenever I lint a piece of code I'm working on I get the This function's cyclomatic complexity is too high. (7). But I'm a bit confused on how I could rewrite it in such way so it works.
This would ...

The following java code gives a rather high Cyclomatic Complexity. I would like to find a way to properly reduce it. How would I best do this?
To be clear, the code gets the corresponding result of a ...

I'm working on a class which sends a RequestDTO to a Web Service. I need to validate the request before it is sent.
The request can be sent from 3 different places and there are different validation ...