Enhancing the Cyclomatic Complexity check

53 views
Skip to first unread message

Brian

unread,
May 3, 2012, 1:55:14 PM5/3/12
to Scalastyle users
I just found this group after starting to work on my similar project
(which I'm now stopping given how far along this project is).

I was wondering if you had plans to enhance the Cyclomatic Complexity
check and if so in what direction(s)? The Boston Scala Enthusiasts
group has had a number of discussions about how to measure complexity
in functional languages.

I'd like to contribute in this area but want to run in the same
direction you were planning (if you had any plans in this regard).
The current check counts the number of IF,CASE,WHILE,DO,FOR and &&, ||
tokens. Have you given any thought to taking it to the next level and
distinguishing complexity within those statements? For loops/
comprehensions in particular seem to have an enormous range of
potential complexity.

Thanks.

Matthew Farwell

unread,
May 5, 2012, 4:27:54 PM5/5/12
to scalasty...@googlegroups.com
Any work on the complexity rules would be very welcome, since it's not
really my area of expertise.

The cyclomatic complexity rules that I've implemented are almost
straight copies from the Checkstyle ones, so the metric applies to
Scala but isn't necessarily relevant. There are also a few anomalies
such as the filter() methods which have implicit ifs in them, so the
theoretical complexity of the method goes up, but doesn't show up in
the figure. However, you can write java in such a way as to have the
same anomalies, so I'm not so worried about that.

So, my view (at the minute) is that the Cyclomatic complexity check as
implemented should probably stay as it is, but if you want to do
another complexity check based upon other criteria, more specific to
functional type languages, why not?

As I say, I'm not really an expert of metrics, and certainly not for
functional languages, so any input is gratefully received.

Matthew Farwell.

2012/5/3 Brian <brian...@gmail.com>:

Matt Russell

unread,
May 10, 2012, 2:36:54 PM5/10/12
to scalasty...@googlegroups.com
See also Felix Mueller's work on the Sonar Scala plug-in:

Matthew Farwell

unread,
May 13, 2012, 12:52:26 PM5/13/12
to scalasty...@googlegroups.com
Thanks Matt, I didn't actually know there was a Sonar plugin started, that was on my list of things to do. I've email Felix, and we'll see how we get on.

Matthew Farwell.
Reply all
Reply to author
Forward
0 new messages