gojp / goreportcard

A report card for your Go application
https://goreportcard.com
Apache License 2.0
1.99k stars 252 forks source link

Specifying a directory with the CLI option -d does not work #407

Open geertjanvdk opened 1 year ago

geertjanvdk commented 1 year ago

The result when running the goreportcard-cli tool with the option -d is not as expected.

For example:

$ go run ./cmd/goreportcard-cli                   
2023/02/25 09:33:15 disabling ineffassign on large repo...
2023/02/25 09:33:15 disabling misspell on large repo...
Grade ........... A+ 98.1%
Files ................ 850
Issues ............... 140

The above correctly takes the current directory. It is the same as go run ./cmd/goreportcard-cli -d ..

However, when specifying the actual folder as ../goreportcard, it does not walk the tree correctly:

go run ./cmd/goreportcard-cli -d ../goreportcard
Grade ............ D 56.3%
Files ................. 38
Issues ............... 141

Note the number of issues, which is very similar.

I could not pinpoint where it fails in GoFiles-function, but it is probably better to actually change directory (using os.Chwd), and then use the current directory. Doing it that way works great.

Why I need this? Because I am preparing another PR and I wanted to add a test :)

texadactyl commented 8 months ago

It looks like check/check.go function Run and/or possibly check/utils.go function GoFiles are/is having some tree walking issues. Been in that sort of soup myself.