Giter Site home page Giter Site logo

golangci / golangci-lint Goto Github PK

View Code? Open in Web Editor NEW
14.5K 95.0 1.3K 42.56 MB

Fast linters Runner for Go

Home Page: https://golangci-lint.run

License: GNU General Public License v3.0

Go 98.32% Makefile 0.30% Dockerfile 0.12% Shell 1.25%
go golang linter ci golangci-lint

golangci-lint's Introduction

If you are looking for golangci-lint please go to https://github.com/golangci/golangci-lint

THIS REPOSITORY IS ARCHIVED.

GolangCI

GolangCI is an automated golang codereview tool.

This repository contains the central issue tracker for the GolangCI project.

Other repositories

GolangCI consists of sub-projects. The main ones are:

golangci-api

golangci-api is the Golang server with REST API for golangci-web.

golangci-web

golangci-web is a frontend of golangci.com. It uses React, Redux, Typescript, Webpack.

golib

golib is a small Golang HTTP framework. It's used in golangci-api.

golangci-worker

golangci-worker is the queue worker. When user creates or updates GitHub pull request, golangci-api gets webhook event about it. Then it send this event to distributed queue. golangci-worker handles such queue events and runs code analysis.

Issues, Features

Create issue in central issue tracker. Also you can create issue in one of subprojects repo if you know which one you need.

Contact email is [email protected].

golangci-lint's People

Contributors

alexandear avatar antonboom avatar ashanbrown avatar blizzy78 avatar bombsimon avatar butuzov avatar daixiang0 avatar denis-tingaikin avatar dependabot-preview[bot] avatar dependabot[bot] avatar ernado avatar golangci-releaser avatar golangcidev avatar iwankgb avatar jirfag avatar ldez avatar maratori avatar nishanths avatar nunnatsa avatar renovate[bot] avatar ryancurrah avatar sanposhiho avatar sashamelentyev avatar sayboras avatar scop avatar sebastien-rosset avatar sivchari avatar tmzane avatar tpounds avatar viktorasm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

golangci-lint's Issues

"No issues were found" even with an blank file

Steps to reproduce:

  • cd /tmp
  • touch blank.go
  • then run golangci-lint run -v blank.go:
INFO[0000] Active linters: [deadcode govet errcheck megacheck gas varcheck ineffassign structcheck]
INFO[0000] Found paths for analysis for 56.244µs: [blank.go]
/tmp/blank.go:1:1: expected 'package', found 'EOF'
INFO[0000] Program loading took 3.005445ms
INFO[0000] SSA repr building took 7.026µs
INFO[0000] worker.3 took 1.807229ms with stages: errcheck: 924.983µs, ineffassign: 846.136µs, varcheck: 14.522µs, structcheck: 5.831µs, deadcode: 3.545µs
INFO[0000] worker.4 took 1.854175ms with stages: govet: 1.845642ms
INFO[0000] Panic stack trace: goroutine 38 [running]:
runtime/debug.Stack(0x17d70b6, 0x11, 0xc42042f7c8)
        /usr/local/Cellar/go/1.10.1/libexec/src/runtime/debug/stack.go:24 +0xa7
github.com/golangci/golangci-lint/pkg.runLinterSafe.func1(0xc42042fd10)
        /Users/quanta/go/src/github.com/golangci/golangci-lint/pkg/runner.go:34 +0xc2
panic(0x16ee1a0, 0x1c8efa0)
        /usr/local/Cellar/go/1.10.1/libexec/src/runtime/panic.go:502 +0x229
go/token.(*File).Name(...)
        /usr/local/Cellar/go/1.10.1/libexec/src/go/token/position.go:105
github.com/golangci/golangci-lint/vendor/github.com/GoASTScanner/gas.(*Analyzer).ProcessProgram(0xc420104230, 0xc4200c4080)
        /Users/quanta/go/src/github.com/golangci/golangci-lint/vendor/github.com/GoASTScanner/gas/analyzer.go:148 +0x16d
github.com/golangci/golangci-lint/pkg/golinters.Gas.Run(0x188a280, 0xc42013e840, 0xc4200fee10, 0x102a909, 0x8, 0xc420106200, 0x2, 0xc42013cc80)
        /Users/quanta/go/src/github.com/golangci/golangci-lint/pkg/golinters/gas.go:34 +0x1c3
github.com/golangci/golangci-lint/pkg.runLinterSafe(0x188a280, 0xc42013e840, 0xc4200fee10, 0x18892c0, 0x1cc0a20, 0x0, 0x0, 0x0, 0x1881020, 0xc42041e3a0)
        /Users/quanta/go/src/github.com/golangci/golangci-lint/pkg/runner.go:38 +0x9f
github.com/golangci/golangci-lint/pkg.runWorker.func1()
        /Users/quanta/go/src/github.com/golangci/golangci-lint/pkg/runner.go:61 +0x64
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc420106040, 0x17beda2, 0x3, 0xc42013ce60)
        /Users/quanta/go/src/github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:73 +0x53
github.com/golangci/golangci-lint/pkg.runWorker(0x188a280, 0xc42013e840, 0xc4200fee10, 0xc4201a4d80, 0xc4201a4de0, 0xc4204c2008, 0x8)
        /Users/quanta/go/src/github.com/golangci/golangci-lint/pkg/runner.go:60 +0x185
github.com/golangci/golangci-lint/pkg.(*SimpleRunner).runWorkers.func1(0xc420369450, 0x188a280, 0xc42013e840, 0xc4200fee10, 0xc4201a4d80, 0xc4201a4de0, 0xc4201a4e40, 0x4, 0x4, 0x0)
        /Users/quanta/go/src/github.com/golangci/golangci-lint/pkg/runner.go:118 +0x117
created by github.com/golangci/golangci-lint/pkg.(*SimpleRunner).runWorkers
        /Users/quanta/go/src/github.com/golangci/golangci-lint/pkg/runner.go:115 +0x1e6

INFO[0000] worker.1 took 6.643812ms with stages: gas: 6.461126ms
INFO[0000] Can't run linter gas: panic occured: runtime error: invalid memory address or nil pointer dereference
INFO[0000] worker.2 took 15.14121ms with stages: megacheck: 15.117582ms
INFO[0000] Workers idle times: #1: 8.572497ms, #3: 13.38068ms, #4: 13.37371ms
INFO[0000] processing took 167.02µs with stages: max_same_issues: 163.107µs, max_from_linter: 1.24µs, path_prettifier: 970ns, diff: 838ns, exclude: 452ns, cgo: 246ns, max_per_file_from_linter: 67ns, uniq_by_line: 51ns, nolint: 49ns
Congrats! No issues were found.
INFO[0000] Extracting issued lines took 0s
INFO[0000] Memory: 1 samples, avg is 15.3MB, max is 15.3MB
INFO[0000] Execution took 21.079892ms

Shouldn't "/tmp/blank.go:1:1: expected 'package', found 'EOF'" be considered as an issue?

Can't run linter megacheck: panic occured

golangci-lint run -v:

