Is there a package for calculating source code metrics?

Is there something like scc that allows to determine some code metrics for Julia in an easy, fire-and-forget kind of manner? What I’d be interested in is a tool that I can point at a directory, which it will recursively crawl for Julia files and break the line counts down to something like

  • # blank lines
  • # comment lines
  • # docstring lines
  • # code lines
  • # total lines

Of course, it would be interesting to also learn about things like number of docstrings, number of function/macro definitions etc. but that would just be the cherry on top :slight_smile:

2 Likes

Side note: scc seems to support Julia.

1 Like

They could probably use some improvements, though — their Julia code-complexity patterns include a switch statement that doesn’t exist and omit a lot of operators, for example.

Update: update Julia complexity checks by stevengj · Pull Request #366 · boyter/scc · GitHub

1 Like

I made a little experience and a && increases 2 complexity points whilst & increases 1!!!

Thanks for pointing this out! There are also more projects out there that support Julia, e.g., tokei. I was just wondering if there exists something similar in pure Julia that would allow to also get more Julia-specific information.

@sloede I had a look into this topic and tokei doesn’t look to report complexity. Did you try scc? A limitation I see is that it doesn’t report complexity by function. thanks

Yes, I’ve been using scc for the time being.

1 Like