Golangci-lint: golint errors are not being reported

Created on 6 Nov 2019  路  4Comments  路  Source: golangci/golangci-lint

Given the following simple example: https://gist.github.com/bacongobbler/223b2287b49d59bb3e672a26c0ebf3c0

package main

import "fmt"

type Person struct {
        Name string
}

func main() {
        p := &Person{Name: "Matthew Fisher"}

        fmt.Println(p.Name)
}

golangci-lint does not report a linter error with the package comment, even with the golint linter explicitly enabled. Explicitly calling golint reports the correct error.

><> golangci-lint run --disable-all -E golint main.go 
><> golint main.go 
main.go:5:6: exported type Person should have comment or be unexported

Tested with all of the most recent releases since the last year, and all revisions of golangci-lint don't appear to report this issue either:

><> for version in 1.21.0 1.20.1 1.19.1 1.18.0 1.17.1 1.16.0 1.15.0; do curl -sSL https://github.com/golangci/golangci-lint/releases/download/v$version/golangci-lint-$version-linux-amd64.tar.gz | tar xz; ./golangci-lint-$version-linux-amd64/golangci-lint run --disable-all -E golint main.go; done
><> echo $?
0

Tested with the latest Go version and golangci-lint versions.

><> go version
go version go1.13.3 linux/amd64
><> golangci-lint --version
golangci-lint has version 1.21.0 built from 645e794 on 2019-10-15T18:16:56Z

Is there a feature flag I'm missing that has to be enabled to make golangci-lint check for these missing package comments?

related: #464

false negative won't fix

Most helpful comment

The excluded strings calls this out as being disabled by default:

$ golangci-lint run --help

-e, --exclude strings                Exclude issue by regexp
      --exclude-use-default            Use or not use default excludes:
                                         # golint: Annoying issue about not having a comment. The rare codebase has such comments
                                         - (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)                                       

Using the cli flag exclude-use-default=false disabled the filter, and the comments are correctly reported now:

golangci-lint run --enable golint --exclude-use-default=false

server/hashable.go:7:1: exported method `Hashable.ID` should have comment or be unexported (golint)
func (h Hashable) ID(node *core.Node) string {

Would still like these to be enabled by default but at least you can override locally :)

All 4 comments

Same for me - golint does not report with all other disabled.

The excluded strings calls this out as being disabled by default:

$ golangci-lint run --help

-e, --exclude strings                Exclude issue by regexp
      --exclude-use-default            Use or not use default excludes:
                                         # golint: Annoying issue about not having a comment. The rare codebase has such comments
                                         - (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)                                       

Using the cli flag exclude-use-default=false disabled the filter, and the comments are correctly reported now:

golangci-lint run --enable golint --exclude-use-default=false

server/hashable.go:7:1: exported method `Hashable.ID` should have comment or be unexported (golint)
func (h Hashable) ID(node *core.Node) string {

Would still like these to be enabled by default but at least you can override locally :)

hi,
closing, because you can use --exclude-use-default=false

Slightly confused -- certain lint rules are turned off by default and override explicit configuration?

Was this page helpful?
0 / 5 - 0 ratings