# Is there a package for calculating source code metrics?

**URL:** <https://discourse.julialang.org/t/is-there-a-package-for-calculating-source-code-metrics/63283>\
**Category:** General Usage\
**Created:** [June 21, 2021, 9:09am UTC](https://discourse.julialang.org/t/is-there-a-package-for-calculating-source-code-metrics/63283 "2021-06-21T09:09:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sloede](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sloede/32/44787_2.png) [@sloede](https://discourse.julialang.org/u/sloede)\
**Post date:** [June 21, 2021, 9:09am UTC](https://discourse.julialang.org/t/is-there-a-package-for-calculating-source-code-metrics/63283/1 "2021-06-21T09:09:44Z")

</div>

Is there something like [scc](https://github.com/boyter/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 🙂

---

<div class="post-metadata">

**Author:** ![ranocha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ranocha/32/35588_2.png) [@ranocha](https://discourse.julialang.org/u/ranocha)\
**Post date:** [June 21, 2021, 11:39am UTC](https://discourse.julialang.org/t/is-there-a-package-for-calculating-source-code-metrics/63283/2 "2021-06-21T11:39:16Z")

</div>

Side note: `scc` seems to [support Julia](https://github.com/boyter/scc/blame/master/LANGUAGES.md#L116).

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [June 21, 2021, 12:41pm UTC](https://discourse.julialang.org/t/is-there-a-package-for-calculating-source-code-metrics/63283/3 "2021-06-21T12:41:55Z")

</div>

> [@ranocha](#):
>
> Side note: `scc` seems to [support Julia](https://github.com/boyter/scc/blame/master/LANGUAGES.md#L116).

They could probably use some improvements, though — their [Julia code-complexity patterns](https://github.com/boyter/scc/blob/61304326e1d6a6dcfe0cd29d1a3e86d0403a3b0d/languages.json#L3185-L3222) 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](https://github.com/boyter/scc/pull/366)

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [June 21, 2021, 12:59pm UTC](https://discourse.julialang.org/t/is-there-a-package-for-calculating-source-code-metrics/63283/4 "2021-06-21T12:59:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sloede](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sloede/32/44787_2.png) [@sloede](https://discourse.julialang.org/u/sloede)\
**Post date:** [June 22, 2021, 7:54am UTC](https://discourse.julialang.org/t/is-there-a-package-for-calculating-source-code-metrics/63283/5 "2021-06-22T07:54:42Z")

</div>

Thanks for pointing this out! There are also more projects out there that support Julia, e.g., [tokei](https://github.com/XAMPPRocky/tokei). I was just wondering if there exists something similar in pure Julia that would allow to also get more Julia-specific information.

---

<div class="post-metadata">

**Author:** ![dpinol](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpinol/32/26550_2.png) [@dpinol](https://discourse.julialang.org/u/dpinol)\
**Post date:** [January 9, 2023, 1:09pm UTC](https://discourse.julialang.org/t/is-there-a-package-for-calculating-source-code-metrics/63283/6 "2023-01-09T13:09:19Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![sloede](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sloede/32/44787_2.png) [@sloede](https://discourse.julialang.org/u/sloede)\
**Post date:** [January 9, 2023, 1:25pm UTC](https://discourse.julialang.org/t/is-there-a-package-for-calculating-source-code-metrics/63283/7 "2023-01-09T13:25:41Z")

</div>

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