INFO[0000] Active linters: [megacheck govet errcheck structcheck ineffassign varcheck deadcode gas]
INFO[0000] Found paths for analysis for 459.186µs: [. ./cmd ./cmd/load ./lib ./models]
INFO[0008] Program loading took 8.768935722s
INFO[0011] SSA repr building took 3.050474608s
INFO[0012] worker.4 took 4.286801ms with stages: ineffassign: 3.145384ms, errcheck: 346.462µs, deadcode: 260.268µs, structcheck: 230.44µs
INFO[0012] worker.1 took 4.653629ms with stages: gas: 3.904082ms, varcheck: 674.395µs
INFO[0012] worker.2 took 158.615506ms with stages: govet: 158.552628ms
INFO[0017] Panic stack trace: goroutine 2263 [running]:
runtime/debug.Stack(0x17d70b6, 0x11, 0xc444064908)
        /usr/local/Cellar/go/1.10.1/libexec/src/runtime/debug/stack.go:24 +0xa7
github.com/golangci/golangci-lint/pkg.runLinterSafe.func1(0xc444065d10)
        /Users/quanta/go/src/github.com/golangci/golangci-lint/pkg/runner.go:34 +0xc2
panic(0x16daac0, 0xc474fca170)
        /usr/local/Cellar/go/1.10.1/libexec/src/runtime/panic.go:502 +0x229
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint.(*Linter).Lint(0xc444065688, 0xc42019c180, 0xc420154420, 0xc44f004be0, 0x1743580, 0x1c135e0, 0xc44fda96a8)
        /Users/quanta/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lint.go:446 +0x2e7c
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lintutil.(*runner).lint(0xc44fda97c0, 0xc42019c180, 0xc420154420, 0xc44f004be0, 0x0, 0x0, 0x0)
        /Users/quanta/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lintutil/util.go:292 +0xc8
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lintutil.Lint(0xc45afa2240, 0x3, 0x4, 0xc42019c180, 0xc420154420, 0xc44f004be0, 0xc444065928, 0x4, 0xc44fda9900, 0x1011ff9, ...)
        /Users/quanta/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lintutil/util.go:248 +0x1f5
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lintutil.ProcessFlagSet(0xc45af2e6c0, 0x3, 0x4, 0xc45af2e660, 0xc42019c180, 0xc420154420, 0xc44f004be0, 0x4, 0x2, 0xc452b83780)
        /Users/quanta/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lintutil/util.go:203 +0x615
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/cmd/megacheck.Run(0xc42019c180, 0xc420154420, 0xc44f004be0, 0x1010101, 0xc44a603360, 0xc44193ef78, 0x1890ec0)
        /Users/quanta/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/cmd/megacheck/megacheck.go:124 +0x74a
github.com/golangci/golangci-lint/pkg/golinters.Megacheck.Run(0x10101, 0x188a280, 0xc4201a11a0, 0xc45af23800, 0x102a909, 0x8, 0xc432861bc0, 0x2, 0xc420057480)
        /Users/quanta/go/src/github.com/golangci/golangci-lint/pkg/golinters/megacheck.go:42 +0x7d
github.com/golangci/golangci-lint/pkg.runLinterSafe(0x188a280, 0xc4201a11a0, 0xc45af23800, 0x1889500, 0xc42078e445, 0x0, 0x0, 0x0,0x1881020, 0xc474f8d2e0)
        /Users/quanta/go/src/github.com/golangci/golangci-lint/pkg/runner.go:38 +0x9f
github.com/golangci/golangci-lint/pkg.runWorker.func1()
        /Users/quanta/go/src/github.com/golangci/golangci-lint/pkg/runner.go:61 +0x64
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc44856bc40, 0x17c4e96, 0x9, 0xc420057660)
        /Users/quanta/go/src/github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:73 +0x53
github.com/golangci/golangci-lint/pkg.runWorker(0x188a280, 0xc4201a11a0, 0xc45af23800, 0xc44854bf80, 0xc45af2e4e0, 0xc438359b28, 0x8)
        /Users/quanta/go/src/github.com/golangci/golangci-lint/pkg/runner.go:60 +0x185
github.com/golangci/golangci-lint/pkg.(*SimpleRunner).runWorkers.func1(0xc438359ac0, 0x188a280, 0xc4201a11a0, 0xc45af23800, 0xc44854bf80, 0xc45af2e4e0, 0xc45af2e540, 0x4, 0x4, 0x2)
        /Users/quanta/go/src/github.com/golangci/golangci-lint/pkg/runner.go:118 +0x117
created by github.com/golangci/golangci-lint/pkg.(*SimpleRunner).runWorkers
        /Users/quanta/go/src/github.com/golangci/golangci-lint/pkg/runner.go:115 +0x1e6

INFO[0017] worker.3 took 5.245747545s with stages: megacheck: 5.245730941s
INFO[0017] Workers idle times: #1: 5.242094403s, #2: 5.08820943s, #4: 5.242487759s
INFO[0017] Can't run linter megacheck: panic occured: panic: runtime error: invalid memory address or nil pointer dereference, stack: goroutine 2782 [running]:
runtime/debug.Stack(0xc48de310b8, 0x16ee1a0, 0x1c8efa0)
        /usr/local/Cellar/go/1.10.1/libexec/src/runtime/debug/stack.go:24 +0xa7
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint.(*Linter).Lint.func1.1(0xc47b2c2090, 0x13)
        /Users/quanta/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lint.go:427 +0x6e
panic(0x16ee1a0, 0x1c8efa0)
        /usr/local/Cellar/go/1.10.1/libexec/src/runtime/panic.go:502 +0x229
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/staticcheck.(*Checker).CheckDeprecated.func1(0x1884fc0, 0xc4202e7800, 0x0)
        /Users/quanta/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/staticcheck/lint.go:2376 +0x145
go/ast.inspector.Visit(0xc463f72940, 0x1884fc0, 0xc4202e7800, 0xc4202e77e0, 0x1ca2fe0)
        /usr/local/Cellar/go/1.10.1/libexec/src/go/ast/walk.go:373 +0x3a
go/ast.Walk(0x1882660, 0xc463f72940, 0x1884fc0, 0xc4202e7800)
        /usr/local/Cellar/go/1.10.1/libexec/src/go/ast/walk.go:52 +0x66
go/ast.Walk(0x1882660, 0xc463f72940, 0x1884700, 0xc4201c2140)
        /usr/local/Cellar/go/1.10.1/libexec/src/go/ast/walk.go:136 +0x102b
go/ast.Walk(0x1882660, 0xc463f72940, 0x18849c0, 0xc4200bc660)
        /usr/local/Cellar/go/1.10.1/libexec/src/go/ast/walk.go:196 +0x1b0c
go/ast.walkStmtList(0x1882660, 0xc463f72940, 0xc4200e6300, 0xb, 0x10)
        /usr/local/Cellar/go/1.10.1/libexec/src/go/ast/walk.go:32 +0x81
go/ast.Walk(0x1882660, 0xc463f72940, 0x1884680, 0xc4207ac600)
        /usr/local/Cellar/go/1.10.1/libexec/src/go/ast/walk.go:224 +0x1b61
go/ast.Walk(0x1882660, 0xc463f72940, 0x1884b00, 0xc4207ac630)
        /usr/local/Cellar/go/1.10.1/libexec/src/go/ast/walk.go:344 +0xd6d
go/ast.walkDeclList(0x1882660, 0xc463f72940, 0xc420c20280, 0x2, 0x2)
        /usr/local/Cellar/go/1.10.1/libexec/src/go/ast/walk.go:38 +0x81
