Skip to content

Return a failure on linter fail #451

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
JordanRees1 opened this issue Mar 19, 2019 · 1 comment · Fixed by #890
Closed

Return a failure on linter fail #451

JordanRees1 opened this issue Mar 19, 2019 · 1 comment · Fixed by #890
Labels
bug Something isn't working enhancement New feature or improvement

Comments

@JordanRees1
Copy link

What happened: A linter failed to run and the return code is 0 showing as a warning on the cli.

What did I expect: The return code to be none 0 so the CI fails if a linter fails to run.

How could this be achieved: A setting which allows a failure to be returned if one or more linters fails to run.

  1. Version of golangci-lint: 1.15.0

  2. Config file:

linters-settings:
  govet:
    check-shadowing: true
  golint:
    min-confidence: 0.4
  gocyclo:
    min-complexity: 10
  maligned:
    suggest-new: true
  goconst:
    min-len: 2
    min-occurrences: 2
  goimports:
    local-prefixes: github.com/golangci/golangci-lint
  gocritic:
    enabled-tags:
      - performance
      - style
      - experimental
    disabled-checks:
      - wrapperFunc

linters:
  enable-all: true
  disable:
    - stylecheck
    - gosec
    - unconvert
    - dupl
    - maligned
    - depguard
    - misspell
    - lll
    - unparam
    - nakedret
    - scopelint
    - gocritic
    - gochecknoinits
    - gochecknoglobals

run:
  skip-dirs:
    - vendor/

service:
  golangci-lint-version: 1.15.0 # use the fixed version to not introduce new linters unexpectedly
  1. Go environment:
go version go1.11.5 linux/amd64
GOARCH="amd64"
GOBIN="/buildstream-install/usr/bin"
GOCACHE="/tmp/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/buildstream-install/usr/lib/go/"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build822265853=/tmp/go-build -gno-record-gcc-switches"
  1. Verbose output of running:
INFO [config_reader] Config search paths: [./ /buildstream-install/usr/lib/go/src/github.hpe.com/storex/storex/exampledatabase /buildstream-install/usr/lib/go/src/github.hpe.com/storex/storex /buildstream-install/usr/lib/go/src/github.hpe.com/storex /buildstream-install/usr/lib/go/src/github.hpe.com /buildstream-install/usr/lib/go/src /buildstream-install/usr/lib/go /buildstream-install/usr/lib /buildstream-install/usr /buildstream-install /] 
INFO [config_reader] Used config file ../.golangci.yml 
INFO [lintersdb] Active 17 linters: [deadcode errcheck goconst gocyclo gofmt goimports golint gosimple govet ineffassign interfacer prealloc staticcheck structcheck typecheck unused varcheck] 
INFO [lintersdb] Optimized sublinters [staticcheck gosimple unused] into metalinter megacheck 
INFO [loader] Go packages loading at mode load deps types and syntax took 2.049268009s 
INFO [loader] SSA repr building timing: packages building 54.736477ms, total 200.704905ms 
INFO [runner] worker.2 took 3.112613ms with stages: govet: 2.816186ms, varcheck: 289.043µs 
WARN [runner] Can't run linter goimports: error computing diff: exec: "diff": executable file not found in $PATH 
INFO [runner] worker.3 took 3.276324ms with stages: goimports: 2.475366ms, errcheck: 315.973µs, deadcode: 188.669µs, structcheck: 118.029µs, gocyclo: 88.57µs, goconst: 63.193µs, typecheck: 5.407µs 
INFO [runner] worker.1 took 3.579534ms with stages: gofmt: 2.37589ms, ineffassign: 1.131612ms, prealloc: 56.845µs 
INFO [runner] worker.4 took 31.687732ms with stages: golint: 31.669985ms 
INFO [runner] worker.6 took 42.932364ms with stages: interfacer: 42.912742ms 
INFO [runner] worker.5 took 879.754958ms with stages: megacheck: 879.746166ms 
INFO [runner] Workers idle times: #1: 875.968691ms, #2: 876.591087ms, #3: 876.366706ms, #4: 848.090183ms, #6: 836.677572ms 
INFO [runner] Issues before processing: 1, after processing: 0 
INFO [runner] processing took 159.62µs with stages: skip_dirs: 83.892µs, autogenerated_exclude: 40.319µs, cgo: 18.69µs, path_prettifier: 7.65µs, max_same_issues: 1.646µs, replacement_builder: 780ns, nolint: 769ns, identifier_marker: 762ns, max_from_linter: 737ns, exclude: 735ns, skip_files: 628ns, diff: 588ns, max_per_file_from_linter: 550ns, source_code: 532ns, path_shortener: 450ns, exclude-rules: 449ns, uniq_by_line: 443ns 
INFO Memory: 31 samples, avg is 331.7MB, max is 811.2MB 
INFO Execution took 3.140833195s 
@lovung
Copy link

lovung commented Mar 21, 2019

(Y)

@tpounds tpounds added bug Something isn't working feedback required Requires additional feedback labels Oct 3, 2019
saschagrunert added a commit to saschagrunert/golangci-lint that referenced this issue Dec 17, 2019
We now return an error if any linter is unable to run to
not exit on 0 in that case.

Closes golangci#451

Signed-off-by: Sascha Grunert <[email protected]>
tpounds pushed a commit that referenced this issue Dec 29, 2019
We now return an error if any linter is unable to run to
not exit on 0 in that case.

Closes #451

Signed-off-by: Sascha Grunert <[email protected]>
@tpounds tpounds added enhancement New feature or improvement and removed feedback required Requires additional feedback labels Dec 29, 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 enhancement New feature or improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants