boyter / scc

Sloc, Cloc and Code: scc is a very fast accurate code counter with complexity calculations and COCOMO estimates written in pure Go
MIT License
6.28k stars 250 forks source link

scc includes the .ignore file as part of the project counting #423

Closed csrabak closed 2 months ago

csrabak commented 6 months ago

Unexpected behaviour

In a directory where a .ignore file is present, scc includes it as part of the project stats.

My experience

  1. In a project with 54 source files and the .ignore one to exclude no project files.
  2. Using the command scc --no-gen --no-cocomo -x i ./project
  3. scc output is:
───────────────────────────────────────────────────────────────────────────────
Language                 Files     Lines   Blanks  Comments     Code Complexity
───────────────────────────────────────────────────────────────────────────────
C                           54      8444      518      2483     5443        602
C Header                     1         1        0         1        0          0
ignore                       1        10        0         0       10          0
───────────────────────────────────────────────────────────────────────────────
Total                       56      8455      518      2484     5453        602
───────────────────────────────────────────────────────────────────────────────

Expected behavior

Language                 Files     Lines   Blanks  Comments     Code Complexity
───────────────────────────────────────────────────────────────────────────────
C                           54      8444      518      2483     5443        602
C Header                     1         1        0         1        0          0
───────────────────────────────────────────────────────────────────────────────
Total                       55      8445      518      2484     5443        602
───────────────────────────────────────────────────────────────────────────────

Desktop (please complete the following information):

boyter commented 5 months ago

Its funny... I added this as a way to assist with counting them since it was not common at the time, along with gitignore and hgignore files...

Perhaps it would be best to exclude them by default allowing people to opt in... either that or respect a dot file in the home directory or some such to change the behavior.

csrabak commented 5 months ago

Perhaps we can agree in a more specific name .scc_ignore and as you wrote, by default don't include it, except if in some organization the file be considered part of the deliverables that have to maintained or such, and so it would make sense in this case to opt in.

boyter commented 5 months ago

So I am going to implement support for a scc_ignore file soon, as some want specific behavior for counting itself. The reason for .ignore file support itself was due to wanting drop in compatibility with tools such as ripgrep and ag which support this file, and by extension visual studio code.

boyter commented 2 months ago

Done. This is now the default. If you want to count ignore files you must set the flag

--count-ignore                 set to allow .gitignore and .ignore files to be counted

so

scc --count-ignore

for ignore files to be counted.