go/ast.Walk(0x1882660, 0xc463f72940, 0x1884a80, 0xc42011a280)
        /usr/local/Cellar/go/1.10.1/libexec/src/go/ast/walk.go:353 +0x2650
go/ast.Inspect(0x1884a80, 0xc42011a280, 0xc463f72940)
        /usr/local/Cellar/go/1.10.1/libexec/src/go/ast/walk.go:385 +0x4b
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/staticcheck.(*Checker).CheckDeprecated(0xc4485768a0, 0xc43e30a440)
        /Users/quanta/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/staticcheck/lint.go:2406 +0xa5
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/staticcheck.(*Checker).CheckDeprecated-fm(0xc43e30a440)
        /Users/quanta/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/staticcheck/lint.go:235 +0x34
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint.(*Linter).Lint.func1(0xc47b2c2090, 0xc48ddea6e0, 0xc47b2c2060, 0x13, 0xc43e30a440)
        /Users/quanta/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lint.go:436 +0xc7
created by github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint.(*Linter).Lint
        /Users/quanta/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lint.go:424 +0x25a0

INFO[0017] processing took 3.645µs with stages: max_same_issues: 2.115µs, path_prettifier: 448ns, max_from_linter: 258ns, uniq_by_line: 218ns, diff: 200ns, exclude: 135ns, cgo: 121ns, nolint: 81ns, max_per_file_from_linter: 69ns
Congrats! No issues were found.
INFO[0017] Extracting issued lines took 0s
INFO[0017] Memory: 101 samples, avg is 1158.7MB, max is 1850.9MB
INFO[0017] Execution took 17.185922259s

nolint directive is not feature compatible with gometalinter

In gometalinter, nolint directives can be applied to a branch in the AST, as well as directly on the offending line. golangci-lint does not support the former.

For example, the following does not work:

// nolint
func someFunc() {
  anUnusedVar := true
}

while this does work:

func someFunc() {
  anUnusedVar := true // nolint
}

It would be very helpful if golangci-lint were compatible with gometalinter for nolint directives.

Additional --out-format (tabwriter)

golangci-lint has the flag:

--out-format string    Format of output: colored-line-number|line-number|json (default "colored-line-number")

It would be nice if there was an additional format that made use of Go's standard library tabwriter, that would output something like:

cmd\modd\main.go:70:15:     errcheck      Error return value of `runner.Reset` is not checked
daemon.go:123:23:           errcheck      Error return value of `d.cmd.Process.Signal` is not checked
modd_test.go:39:17:         errcheck      Error return value of `ioutil.ReadFile` is not checked
notify\notify.go:40:12:     errcheck      Error return value of `cmd.Run` is not checked
notify\notify.go:52:12:     errcheck      Error return value of `cmd.Run` is not checked
proc.go:37:36:              interfacer    fp can be io.Reader

rather than:

cmd\modd\main.go:70:15: Error return value of `runner.Reset` is not checked (errcheck)
daemon.go:123:23: Error return value of `d.cmd.Process.Signal` is not checked (errcheck)
modd_test.go:39:17: Error return value of `ioutil.ReadFile` is not checked (errcheck)
notify\notify.go:40:12: Error return value of `cmd.Run` is not checked (errcheck)
notify\notify.go:52:12: Error return value of `cmd.Run` is not checked (errcheck)
proc.go:37:36: fp can be io.Reader (interfacer)

"too many open files" in macOS High Sierra

When running golangci-lint run on a repository with nearly 4000 .go files on macOS High Sierra, a "too man open files" error is encountered:

WARN[0015] running error: can't print 49 issues: can't read file path/to/file.go for printing issued line: open path/to/file.go: too many open files

macOS High Sierra defaults to an open file limit of 256, and can be increased for a shell session with ulimit -n.

Perhaps this issue can be documented in README.md. Or golangcli-lint can increase its open file limit with Setrlimit.

structcheck should probably have `-t` set

By default, structcheck does not load test files, so structs with fields that are only used for testing will fail. I'm not sure that's a great default as it leads to more false positives. As you can't modify arguments for specific linters using golangci-lint (that I can see at least) it seems like it might be a good idea to run structcheck with t so it brings in the test files too.

Lint tests by default

I think we shouldn't treat testing code as a second class citizen. In my opinion this sends a wrong message that somehow its not as important for test code to be clean as for non-test code. I think we should set --tests to true by default.

Generated files inconsistently skipped

This is a weird one. Most generated files seem to be correctly skipped, but one doesn't:

$ golangci-lint run --fast
mocks/ec2api.go:304:22: method AssignPrivateIpAddresses should be AssignPrivateIPAddresses (golint)
mocks/ec2api.go:312:35: method AssignPrivateIpAddresses should be AssignPrivateIPAddresses (golint)
mocks/ec2api.go:317:22: method AssignPrivateIpAddressesRequest should be AssignPrivateIPAddressesRequest (golint)
...
$ head -1 mocks/ec2api.go
// Code generated by MockGen. DO NOT EDIT.
$ head -1 mocks/iamapi.go
// Code generated by MockGen. DO NOT EDIT.

If I delete mocks/ec2api.go, there are no lint errors.

govet requires go install to work better

I know this report won't be that helpful, but I don't have much information.

I have this configuration:

# Exhaustive list of options here:
# https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml
run:
  deadline: 5m
  tests: true
  skip-dirs:
    - mock # Remove once https://github.com/golangci/golangci-lint/issues/86 is fixed

output:
  print-issued-lines: false

linters:
  enable-all: true
  disable:
    - maligned

linters-settings:
  govet:
    check-shadowing: true
  golint:
    min-confidence: 0
  gocyclo:
    min-complexity: 10
  dupl:
    threshold: 100
  goconst:
    min-len: 2
    min-occurrences: 2
  gocyclo:
    min-complexity: 20

issues:
  max-per-linter: 0
  max-same: 0
  exclude-use-default: false
  exclude:
    # Captured by errcheck.
    - '^(G104|G204):'
    # Very commonly not checked.
    - 'Error return value of .(.*\.Help|.*\.MarkFlagRequired|(os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked'
    # TODO(aat): remove this once docs are added.
    - '.*should have.*comment.*'
    # Weird error only seen on CI...
    - 'internal error: no range for'

Running golangci-lint run locally on my laptop results in the following error:

pkg/provision/iam/policies.go:133:5: declaration of "err" shadows declaration at pkg/provision/iam/policies.go:115 (govet)

But when this runs under CI (on Kochiku), no error is reported. I've run it on CI with -v and it gives the following:

time="2018-06-12T00:27:06Z" level=info msg="Config search paths: [./ /data/app/kochiku-worker/shared/build-partition/cash/squaremason/src/stash.corp.squareup.com/cash/squaremason /data/app/kochiku-worker/shared/build-partition/cash/squaremason/src/stash.corp.squareup.com/cash /data/app/kochiku-worker/shared/build-partition/cash/squaremason/src/stash.corp.squareup.com /data/app/kochiku-worker/shared/build-partition/cash/squaremason/src /data/app/kochiku-worker/shared/build-partition/cash/squaremason /data/app/kochiku-worker/shared/build-partition/cash /data/app/kochiku-worker/shared/build-partition /data/app/kochiku-worker/shared /data/app/kochiku-worker /data/app /data /]"
time="2018-06-12T00:27:06Z" level=info msg="Used config file .golangci.yml"
time="2018-06-12T00:27:06Z" level=info msg="Active 18 linters: [deadcode depguard dupl errcheck gas goconst gocyclo gofmt goimports golint govet ineffassign interfacer megacheck structcheck typecheck unconvert varcheck]"
time="2018-06-12T00:27:06Z" level=info msg="Skipped dirs: [mocks pkg/awsenv/testdata vendor]"
time="2018-06-12T00:27:06Z" level=info msg="Paths resolving took 3.812451ms: [cmd/sqm cmd/sqm/env cmd/sqm/service internal/registry pkg/awsenv pkg/awsenv/iampolicy pkg/k8senv pkg/provision pkg/provision/database pkg/provision/iam pkg/provision/service server]"
time="2018-06-12T00:27:13Z" level=info msg="Program loading took 7.027793144s"
time="2018-06-12T00:27:17Z" level=info msg="SSA repr building took 3.545941115s"
time="2018-06-12T00:27:17Z" level=info msg="worker.3 took 358.10083ms with stages: goimports: 239.360565ms, dupl: 98.248495ms, ineffassign: 16.93739ms, gocyclo: 1.830568ms, unconvert: 1.651006ms"
time="2018-06-12T00:27:17Z" level=info msg="worker.4 took 360.277981ms with stages: golint: 237.566721ms, gofmt: 57.642512ms, gas: 45.870413ms, varcheck: 7.755287ms, deadcode: 3.634114ms, structcheck: 3.598876ms, errcheck: 2.459229ms, goconst: 1.650107ms, typecheck: 948ns"
time="2018-06-12T00:27:18Z" level=info msg="worker.1 took 928.704012ms with stages: interfacer: 790.557348ms, govet: 138.112655ms, depguard: 7.709µs"
time="2018-06-12T00:28:08Z" level=info msg="worker.2 took 51.523991372s with stages: megacheck: 51.523955449s"
time="2018-06-12T00:28:08Z" level=info msg="Workers idle times: #1: 50.595252839s, #3: 51.165207269s, #4: 51.163674384s"
time="2018-06-12T00:28:08Z" level=info msg="processing took 1.665043ms with stages: nolint: 824.966µs, exclude: 571.104µs, path_prettifier: 149.593µs, autogenerated_exclude: 78.38µs, cgo: 13.559µs, max_same_issues: 4.953µs, uniq_by_line: 4.94µs, diff: 4.718µs, max_per_file_from_linter: 4.331µs, skip_files: 4.306µs, max_from_linter: 4.193µs"
Congrats! No issues were found.

The CI gets the latest golangci-lint with:

go get -u github.com/golangci/golangci-lint/cmd/golangci-lint

And I'm using the same version locally.

Sorry I can't be of more help, but I can't get any more information out of golangci-lint or the CI.

Double parsing having unwanted side effects.

I noticed your comment here https://github.com/golangci/golangci-lint/blob/master/pkg/commands/run.go#L404 about double parsing that way you can get Viper setup with the config values. But this causes some of the flags to act as if they were passed in twice by the user. StringSlice for example will duplicate the result. Not sure if there are any other flags that are doing this.

I think a possible solution may be to call e.parseConfig inside the executeRun command. But maybe there is something I am not seeing?

Syntax errors are not reported

eg.

