Measuring Code Complexity


#1

One of my teams wants to bring into their metrics arsenal cyclomatic complexity aka McCabe’s number.

Looking for recommendations on tools to use? Framework is Angular.js

Had a quick look at code climate. Not sufficient.

Paid / open source, doesn’t matter either way.

Thoughts?


#2

Great question! There are a lot of tools available for this and it’s very dependent your needs and technology/language used. Here are a couple questions I think are helpful to ask before looking for tools.

1.) Do you need something to give feedback on the dev’s local PC (inside their IDE) or based on the CI build process?
2.) Do you need to see historical results and trend reports?

A general tool my team and I use which supports multiple languages and technology stacks is SonarQube, https://www.sonarqube.org. We currently use it to aggregate static analysis, unit test, and code coverage results on each build for multiple C#, HTML, JavaScript, and CSS applications.


#3

Thanks @christoph

Current Framework is angular.js

Our primary use case is feedback based on CI build
Results inside IDE is a nice to have
Historical results/trend reports a must have.

I’ll check out sonarqube.


#4

Which version would of angular there are multiple now :frowning:


#5

want to get to ng2 this year
not there yet…

currently running whatever the latest v1 is, i think 1.59 or 1.6


#6

If possible, you might want to reframe the priorities so the IDE integration is higher. It’s the level-0 feedback loop for the developer. While the CI feedback loop is good, the bad code is already written, context has shifted and waste is in the system. Building quality in from the IDE is more important that catching issues after the fact in my opinion.


#7

Interesting and though provoking as always @ryan

Does the focus shift depending on if it’s fresh code or legacy code?


#8

Focus? Not in my opinion.
The developers agility in the code is surely hindered with the legacy code though.

The focus should be on building quality in at all levels. Detecting defects after the face is a pretty big anti-pattern I try to eliminate wherever feasible.