cgag / loc

Count lines of code quickly.
MIT License
2.32k stars 125 forks source link

`loc` considers files with full name as extension as part of a given language #115

Closed justanotherdot closed 1 year ago

justanotherdot commented 5 years ago

Hi, thanks for the great tool!

Looks like loc won't check for a leading . when inferring a language; is this on purpose? e.g.

$ cd /tmp
$ mkdir loc_test
$ cd loc_test
$ echo "ahhhhhhh" >  rs
$ touch go
$ loc
--------------------------------------------------------------------------------
 Language             Files        Lines        Blank      Comment         Code
--------------------------------------------------------------------------------
 Rust                     1            1            0            0            1
 Go                       1            0            0            0            0
--------------------------------------------------------------------------------
 Total                    2            1            0            0            1
--------------------------------------------------------------------------------

In my own experience this confuses loc when you have scripts that share the name of suffixes.

justanotherdot commented 5 years ago

I had a poke around and it seems like we could simply return Unrecognized instead of setting ext to the full filename, which will work for the cases I mentioned above. Would this be an acceptable change?

cgag commented 5 years ago

I'd have to look at it again but I believe that was a hack to make it work for files we want to count that don't have extensions, which might just be makefiles.

justanotherdot commented 5 years ago

I just raised #116 which seems to work for me. It would seem the lines above take care of cmake, makefiles, etc. unless there are other file formats that still need this suffix-as-file-type approach that I'm not considering?