[aat@cavern:~/Projects/kong]golangci-lint run --fast
Congrats! No issues were found.
[aat@cavern:~/Projects/kong]go build .
# github.com/alecthomas/kong
../../.go/src/github.com/alecthomas/kong/build.go:67:5: syntax error: unexpected ft at end of statement
../../.go/src/github.com/alecthomas/kong/build.go:69:5: syntax error: unexpected else at end of statement
../../.go/src/github.com/alecthomas/kong/build.go:72:2: syntax error: non-declaration statement outside function body
[aat@cavern:~/Projects/kong]git diff
diff --git a/build.go b/build.go
index 2eabbf9..7fa50cd 100644
--- a/build.go
+++ b/build.go
@@ -64,7 +64,7 @@ func buildNode(v reflect.Value, seenFlags map[string]bool) *Node {
                tag := parseTag(fv, ft.Tag.Get("kong"))

                // Nested structs are either commands or args.
-               if ft.Type.Kind() == reflect.Struct && (tag.Cmd || tag.Arg) {
+               i ft.Type.Kind() == reflect.Struct && (tag.Cmd || tag.Arg) {
                        buildChild(node, v, ft, fv, tag, name, seenFlags)
                } else {
                        buildField(node, v, ft, fv, tag, name, seenFlags)

Comments issues(golint) should not be ignored by default

(should have comment|comment on exported method) - golint: annoying issues about not having a comment. The rare codebase has such comments.

In my opinion, comments in Go code are not only just comments but also the documents of the code in Golang design. It's pretty familiar with the here documents in Python. If this issue is ignored by default, the code might be without the document in some careless actions, and might be unmaintainable. Also, this will cause some different reaction with the original golint, just like below.

$ golangci-lint run --disable-all -E golint ./...
Congrats! No issues were found.
$ golint ./...
pkg/enabled_linters.go:15:2: exported const PresetFormatting should have comment (or a comment on this block) or be unexported
pkg/enabled_linters.go:23:1: exported function AllPresets should have comment or be unexported
pkg/enabled_linters.go:35:6: exported type LinterConfig should have comment or be unexported
pkg/enabled_linters.go:44:1: exported method LinterConfig.WithFullImport should have comment or be unexported
pkg/enabled_linters.go:49:1: exported method LinterConfig.WithSSA should have comment or be unexported
pkg/enabled_linters.go:55:1: exported method LinterConfig.WithPresets should have comment or be unexported
pkg/enabled_linters.go:60:1: exported method LinterConfig.WithSpeed should have comment or be unexported
pkg/enabled_linters.go:74:1: exported function GetLinterConfig should have comment or be unexported
pkg/enabled_linters.go:100:1: exported function GetAllSupportedLinterConfigs should have comment or be unexported
pkg/enabled_linters.go:283:1: exported function GetAllLintersForPreset should have comment or be unexported
...

gocyclo linter is not executed when other linters enabled

GolangCI-Lint version: 1.3.6
Go version: 1.10

I've noticed that when using default configuration (i.e., default set of linters) and enabling gocyclo both using command line arguments or .golangci.yml, gocyclo is actually not running or it can rarely give one output (although I know it should output a ton of warnings).
Looks like something interrupting it's work.
So I've tried to disable all the linters (including enabled by default) but left gocyclo enabled and it started to work like a charm.
Then I enabled govet and gocyclo continued to work correctly.
But when I was trying to enable some other linters from default linter set, gocyclo went back to incorrect work (or no work at all, to be precise).

Here's the config:

linters:
    enable:
        - gocyclo
    disable:
        - errcheck
        - staticcheck
        - unused
        - gosimple
        - gas
        - structcheck
        - varcheck
        - ineffassign
        - deadcode
        - typecheck

linters-settings:
    gocyclo:
        min-complexity: 5
    golint:
        min-confidence: 0
    govet:
        check-shadowing: true
    maligned:
        suggest-new: true

issues:
  exclude:
    - should have a package comment
    - declaration of "err" shadows declaration

deadline exceeded should returns 1 instead of 0

...
INFO[0082] processing took 667.366µs with stages: max_same_issues: 664.846µs, max_from_linter: 1.138µs, path_prettifier: 394ns, cgo: 227ns, exclude: 203ns, diff: 181ns, nolint: 173ns, max_per_file_from_linter: 154ns, uniq_by_line: 50ns
WARN[0082] 0/9 linters finished: deadline exceeded: try increase it by passing --deadline option
Congrats! No issues were found.
INFO[0082] Extracting issued lines took 0s

❯❯❯❯ echo $?
0

Default concurrency is NumCPU, not 4

I was confused by this section of the --help text. I wondered why concurrency was defaulting to 4, instead of using runtime.NumCPU() to scale the number of workers to the user's actual number of cores.

Flags:
  -j, --concurrency int           Concurrency (default 4)

Apparently, you are doing this 😀👍

rootCmd.PersistentFlags().IntVarP(&e.cfg.Run.Concurrency, "concurrency", "j", runtime.NumCPU(), "Concurrency")

https://github.com/golangci/golangci-lint/blob/master/pkg/commands/root.go#L64

I think the --help text should be updated to Concurrency (default NumCPU) or similar. Go programmers will recognize NumCPU as runtime.NumCPU().

Add binaries to releases

It would nice to have binaries in the release pages.
Currently the proposed way to install is to go get -u github.com/golangci/golangci-lint/cmd/golangci-lint.
There are official releases though 👏 .
It would be nice to have binaries attached to the releases so one can use a specific version.

Cheers!

Adding `-D` when also passing config file ignores config?

With a .golangci.toml containing

[linters]
enable-all = true
disable = [
  "dupl",
  "goconst",
  "maligned",
  "golint"
]

and running golangci-lint run -c ../../.golangci.toml -Dtypecheck ./... to also disable typecheck, the previously disabled linters are enabled again.

Possiblie add more linters to --fast

with gometalinter the --fast option includes more linters and is still almost instantaneous. With golangci-lint the --fast option doesn't include enough linters to really be helpful using it as my editors linter, in my opinion.

A sollution could be a scale possibly? for example --very-fast and --fast.

capitalized errors ignoring

warning: error strings should not be capitalized or end with punctuation or a newline (golint) were skipped with options --max-issues-per-linter 0 --max-same-issues 0

Missing golint warning about missed comment

package main

import "fmt"

const Test = 1

func main() {
	fmt.Println(Test)
}
❯❯❯❯ golint golint.go
golint.go:5:7: exported const Test should have comment or be unexported
golangci-lint -v run --enable-all
INFO[0000] Active 19 linters: [deadcode depguard dupl errcheck gas goconst gocyclo gofmt goimports golint govet ineffassign interfacer maligned megacheck structcheck typecheck unconvert varcheck]
INFO[0000] Paths resolving took 53.912µs: golint.go
INFO[0001] Program loading took 1.022202555s
INFO[0001] SSA repr building took 298.371047ms
INFO[0001] worker.3 took 7.052603ms with stages: golint: 6.628217ms, gofmt: 144.329µs, errcheck: 93.992µs, ineffassign: 90.38µs, goconst: 9.614µs, varcheck: 9.607µs, gocyclo: 8.495µs, structcheck: 8.009µs, deadcode: 6.384µs, maligned: 3.45µs, typecheck: 419ns
INFO[0001] worker.4 took 7.052492ms with stages: govet: 6.374265ms, dupl: 313.173µs, gas: 285.407µs, unconvert: 42.404µs, depguard: 7.263µs
INFO[0001] worker.1 took 20.340269ms with stages: interfacer: 16.335097ms, goimports: 3.897825ms
INFO[0002] worker.2 took 722.756747ms with stages: megacheck: 722.712178ms
INFO[0002] Workers idle times: #1: 701.870643ms, #3: 715.659484ms, #4: 715.64974ms
INFO[0002] processing took 142.927µs with stages: exclude: 110.433µs, path_prettifier: 20.749µs, nolint: 4.109µs, autogenerated_exclude: 2.89µs, max_same_issues: 1.602µs, cgo: 1.019µs, max_from_linter: 589ns, diff: 506ns, uniq_by_line: 368ns, skip_files: 331ns, max_per_file_from_linter: 331ns
Congrats! No issues were found.
INFO[0002] Extracting issued lines took 0s
INFO[0002] Memory: 21 samples, avg is 128.8MB, max is 239.0MB
INFO[0002] Execution took 2.072068135s

govet can produce false-positive without running go install first

Environment

  • Go v1.10.2
  • Golangci-lint v1.2.1

Reproduction Steps

  • Create Go file with the following content,
package main

import "fmt"

func main() {
	format := fmt.Sprintf("%%-%ds %%s", 20)
	fmt.Println("format:", format)
	fmt.Printf(format+"\n", "golangci-lint", "test")
}
  • Run golangci-lint run

Expected Result

Congrats! No issues were found.

Actual Result

master ms 0 % golangci-lint run ./...
Run this tool in cloud on every github pull request in https://golangci.com for free (public repos)
govet.go:8: Printf call has arguments but no formatting directives (govet)
        fmt.Printf(format+"\n", "golangci-lint", "test")

--fast panics

First of all, awesome project. The pretty-printed output is very helpful, and I'm definitely seeing performance improvements over gometalinter.

I encountered some problems while trying this tool out. It works fine when run with --enable-all, but panics when passed --fast, as well as some combinations involving --disable-all.

Version Info

Go version 1.10
golangci-lint version:

$ golangci-lint --version
golangci-lint has version master built from ? on

Not sure what that output means to you...

$ cd $GOPATH/src/github.com/golangci/golangci-lint/
$ git rev-parse HEAD
0eb6aa7c59aab27a316af0b18acd023faf814c72

Which appears to be the latest master version as of this moment.

Stack Traces

$ golangci-lint run --fast
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0xa41543]

goroutine 1 [running]:
github.com/golangci/golangci-lint/pkg/commands.separateNotCompilingPackages(0xc420186a00)
        /opt/go/src/github.com/golangci/golangci-lint/pkg/commands/run.go:199 +0x43
github.com/golangci/golangci-lint/pkg/commands.buildLintCtx(0xc8e360, 0xc42009ac60, 0xc420114e80, 0x8, 0x8, 0xc42013b1e0, 0xc4204b5a40, 0x49aeff, 0xbc7742)
        /opt/go/src/github.com/golangci/golangci-lint/pkg/commands/run.go:264 +0x39a
github.com/golangci/golangci-lint/pkg/commands.(*Executor).runAnalysis(0xc42011eb90, 0xc8e360, 0xc42009ac60, 0xc420495b70, 0x0, 0x1, 0x0, 0x0, 0x0)
        /opt/go/src/github.com/golangci/golangci-lint/pkg/commands/run.go:277 +0xf3
github.com/golangci/golangci-lint/pkg/commands.(*Executor).runAndPrint(0xc42011eb90, 0xc8e360, 0xc42009ac60, 0xc420495b70, 0x0, 0x1, 0x0, 0x0)
        /opt/go/src/github.com/golangci/golangci-lint/pkg/commands/run.go:331 +0xe0
github.com/golangci/golangci-lint/pkg/commands.(*Executor).executeRun(0xc42011eb90, 0xc4204b6280, 0xc420495b70, 0x0, 0x1)
        /opt/go/src/github.com/golangci/golangci-lint/pkg/commands/run.go:379 +0x23e
github.com/golangci/golangci-lint/pkg/commands.(*Executor).(github.com/golangci/golangci-lint/pkg/commands.executeRun)-fm(0xc4204b6280, 0xc420495b70, 0x0, 0x1)
        /opt/go/src/github.com/golangci/golangci-lint/pkg/commands/run.go:40 +0x52
github.com/golangci/golangci-lint/vendor/github.com/spf13/cobra.(*Command).execute(0xc4204b6280, 0xc420495b60, 0x1, 0x1, 0xc4204b6280, 0xc420495b60)
        /opt/go/src/github.com/golangci/golangci-lint/vendor/github.com/spf13/cobra/command.go:760 +0x2c1
github.com/golangci/golangci-lint/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc4204b6000, 0xa, 0xbcb5ec, 0xc4204b6a00)
        /opt/go/src/github.com/golangci/golangci-lint/vendor/github.com/spf13/cobra/command.go:846 +0x30a
github.com/golangci/golangci-lint/vendor/github.com/spf13/cobra.(*Command).Execute(0xc4204b6000, 0xc42013b1e0, 0xc42011eb90)
        /opt/go/src/github.com/golangci/golangci-lint/vendor/github.com/spf13/cobra/command.go:794 +0x2b
github.com/golangci/golangci-lint/pkg/commands.Executor.Execute(0xc4204b6000, 0xc42013b1e0, 0x0, 0xbc48a7, 0x6, 0xbc1d5f, 0x1, 0x0, 0x0, 0xc4204b5f78, ...)
        /opt/go/src/github.com/golangci/golangci-lint/pkg/commands/executor.go:35 +0x2b
main.main()
        /opt/go/src/github.com/golangci/golangci-lint/cmd/golangci-lint/main.go:16 +0x9a

And a variant with --disable-all, but failing to use --enable=xx correctly produces a similar response.

$ golangci-lint run -v --no-config --disable-all --enable govet
INFO[0000] Concurrency: 4, machine cpus count: 4
INFO[0000] Active linters: [govet]
INFO[0000] set GOROOT="/usr/local/go"
INFO[0000] Found paths for analysis for 2.69556ms: [. ./cmd ./dbal ./env ./lib/async ./lib/auditlog ./lib/classify ./lib/conn ./lib/daemon ./lib/locker ./lib/log ./lib/schedule ./lib/trie ./pipe ./pipe/msg ./pipe/plugin/core ./pipe/plugin/frhc ./pipe/plugin/rabbitmq ./pipe/plugin/reports ./pipe/plugin/salesforce ./pipe/plugin/telcor]
INFO[0000] Memory: 1 samples, avg is 14.7MB, max is 14.7MB
INFO[0000] Execution took 19.662404ms
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0xa41543]

