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.8k stars 267 forks source link

--exclude-dir not working ? #549

Closed janpfeifer closed 4 weeks ago

janpfeifer commented 1 month ago

Describe the bug I added a directory in --exclude-dir and it is still including the file in the output.

See line here, where internal/protos directory is not excluded:

$ scc --exclude-dir=internal/protos --by-file
───────────────────────────────────────────────────────────────────────────────
Language                 Files     Lines   Blanks  Comments     Code Complexity
───────────────────────────────────────────────────────────────────────────────
Go                          15      5000      531       793     3676        537
───────────────────────────────────────────────────────────────────────────────
internal/protos/onnx-ml.pb.go       3208      345       522     2341        316
~ternal/protos/onnx-data.pb.go       613       69        79      465         52
~rotos/onnx-operators-ml.pb.go       375       38        85      252         36
onnx/graph.go                        185       14        36      135         31
onnx/prettyprint.go                  138       14        10      114         35
~md/protoc_onnx_protos/main.go       113       16        21       76          9
onnx/dynamicshape.go                 105        7        11       87         25
onnx/onnx.go                          81        8        14       59         12
onnx/dynamicshape_test.go             51        7         5       39          0
internal/togomlx/tensor.go            45        3         2       40         16
internal/togomlx/dtypes.go            42        2         2       38          1
onnx/linear_test.go                   22        4         1       17          0
onnx/ops.go                           17        3         3       11          4
internal/protos/protos.go              4        1         2        1          0
internal/togomlx/model.go              1        0         0        1          0
───────────────────────────────────────────────────────────────────────────────
Protocol Buffers             3      1186      190       691      305          0
───────────────────────────────────────────────────────────────────────────────
internal/protos/onnx-ml.proto        895      132       524      239          0
~ternal/protos/onnx-data.proto       155       36        74       45          0
~rotos/onnx-operators-ml.proto       136       22        93       21          0
───────────────────────────────────────────────────────────────────────────────
Jupyter                      2       705        0         0      705          0
───────────────────────────────────────────────────────────────────────────────
onnx-py.ipynb                        362        0         0      362          0
onnx-go.ipynb                        343        0         0      343          0
───────────────────────────────────────────────────────────────────────────────
Markdown                     2        20        7         0       13          0
───────────────────────────────────────────────────────────────────────────────
internal/protos/README.md             11        4         0        7          0
README.md                              9        3         0        6          0
───────────────────────────────────────────────────────────────────────────────
License                      1       201       32         0      169          0
───────────────────────────────────────────────────────────────────────────────
LICENSE                              201       32         0      169          0
───────────────────────────────────────────────────────────────────────────────
Total                       23      7112      760      1484     4868        537
───────────────────────────────────────────────────────────────────────────────
Estimated Cost to Develop (organic) $142,335
Estimated Schedule Effort (organic) 6.56 months
Estimated People Required (organic) 1.93
───────────────────────────────────────────────────────────────────────────────
Processed 290059 bytes, 0.290 megabytes (SI)
───────────────────────────────────────────────────────────────────────────────

Expected behavior Files in the directories marked by --exclude-dir should have been excluded.

Desktop (please complete the following information):

$ uname -a
Linux galactica 6.8.0-47-generic #47-Ubuntu SMP PREEMPT_DYNAMIC Fri Sep 27 21:40:26 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
$ scc --version
scc version 3.4.0

Thank you! 😃

ps. : Apologies in advance if I'm doing something wrong, it's the first time I'm using the tool. But I did read the --help of the flag, so if anything maybe whatever I'm doing wrong could be included in the documentation ?

janpfeifer commented 1 month ago

I installed the most recent version (go install github.com/boyter/scc@master), and with that version, the --exclude-dir works as I would expect it.

boyter commented 1 month ago

Seems you ran into the bug I introduced when I moved over to the new file walker where I forgot to add in exclude directory. As you discovered fixed in a later version.

You might also want to consider adding a .ignore or .sccignore file to avoid you having to set this via the command line each time.

janpfeifer commented 1 month ago

Many thanks @boyter !

I'll let you close the issue when you think appropriate (when the fix is released depending how you are managing it?)

janpfeifer commented 1 month ago

Btw, .sccignore (it makes more sense than .ignore) is not working for now (?)

But .ignore works, so I'm using that for now.

boyter commented 4 weeks ago

@janpfeifer so the .ignore is there in case you want to have the same rules applied to tools such as ag and rg, but for those cases where you don't want that .sccignore works well too.

Going to close as the fix has been pushed out in the latest versions so hopefully nobody runs into this again. Thanks for responding back, it helps with knowing if these are save to close.