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

孤者浪人 提交于 2019-12-03 00:35:30

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
--------------------------------------------------------------------------------
Vidya

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!