goroutine 1 [running]:
github.com/golangci/golangci-lint/pkg/commands.separateNotCompilingPackages(0xc420da3ea0)
        /opt/go/src/github.com/golangci/golangci-lint/pkg/commands/run.go:199 +0x43
github.com/golangci/golangci-lint/pkg/commands.buildLintCtx(0xc8e360, 0xc4200d8cc0, 0xc42013d4f0, 0x1, 0x1, 0xc4200e1380, 0xc420369a40, 0x49aeff, 0xbc7742)
        /opt/go/src/github.com/golangci/golangci-lint/pkg/commands/run.go:264 +0x39a
github.com/golangci/golangci-lint/pkg/commands.(*Executor).runAnalysis(0xc420148af0, 0xc8e360, 0xc4200d8cc0, 0xc420148c30, 0x0, 0x5, 0x0, 0x0, 0x0)
        /opt/go/src/github.com/golangci/golangci-lint/pkg/commands/run.go:277 +0xf3
github.com/golangci/golangci-lint/pkg/commands.(*Executor).runAndPrint(0xc420148af0, 0xc8e360, 0xc4200d8cc0, 0xc420148c30, 0x0, 0x5, 0x0, 0x0)
        /opt/go/src/github.com/golangci/golangci-lint/pkg/commands/run.go:331 +0xe0
github.com/golangci/golangci-lint/pkg/commands.(*Executor).executeRun(0xc420148af0, 0xc42036c280, 0xc420148c30, 0x0, 0x5)
        /opt/go/src/github.com/golangci/golangci-lint/pkg/commands/run.go:379 +0x23e
github.com/golangci/golangci-lint/pkg/commands.(*Executor).(github.com/golangci/golangci-lint/pkg/commands.executeRun)-fm(0xc42036c280, 0xc420148c30, 0x0, 0x5)
        /opt/go/src/github.com/golangci/golangci-lint/pkg/commands/run.go:40 +0x52
github.com/golangci/golangci-lint/vendor/github.com/spf13/cobra.(*Command).execute(0xc42036c280, 0xc420148be0, 0x5, 0x5, 0xc42036c280, 0xc420148be0)
        /opt/go/src/github.com/golangci/golangci-lint/vendor/github.com/spf13/cobra/command.go:760 +0x2c1
github.com/golangci/golangci-lint/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc42036c000, 0xa, 0xbcb5ec, 0xc42036c780)
        /opt/go/src/github.com/golangci/golangci-lint/vendor/github.com/spf13/cobra/command.go:846 +0x30a
github.com/golangci/golangci-lint/vendor/github.com/spf13/cobra.(*Command).Execute(0xc42036c000, 0xc4200e1380, 0xc420148af0)
        /opt/go/src/github.com/golangci/golangci-lint/vendor/github.com/spf13/cobra/command.go:794 +0x2b
github.com/golangci/golangci-lint/pkg/commands.Executor.Execute(0xc42036c000, 0xc4200e1380, 0x0, 0xbc48a7, 0x6, 0xbc1d5f, 0x1, 0x0, 0x0, 0xc420369f78, ...)
        /opt/go/src/github.com/golangci/golangci-lint/pkg/commands/executor.go:35 +0x2b
main.main()
        /opt/go/src/github.com/golangci/golangci-lint/cmd/golangci-lint/main.go:16 +0x9a

Other Notes

I'm guessing it's related to enabling a default linter which was disabled with disable-all:
golangci-lint run --no-config --deadline=30s --disable-all --enable=deadcode works
golangci-lint run --no-config --deadline=30s --disable-all --enable=govet is broken

Make incremental program loading

Currently, it's the slowest part of golangci-lint in "slow" (without --fast) mode.
Need to cache loaded packages and reload only changed packages.

Add custom linter commands to the config

Hey, I love this project and would love to use that as our main CI linter.

But in order to do that, we'd need more flexibility. I.e. we need the ability to pass specific commands to linters, somethin like so (please, correct me if I've missed it somewhere along the docs):

"gas": {
  "Command": "gas -include=G101,G102,G203,G303,G402,G404"
}

Improve nolint comments matching

Match nolint comments:

  • on a line above the problematic code
  • on a line above the function definition containing the problematic code
  • if there are spaces in comment between nolint: and linters list

"typecheck" takes ~5 times longer than "go build"

$ time golangci-lint run --disable-all --enable typecheck
Congrats! No issues were found.
golangci-lint run --disable-all --enable typecheck  4.61s user 1.51s system 391% cpu 1.562 total
$ time go build .
go build .  0.72s user 0.50s system 139% cpu 0.873 total

"linters" command should list current configuration

When running golangci-lint linters we get output similar to documentation.

