Scala source code metrics tool (lines of code, lines of comments and so on) [closed]
Asked Answered
A

2

6

There seems to be so many code analysis tools supporting the java language, but I am so far unable to find one that supports scala (something simple like finding LOC would be nice)? I'm working in intellij so have tried metricsReloaded and Static plugins, but they are completely ignoring the scala files.

Any suggestions would be appreciated.. :)

Edit: Metrics needed is just something like lines of code, lines of comment (% of comments), simple stuff like that

Edit: Thanks everyone, both answers were useful. :) I had to just choose an arbitrary "correct" answer (just gave it to the one with least votes up.

Aslam answered 27/1, 2014 at 20:59 Comment(2)
Be more specific what metrics are you looking for. Unit test coverage, style check, WTFs per second ...Faction
Cloc seems to work for Scala. I haven't verified its accuracy, but it knows the file extensions and gives reasonable counts.Polypus
J
9

I use cloc and it works just fine. It understands pretty much any language or script out there, it's easy to install - comes as a package on Linux, and easy to use. It can also output to multiple formats like csv, xml, yaml, sql, etc. Here is an example output of one of my projects:

# cloc .

    1145 text files.
     853 unique files.                                          
     937 files ignored.

http://cloc.sourceforge.net v 1.60  T=23.05 s (25.5 files/s, 8260.4 lines/s)
--------------------------------------------------------------------------------
Language                      files          blank        comment           code
--------------------------------------------------------------------------------
XML                             383            311             26         150875
Javascript                       18           2330            948           9904
Scala                           132           1689           1901           8029
CSS                               8           1266            163           7373
HTML                             23            459             91           2835
SQL                              11             11              5            877
XSLT                              1             30             16            468
Bourne Shell                      9             57            108            240
Perl                              1             57            102            227
Bourne Again Shell                1              2              0              3
DOS Batch                         1              0              0              2
--------------------------------------------------------------------------------
SUM:                            588           6212           3360         180833
--------------------------------------------------------------------------------
Jilljillana answered 28/1, 2014 at 0:20 Comment(0)
B
5

Although the examples are in Java, you really need to take a look at the aptly-named Metrics library by Coda Hale. And here is the Scala API for it. I think it will be exactly what you need. It even supports things like partial functions and Actors and Futures.

After seeing @Randall's comment and your edit, it is clear you are looking for static analysis tools rather than what I consider "metrics." My bad. To that end, I suggest you take a look at Scalastyle, which is much better than Gangnam Style and is analogous to CheckStyle in Java. You should also look at cpd4sbt (analogous to PMD) and FindBugs (analogous to, well, FindBugs) despite the commonly reported false positives.

Blameless answered 27/1, 2014 at 23:4 Comment(2)
I cannot interpret the question as one about execution metrics.Polypus
Thanks to you and the OP for clarifying. Edit made.Blameless

© 2022 - 2024 — McMap. All rights reserved.