Skip to content

Return a failure on linter fail #451

Closed
@JordanRees1

Description

@JordanRees1

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 

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions