cyclomatic-complexity

Code Analysis In Python

What tools are good to use for code analysis in python? I have a large source repository split across multiple projects, and I would like to be able to run tools across the directories to see details like Cyclomatic Complexity, and perhaps be able to spot errors using static analysis. Ideally, I would like to be able to produce a repor...

Calculate Cyclomatic Complexity for Javascript

Are there any tools available for calculating Cyclomatic Complexity in Javascript? I've found it a very helpful metric in the past while working on server side code, and would like to be able to use it for the client side Javascript I write. ...

Conditional logging with minimal cyclomatic complexity

After reading "What’s your/a good limit for cyclomatic complexity?", I realize many of my colleagues were quite annoyed with this new QA policy on our project: no more 10 cyclomatic complexity per function. Meaning: no more than 10 'if', 'else', 'try', 'catch' and other code workflow branching statement. Right. As I explained in 'Do you...

Seeking clarifications about structuring code to reduce cyclomatic complexity

Recently our company has started measuring the cyclomatic complexity (CC) of the functions in our code on a weekly basis, and reporting which functions have improved or worsened. So we have started paying a lot more attention to the CC of functions. I've read that CC could be informally calculated as 1 + the number of decision points i...

What is the best way to reduce cyclomatic complexity when validating data?

Right now I'm working on a web application that receives a significant amount of data from a database that has a potential to return null results. When going through the cyclomatic complexity for the application a number of functions are weighing in between 10 - 30. For the most part the majority of the functions with the high numbers ha...

How complex should code be?

I'm studying about algorithms which can help me write smaller but more complex code. Instead of writing 150 lines of if-else statements, I can design an algorithm that does it in 20 lines. The problem is a lot of these algorithms can be complex and require a lot of math to understand them. I'm also the only one around here who underst...

What is (or should be) the cyclomatic complexity of a virtual function call?

Cyclomatic Complexity provides a rough metric for how hard to understand a given function is, or how much potential for containing bugs it has. In the implementations I've read about, usually all of the basic control flow constructs (if, case, while, for, etc.) increase the complexity of a function by 1. It appears to me given that cyclo...

Does LINQ and Lambda expressions reduce Cyclomatic-complexity?

Does LINQ and Lambda expressions reduce cyclomatic-complexity? Just curious because CodeRush actually shows a reduction in cc when the VS analyzer increases it. ...

Automatic generation of Unit test cases for .NET and Java

Is there a good tool to generate unit test cases given say a .NET or Java project, it generates unit test cases that would cover an almost 100% code coverage. The number of test cases could be directly proportional to the cyclomatic complexity of the code (the higher the nesting of loops and conditions the higher the cyclomatic complexi...

Are there any tools that are able to do cyclomatics on Pro*C++ sources?

Are there any tools that are able to do code metrics on Pro*C++ sources? I haven't been able to find anything specific via Google. Does anyone have any experience with this? Thanks. ...

Do you find cyclomatic complexity a useful measure?

I've been playing around with measuring the cyclomatic complexity of a big code base. Cyclomatic complexity is the number of linearly independent paths through a program's source code and there are lots of free tools for your language of choice. The results are interesting but not surprising. That is, the parts I know to be the hairi...

Existing library to calculate code complexity of a block of code.

Hi all. I'm given a string which contains an arbitrary amount of code. I want to calculate a number which represents the code complexity of that string. Something like: int complexity = Lib.FindComplexity(someString); I realize there are a lot of tools out there that will do this for you. These tools will not work for me, because...

Best tool to determine code Cyclomatic complexity

Can people suggest the best tool to determine the cyclic complexity with in a C# winforms code base. ...

What is Cyclomatic Complexity?

A term that I see every now and then is "Cyclomatic Complexity". Here on SO I saw some Questions about "how to calculate the CC of Language X" or "How do I do Y with the minimum amount of CC", but I'm not sure I really understand what it is. On the NDepend Website, I saw an explanation that basically says "The number of decisions in a m...

What is the highest Cyclomatic Complexity of any function you maintain? And how would you go about refactoring it?

I was doing a little exploring of a legacy system I maintain, with NDepend (great tool check it out), the other day. My findings almost made me spray a mouthful of coffee all over my screen. The top 3 functions in this system ranked by descending cyclomatic complexity are: SomeAspNetGridControl.CreateChildControls (CC of 171!!!) SomeF...

Code Metrics Calculation in Visual Studio

What is the prefered score range for the code metrics calculation for the following Maintainability Index Cyclomatic Complexity Depth of Inheritance class Coupling ...

Cyclomatic complexity using jar files

Hi everyone, I am working on a project which requires me to find the cyclomatic complexity of Apache ant (Versions 1.1 through 1.6). I have been asked to use the jar files for this purpose. I used a couple of tools (Xdepend trial version and Cyvis ) to have a look at the results. Then i tried to validate the results with results from th...

Cyclomatic complexity of a code with multiple exit points

Hi all, How to find the cyclomatic complexity of a function with multiple exit points? The wiki page says p-s+2 where p is the number of decision points and s is the number of exit points. But should not more exit points increase the cyclomatic complexity as it may lead to more independent paths? Cheers, Aman ...

Common causes of Cyclomatic Complexity and their solutions

At work we are looking into common problems that lead to high cyclomatic complexity. For example, having a large if-else statement can lead to high cyclomatic complexity, but can be resolved by replacing conditionals with polymorphism. What other examples have you found? ...

Need to learn Cyclomatic Complexity - for beginner

Hi, I need to learn about cyclomatic complexity and how to calculate them for various kinds of statements such as IF, FOR, DO-While etc. Can you please provide me sole illustrative tutorial that has some examples of Calculating it Thanks in advance ...