cgag / loc

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

Incorrectly recognizing Prolog code as Perl #84

Open andrewnicolalde opened 6 years ago

andrewnicolalde commented 6 years ago

Working on a project in Prolog, which happens to share the same .pl file extension as Perl. Seems CLOC get's it.

https://i.imgur.com/nZ41e7l.png

boyter commented 5 years ago

@andrewnicolalde I don't suppose you could create a sample repository to replicate this?

andrewnicolalde commented 5 years ago

Let me see what I can do :)

andrewnicolalde commented 5 years ago

As the repository is coursework and I'm not allowed to make it public, could I just add you as a contributor to the repo?

boyter commented 5 years ago

@andrewnicolalde That would work for me.

boyter commented 5 years ago

So I had a look. The reason for this is that loc does not support multiple file extensions. However some tools such as scc (which I am the author of, polyglot and cloc do, but they also do not get this right.

$ loc
--------------------------------------------------------------------------------
 Language             Files        Lines        Blank      Comment         Code
--------------------------------------------------------------------------------
 Perl                     7          150           20            0          130
--------------------------------------------------------------------------------
 Total                    7          150           20            0          130
--------------------------------------------------------------------------------

$ scc
───────────────────────────────────────────────────────────────────────────────
Language                 Files     Lines     Code  Comments   Blanks Complexity
───────────────────────────────────────────────────────────────────────────────
Perl                         7       150      130         0       20          2
───────────────────────────────────────────────────────────────────────────────
Total                        7       150      130         0       20          2
───────────────────────────────────────────────────────────────────────────────
Estimated Cost to Develop $3,171
Estimated Schedule Effort 1.723298 months
Estimated People Required 0.217987
───────────────────────────────────────────────────────────────────────────────

$ gocloc .
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Perl                             7             20              0            130
-------------------------------------------------------------------------------
TOTAL                            7             20              0            130
-------------------------------------------------------------------------------

$ ~/polyglot .
-------------------------------------------------------------------------------
 Language             Files       Lines         Code     Comments       Blanks
-------------------------------------------------------------------------------
 Perl                     7         147          130            0           17
-------------------------------------------------------------------------------
 Total                    7         147          130            0           17
-------------------------------------------------------------------------------

       7 text files.
       7 unique files.
       0 files ignored.

http://cloc.sourceforge.net v 1.60  T=0.14 s (51.3 files/s, 1099.1 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Perl                             7             20              0            130
-------------------------------------------------------------------------------
SUM:                             7             20              0            130
-------------------------------------------------------------------------------

$ tokei
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------$
 Language                                                                                                                                                                 Files        Lines         Code     Comments       Blanks
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------$
 Perl                                                                                                                                                                         7          150          130            0           20
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------$
 Total                                                                                                                                                                        7          150          130            0           20
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------$

Most of the above assume that prolog files would have the extension p or pro. If you are able to supply a list of keywords that clearly identify a prolog file however I can add that into scc and I am use the polyglot author and cloc will do the same.