Skip to content

Running linters through gometalinter and golangci give out different results #619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
iccengan opened this issue Jul 19, 2019 · 11 comments
Closed
Labels
bug Something isn't working

Comments

@iccengan
Copy link

iccengan commented Jul 19, 2019

  1. Version:
golangci-lint --version
golangci-lint has version 1.17.1 built from 4ba2155 on 2019-06-10T09:06:49Z
  1. no config file
go version go1.12.6 linux/amd64
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/iccen/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/iccen/go_proj/test_proj"
GOPROXY=""
GORACE=""
GOROOT="/home/iccen/go"
GOTMPDIR=""
GOTOOLDIR="/home/iccen/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build132636320=/tmp/go-build -gno-record-gcc-switches"

Gometalinter command:
gometalinter ./... --enable-all --disable=govet --deadline=60m -j 2

Golangci-lint command:
golangci-lint run --enable-all --disable=govet --out-format=tab --deadline=60m --max-issues-per-linter=0 --max-same-issues=0 -j=2

I am recently comparing the results between golangci-lint(goll) and gometalinter(goml) since I am upgrading goml to goll shortly.
I found that results between the two runs are very different. For example:
Goml-golint outputs 2678 warnings while goll-golint only outpus 478. And 472 among goll-golint's warnings intersects with goml-golint's.
For some linters such as interfacer, errcheck and maligned, goll's result set does not even have any intersection with goml's.

(note: skipped dirs should not be the reason causing this issue, because some defective files which only appear in goml-unparam's result set appear in both goll-gochecknoinits's and goll-typecheck's)
(note: The number of warnings above does not include lll, gocyclo and dupl. I get rid of these three kinds of warning after I had the output)

@pierrre
Copy link
Contributor

pierrre commented Jul 23, 2019

You're using --enable-all.
Do gometalinter and golangci-lint have the same linters ?
No.

@alexkohler
Copy link

I think iccen8's point is that running linters like errcheck through gometalinter and golangci give out different results. This said, @iccen8, could you please give a concrete example with code and the commands run?

@iccengan
Copy link
Author

iccengan commented Jul 24, 2019

I think iccen8's point is that running linters like errcheck through gometalinter and golangci give out different results. This said, @iccen8, could you please give a concrete example with code and the commands run?

Yes, you have my point.

I have posted commands above:
Gometalinter command:
gometalinter ./... --enable-all --disable=govet --deadline=60m -j 2

Golangci-lint command:
golangci-lint run --enable-all --disable=govet --out-format=tab --deadline=60m --max-issues-per-linter=0 --max-same-issues=0 -j=2

Test code:
https://github.com/Tencent/bk-cmdb
(note: The downloaded source code should be placed into $GOPATH/src/configcenter)

The reason I disable govet is that govet is not running properly. Reference: #484

@iccengan iccengan changed the title Different Running linters through gometalinter and golangci give out different results Jul 24, 2019
@alexaandru
Copy link

I just tested on my end and indeed, for errcheck I get no output from golangci-lint but I do get output when I run errcheck directly:

$ golangci-lint run --build-tags development --disable-all -E errcheck --no-config ./...|wc -l
0
$ errcheck -tags development ./...|wc -l
18

@iccengan
Copy link
Author

I just tested on my end and indeed, for errcheck I get no output from golangci-lint but I do get output when I run errcheck directly:

$ golangci-lint run --build-tags development --disable-all -E errcheck --no-config ./...|wc -l
0
$ errcheck -tags development ./...|wc -l
18

Similar issue here #617

@pierrre
Copy link
Contributor

pierrre commented Jul 24, 2019

Can you try --exclude-use-default false ?

@alexaandru
Copy link

Yes, I can see all the issues if I add --exclude-use-default=false ! Thank you! :)

@pierrre
Copy link
Contributor

pierrre commented Jul 24, 2019

@alexaandru golangci-lint run --help and look at --exclude-use-default.

@iccengan
Copy link
Author

I just tested on my end and indeed, for errcheck I get no output from golangci-lint but I do get output when I run errcheck directly:

$ golangci-lint run --build-tags development --disable-all -E errcheck --no-config ./...|wc -l
0
$ errcheck -tags development ./...|wc -l
18

Similar issue here #617

@alexkohler @pierrre
Just noticed the two issues are not quite similar. You are comparing golangci-lint vs errcheck, but I am comparing golangci-lint vs golangci-lint ;/

@Helcaraxan
Copy link
Contributor

Helcaraxan commented Aug 7, 2019

Aside from the hypothetical answer I provided to #617 you need to take into account that gometalinter and golangci-lint do not run the same versions of the underlying linters.

  • gometalinter relies on the linter binaries being available (and you can thus determine the version of each linter), the gometalinter binary itself only contains the driver and error filtering logic.
  • golangci-lint vendors the various linters at a specific commit (which is upgraded from time-to-time) and the golangci-lint binary effectively contains those linters (as well as the configuration and error filtering logic).

The result is that:

  • Two people running the same version of gometalinter and the same config but with different versions of the underlying linters will likely get different error reports for the same code.
  • The same two people running the same version of golangci-lint and the same config will always get the same error reports.

@tpounds tpounds added the bug Something isn't working label Oct 3, 2019
@jirfag
Copy link
Contributor

jirfag commented Oct 15, 2019

  1. Different linters
  2. Different versions of linters
  3. Different exclude rules

It doesn’t make sense to compare them

@jirfag jirfag closed this as completed Oct 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants