(SLOC/LOC) Line of Code Counter

I needed a quick way to count the lines of code in a program, skipping empty lines and ignoring commented lines so I could get an estimate of how many lines of code a Library used (I have a current interest in SLOC and complexity). I searched online to find such a beast and was surprised that the only online Line of Code Counters I could find didn’t take comments or whitespace into account. Github does a nice job of this, but not every library I was interested in had their code in a single file. I figured how long could a SLOC counter take to write, and the answer was 11 minutes, so here it is, maybe you will find some use in it too:

Number of lines:

Comments