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.58k stars 261 forks source link

--exclude-dir doesn't exclude directories #400

Closed shynur closed 5 months ago

shynur commented 1 year ago

To Reproduce

  1. ​git clone --recursive https://github.com/shynur/.emacs.d.git
  2. At branch (main), type scc --exclude-dir site-lisp/copilot.el/ site-lisp/lsp-bridge/

scc says there are many JSON files. But this is not true. JSON files exists only in those two excluded directories.

Desktop (please complete the following information):

boyter commented 1 year ago

You should use , as the separator for arguments, EG

scc --exclude-dir site-lisp/copilot.el/,site-lisp/lsp-bridge/

You might also want to consider using a .ignore file with those directories in there to assist with this.

Let me know if the , works as expected as I was able to achieve what you requested using that.

shynur commented 1 year ago

You should use , as the separator for arguments, EG

scc --exclude-dir site-lisp/copilot.el/,site-lisp/lsp-bridge/

I tried this

./scc --exclude-dir .git/,site-lisp/copilot.el/,site-lisp/lsp-bridge/

as well; the result was incorrect -- it included some JSON files (and other files that should have been excluded).

boyter commented 1 year ago

Would it be possible to craft a smaller test case I can use to replicate this? I will be happy to include it into the repository itself in order to validate this. I ask because the repository you linked I had some issues cloning.

I need to see the file you are expecting to not be included as well so I can verify the issue exactly. Please be more specific. The more specific the better.

shynur commented 1 year ago

a smaller test case

I've delete most files and upload the ZIP (3.38MB) here. The ZIP file includes scc-3.1.0.

After extract it, execute

./scc.exe --exclude-dir ".git/,site-lisp/copilot.el/,site-lisp/lsp-bridge/"

It is obviously that there is no JSON files, but scc doesn't think so.

boyter commented 5 months ago

Ah I know the issue here. Not a bug, but perhaps not what you expected.

Your use of the --exclude-dir is correct, but it does not work on full paths, only the top level. So in your example `site-lisp/lsp-bridge/" that matches nothing in the way it works.

If you replaced the / with , you should get the effect you want. Ideally use a .ignore file for this sort of thing though, as the intention of --exclude-dir was just to ignore directories from where you ran it not against paths, although thats something I should consider improving.