What could be more useful is to list linters that would be run with golangci-lint run, i.e. it would load configs and list enabled linters with whatever options there are.

Current functionality could be hidden under a flag.

User should be notified that enabled linter failed/panicked

During regular run a message saying "Congrats! No issues were found." is visible.
It should contain some warning about failing linter and possible a hint to use verbose option as well.

See example:

swicus PI-1215-migration_endpoint ✗ 2h44m ▲ ◒ ➜ golangci-lint run -v                                         
INFO[0000] Config search paths: [./ /Users/matej.lesko/go/src/github.com/solarwindscloud/swicus /Users/matej.lesko/go/src/github.com/solarwindscloud /Users/matej.lesko/go/src/github.com /Users/matej.lesko/go/src /Users/matej.lesko/go /Users/matej.lesko /Users /] 
INFO[0000] Used config file .golangci.yml               
INFO[0000] Active 17 linters: [deadcode dupl errcheck gas goconst gocyclo gofmt golint govet ineffassign interfacer maligned megacheck structcheck typecheck unconvert varcheck] 
INFO[0000] set GOROOT="/usr/local/opt/[email protected]/libexec/" 
INFO[0000] Found paths for analysis for 1.727533ms: [./authserver ./cmd/swicus ./db ./db/migrate ./hash ./metrics ./notifier ./snowflake ./types ./types/ctxkey ./types/scope ./types/swerr ./userservice ./valid ./valid/commitlog ./valid/commitlog/static ./valid/gen] 
INFO[0002] Program loading took 2.875186597s            
INFO[0003] SSA repr building took 761.966211ms          
INFO[0004] worker.2 took 392.970712ms with stages: govet: 259.126903ms, gofmt: 83.370094ms, ineffassign: 34.453291ms, structcheck: 5.70993ms, errcheck: 5.549982ms, deadcode: 4.732017ms, typecheck: 514ns 
INFO[0004] worker.3 took 389.2041ms with stages: interfacer: 147.331055ms, dupl: 129.455256ms, gas: 71.787171ms, goconst: 23.963243ms, varcheck: 9.152789ms, unconvert: 2.921552ms, gocyclo: 2.422537ms, maligned: 2.133665ms 
INFO[0004] worker.4 took 457.37095ms with stages: golint: 457.349992ms 
INFO[0004] Panic stack trace: goroutine 1564 [running]:
runtime/debug.Stack(0x17e2b38, 0x11, 0xc4443366f0)
	/usr/local/opt/[email protected]/libexec/src/runtime/debug/stack.go:24 +0xa7
github.com/golangci/golangci-lint/pkg/lint.runLinterSafe.func1(0xc444337c30)
	/Users/matej.lesko/go/src/github.com/golangci/golangci-lint/pkg/lint/runner.go:34 +0xc2
panic(0x16e4ba0, 0xc44f19f1a0)
	/usr/local/opt/[email protected]/libexec/src/runtime/panic.go:502 +0x229
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint.(*Linter).Lint(0xc444337470, 0xc4201a8640, 0xc420162580, 0xc441cd1040, 0x174e440, 0x1c265e0, 0xc420427490)
	/Users/matej.lesko/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lint.go:446 +0x2e7c
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lintutil.(*runner).lint(0xc4204275a8, 0xc4201a8640, 0xc420162580, 0xc441cd1040, 0x0, 0x0, 0x0)
	/Users/matej.lesko/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lintutil/util.go:292 +0xc8
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lintutil.Lint(0xc44e37f3c0, 0x3, 0x4, 0xc4201a8640, 0xc420162580, 0xc441cd1040, 0xc444337710, 0x4, 0xc4204276e8, 0x1012329, ...)
	/Users/matej.lesko/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lintutil/util.go:248 +0x1f5
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lintutil.ProcessFlagSet(0xc44fa88ba0, 0x3, 0x4, 0xc44fa88b40, 0xc4201a8640, 0xc420162580, 0xc441cd1040, 0x4, 0x1, 0xc4200608b8)
	/Users/matej.lesko/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lintutil/util.go:203 +0x615
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/cmd/megacheck.Run(0xc4201a8640, 0xc420162580, 0xc441cd1040, 0x10101, 0x0, 0x1, 0xc420060970)
	/Users/matej.lesko/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/cmd/megacheck/megacheck.go:124 +0x74a
github.com/golangci/golangci-lint/pkg/golinters.Megacheck.Run(0x10101, 0x1898420, 0xc4200d51a0, 0xc44fa19720, 0x102ac39, 0x8, 0xc432277140, 0x0, 0xc420060a80)
	/Users/matej.lesko/go/src/github.com/golangci/golangci-lint/pkg/golinters/megacheck.go:54 +0x7d
github.com/golangci/golangci-lint/pkg/lint.runLinterSafe(0x1898420, 0xc4200d51a0, 0xc44fa19720, 0x18976a0, 0xc420c7c010, 0x10100, 0xc4200fe480, 0x3, 0x3, 0x1, ...)
	/Users/matej.lesko/go/src/github.com/golangci/golangci-lint/pkg/lint/runner.go:38 +0xbf
github.com/golangci/golangci-lint/pkg/lint.runWorker.func1()
	/Users/matej.lesko/go/src/github.com/golangci/golangci-lint/pkg/lint/runner.go:70 +0x8b
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc44fa99b80, 0x17d0872, 0x9, 0xc420060e28)
	/Users/matej.lesko/go/src/github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:73 +0x53
github.com/golangci/golangci-lint/pkg/lint.runWorker(0x1898420, 0xc4200d51a0, 0xc44fa19720, 0xc44fa88960, 0xc44fa889c0, 0xc44f52ab70, 0x8)
	/Users/matej.lesko/go/src/github.com/golangci/golangci-lint/pkg/lint/runner.go:69 +0x19e
github.com/golangci/golangci-lint/pkg/lint.(*SimpleRunner).runWorkers.func1(0xc44f52ab60, 0x1898420, 0xc4200d51a0, 0xc44fa19720, 0xc44fa88960, 0xc44fa889c0, 0xc44fa88a20, 0x4, 0x4, 0x0)
	/Users/matej.lesko/go/src/github.com/golangci/golangci-lint/pkg/lint/runner.go:124 +0x117
created by github.com/golangci/golangci-lint/pkg/lint.(*SimpleRunner).runWorkers
	/Users/matej.lesko/go/src/github.com/golangci/golangci-lint/pkg/lint/runner.go:121 +0x1a5
 
INFO[0004] worker.1 took 1.243648816s with stages: megacheck: 1.243617692s 
INFO[0004] Can't run linter megacheck: panic occured: panic: runtime error: invalid memory address or nil pointer dereference, stack: goroutine 1846 [running]:
runtime/debug.Stack(0xc44aabef28, 0x16f8460, 0x1ca1fc0)
	/usr/local/opt/[email protected]/libexec/src/runtime/debug/stack.go:24 +0xa7
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint.(*Linter).Lint.func1.1(0xc44fa80720, 0x13)
	/Users/matej.lesko/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lint.go:427 +0x6e
panic(0x16f8460, 0x1ca1fc0)
	/usr/local/opt/[email protected]/libexec/src/runtime/panic.go:502 +0x229
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/staticcheck.(*Checker).CheckDeprecated.func1(0x1893060, 0xc42007cb20, 0xc44cdfc3a0)
	/Users/matej.lesko/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/staticcheck/lint.go:2376 +0x145
