Hi,
I want to do some statistics on code metrics. I am interested in "How many methods of my project are in a range less than 5 Lines of code, how many methods are in a range of 5 to 20 lines of code, ... and so on."
I implemented the "range as follows"
class StatisticMetricCallable extends MetricCallable {
string lineNumberRange() {
result = "< 5" and this.getNumberOfLines() < 5 or
result = "5-20" and (this.getNumberOfLines() > 4 and this.getNumberOfLines() < 21) or
result = "21-50" and (this.getNumberOfLines() > 20 and this.getNumberOfLines() < 51) or
result = "51-200" and (this.getNumberOfLines() > 50 and this.getNumberOfLines() < 201) or
result = "201-500" and (this.getNumberOfLines() > 200 and this.getNumberOfLines() < 501) or
result = "> 500" and (this.getNumberOfLines() > 500)
}
}
from StatisticMetricCallable c, int n, string range
where c.fromSource()
and n = c.getNumberOfLines()
and range = c.lineNumberRange()
and not(c.hasName("<clinit>"))
and c instanceof Method
select c.getDeclaringType().getPackage().getName() as Package,
c.getDeclaringType().getName() as Class,
c as Method, n as NumberOfLines, range
order by range asc, NumberOfLines desc
I receive a list with all method's, there range and lines of code. But i want to get a table like this
RANGE COUNT
< 5 236
5 - 20 98
21 - 50 46
51 - 200 16
201 - 500 1
> 500 0
Is there soemthing like "group by" in .QL - or can I get this result in another way?
Thanks for help and regards
Klaus