go/ast.inspector.Visit(0xc44cdfc3a0, 0x1893060, 0xc42007cb20, 0x1010398, 0x173e280)
	/usr/local/opt/[email protected]/libexec/src/go/ast/walk.go:373 +0x3a
go/ast.Walk(0x1890740, 0xc44cdfc3a0, 0x1893060, 0xc42007cb20)
	/usr/local/opt/[email protected]/libexec/src/go/ast/walk.go:52 +0x66
go/ast.Walk(0x1890740, 0xc44cdfc3a0, 0x1892aa0, 0xc42007e680)
	/usr/local/opt/[email protected]/libexec/src/go/ast/walk.go:74 +0xb97
go/ast.Walk(0x1890740, 0xc44cdfc3a0, 0x1892ae0, 0xc42043c570)
	/usr/local/opt/[email protected]/libexec/src/go/ast/walk.go:84 +0x144
go/ast.Walk(0x1890740, 0xc44cdfc3a0, 0x1893160, 0xc42007d600)
	/usr/local/opt/[email protected]/libexec/src/go/ast/walk.go:161 +0x27bf
go/ast.Walk(0x1890740, 0xc44cdfc3a0, 0x1893220, 0xc42043c540)
	/usr/local/opt/[email protected]/libexec/src/go/ast/walk.go:318 +0x2aec
go/ast.Walk(0x1890740, 0xc44cdfc3a0, 0x1892c60, 0xc42007ec80)
	/usr/local/opt/[email protected]/libexec/src/go/ast/walk.go:331 +0xf2f
go/ast.walkDeclList(0x1890740, 0xc44cdfc3a0, 0xc4210e4800, 0x64, 0x80)
	/usr/local/opt/[email protected]/libexec/src/go/ast/walk.go:38 +0x81
go/ast.Walk(0x1890740, 0xc44cdfc3a0, 0x1892b20, 0xc420127d80)
	/usr/local/opt/[email protected]/libexec/src/go/ast/walk.go:353 +0x2650
go/ast.Inspect(0x1892b20, 0xc420127d80, 0xc44cdfc3a0)
	/usr/local/opt/[email protected]/libexec/src/go/ast/walk.go:385 +0x4b
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/staticcheck.(*Checker).CheckDeprecated(0xc44e38d380, 0xc44e35b540)
	/Users/matej.lesko/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/staticcheck/lint.go:2406 +0xa5
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/staticcheck.(*Checker).CheckDeprecated-fm(0xc44e35b540)
	/Users/matej.lesko/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/staticcheck/lint.go:235 +0x34
github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint.(*Linter).Lint.func1(0xc44fa80720, 0xc42d9dc940, 0xc44fa80690, 0x13, 0xc44e35b540)
	/Users/matej.lesko/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lint.go:436 +0xc7
created by github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint.(*Linter).Lint
	/Users/matej.lesko/go/src/github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint/lint.go:424 +0x25a0
 
INFO[0004] Workers idle times: #2: 849.247497ms, #3: 841.003268ms, #4: 785.946032ms 
INFO[0004] processing took 33.331417ms with stages: exclude: 25.154019ms, nolint: 7.6918ms, path_prettifier: 406.631µs, cgo: 71.489µs, uniq_by_line: 1.827µs, max_from_linter: 1.363µs, max_same_issues: 1.361µs, diff: 1.168µs, skip_files: 901ns, max_per_file_from_linter: 858ns 
Congrats! No issues were found.
INFO[0004] Extracting issued lines took 0s              
INFO[0004] Memory: 39 samples, avg is 519.6MB, max is 1024.8MB 
INFO[0004] Execution took 4.883715971s                

[nit] The memory usage comparisons in the README are inaccurate

There are some highly confusing memory consumption comparisons in the README. For example https://github.com/golangci/golangci-lint/blame/master/README.md#L136 states the following:

consumes 1.35x less memory

Assuming that x is the memory consumption, and golangci-lint consumes 1.35x less memory, it would mean x - 1.35x = -0.35x, so golangci-lint consumes negative memory? I'm exaggerating of course, but I really am not sure what 1.35x less memory means. My best guess is that the intended meaning is that for every 1.35GB that metalinter consumes, golangci-lint consumes 1GB? If that's the case, I suggest using 1 - 1.00GB / 1.35GB ~= 0.259 so golangci-lint uses 26% less memory, using multipliers when talking about decreased values is bound to lead to confusion.

Yes, I'm fun at parties.

idea: add linter to check that commited code is the same as that generated by go generate

For background, see the Reddit topic Do you commit all the generated code in your Golang applications?

Specifically, @kemitche's reply https://old.reddit.com/r/golang/comments/8mbi47/do_you_commit_all_the_generated_code_in_your/dzmh9e3/

We commit our generated code, but we also have our CI tools re-run code generation as a sanity check. If it finds any diffs, then we know the most recent commit failed to run code generation.

We use dep to make sure that everyone is using the same version of code generation tools, and we try to stick to tools that are consistent when run repeatedly.

gofmt: got too much paths

$ golangci-lint run                                                                                                                          0
WARN[0000] Gofmt: got too much paths (5877), analyze first 1000

There are only 344 .go files in my repo (outside of vendor/). So why is gofmt receiving so many paths?

support code comments for ignoring^Wacknowledging issues

> golangci-lint run ./...
cmd/foo/serve.go:174:19: Error return value of `logger.Sync` is not checked (errcheck)
        defer logger.Sync() // nolint: errcheck
                         ^
server/handlers.go:32:9: Error return value of `w.Write` is not checked (errcheck)
        w.Write(data) // nolint: errcheck
               ^

It would be nice if there was a way to be able to suppress reporting in by comments like these ☝️ -- the actual comments are from a code base using GML.

Or is there a way to achieve this that I've been missing?

Support partitioning for large repositories

I get this on my work repo:

$ golangci-lint run
WARN[0000] Gofmt: got too much paths (2072), analyze first 1000

gometalinter supports arbitrarily large repos by partitioning linter invocations into manageable sizes.

Go <= 1.8 support

I run the command to install the tool:

go get -u github.com/golangci/golangci-lint/cmd/golangci-lint

but something wrong occur:

go get github.com/golangci/golangci-lint/cmd/golangci-lint
# github.com/golangci/golangci-lint/vendor/github.com/golangci/govet
D:\Gworks\src\github.com\golangci\golangci-lint\vendor\github.com\golangci\govet\asmdecl.go:99: undefined: types.SizesFor
D:\Gworks\src\github.com\golangci\golangci-lint\vendor\github.com\golangci\govet\types.go:313: undefined: types.SizesFor
# github.com/golangci/golangci-lint/vendor/github.com/golangci/go-tools/lint
D:\Gworks\src\github.com\golangci\golangci-lint\vendor\github.com\golangci\go-tools\lint\lint.go:421: undefined: sync.Map

I need help, thanks!

allow for skipping file names by patterns

I'm not sure if this is again only something I haven't found in the docs, but -- it would be very nice if golangci-lint could be configured to ignore files that have been generated. One way we've used this with GML was to configure an "exclude pattern" of *.pb.*.go, like

{
  "Exclude": [
     ".*\\.pb\\.go"
  ]
}

Any way to achieve that, short of (pre-)filtering the list of files to check?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.