Skip to content
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

Lint passes unexpectedly when build fails #866

Closed
3 tasks done
howardjohn opened this issue Nov 23, 2019 · 2 comments
Closed
3 tasks done

Lint passes unexpectedly when build fails #866

howardjohn opened this issue Nov 23, 2019 · 2 comments
Labels
bug Something isn't working false negative An error is not reported when one exists

Comments

@howardjohn
Copy link

Thank you for creating the issue!

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc).

Please include the following information:

Version of golangci-lint
$ golangci-lint --version
v1.21.0
Config file
$ cat .golangci.yml
# WARNING: DO NOT EDIT, THIS FILE IS PROBABLY A COPY
#
# The original version of this file is located in the https://github.com/istio/common-files repo.
# If you're looking at this file in a different repo and want to make a change, please go to the
# common-files repo, make the change there and check it in. Then come back to this repo and run
# "make update-common".

service:
  # When updating this, also update the version stored in docker/build-tools/Dockerfile in the istio/tools repo.
  golangci-lint-version: 1.21.x # use the fixed version to not introduce new linters unexpectedly
run:
  # timeout for analysis, e.g. 30s, 5m, default is 1m
  deadline: 20m

  # which dirs to skip: they won't be analyzed;
  # can use regexp here: generated.*, regexp is applied on full path;
  # default value is empty list, but next dirs are always skipped independently
  # from this option's value:
  #   	vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
  skip-dirs:
    - genfiles$
    - vendor$

  # which files to skip: they will be analyzed, but issues from them
  # won't be reported. Default value is empty list, but there is
  # no need to include all autogenerated files, we confidently recognize
  # autogenerated files. If it's not please let us know.
  skip-files:
    - ".*\\.pb\\.go"
    - ".*\\.gen\\.go"

linters:
  enable-all: true
  disable:
    - bodyclose
    - depguard
    - dogsled
    - dupl
    - funlen
    - gochecknoglobals
    - gochecknoinits
    - gocognit
    - goconst
    - gocyclo
    - godox
    - gosec
    - nakedret
    - prealloc
    - scopelint
    - whitespace
    - wsl
  fast: false

linters-settings:
  errcheck:
    # report about not checking of errors in type assetions: `a := b.(MyStruct)`;
    # default is false: such cases aren't reported by default.
    check-type-assertions: false

    # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
    # default is false: such cases aren't reported by default.
    check-blank: false
  govet:
    # report about shadowed variables
    check-shadowing: false
  golint:
    # minimal confidence for issues, default is 0.8
    min-confidence: 0.0
  gofmt:
    # simplify code: gofmt with `-s` option, true by default
    simplify: true
  goimports:
    # put imports beginning with prefix after 3rd-party packages;
    # it's a comma-separated list of prefixes
    local-prefixes: istio.io/
  maligned:
    # print struct with more effective memory layout or not, false by default
    suggest-new: true
  misspell:
    # Correct spellings using locale preferences for US or UK.
    # Default is to use a neutral variety of English.
    # Setting locale to US will correct the British spelling of 'colour' to 'color'.
    locale: US
    ignore-words:
    - cancelled
  lll:
    # max line length, lines longer will be reported. Default is 120.
    # '\t' is counted as 1 character by default, and can be changed with the tab-width option
    line-length: 160
    # tab width in spaces. Default to 1.
    tab-width: 1
  unused:
    # treat code as a program (not a library) and report unused exported identifiers; default is false.
    # XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
    # if it's called for subdir of a project it can't find funcs usages. All text editor integrations
    # with golangci-lint call it on a directory with the changed file.
    check-exported: false
  unparam:
    # call graph construction algorithm (cha, rta). In general, use cha for libraries,
    # and rta for programs with main packages. Default is cha.
    algo: cha

    # Inspect exported functions, default is false. Set to true if no external program/library imports your code.
    # XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
    # if it's called for subdir of a project it can't find external interfaces. All text editor integrations
    # with golangci-lint call it on a directory with the changed file.
    check-exported: false
  gocritic:
    enabled-checks:
      - appendCombine
      - argOrder
      - assignOp
      - badCond
      - boolExprSimplify
      - builtinShadow
      - captLocal
      - caseOrder
      - codegenComment
      - commentedOutCode
      - commentedOutImport
      - defaultCaseOrder
      - deprecatedComment
      - docStub
      - dupArg
      - dupBranchBody
      - dupCase
      - dupSubExpr
      - elseif
      - emptyFallthrough
      - equalFold
      - flagDeref
      - flagName
      - hexLiteral
      - indexAlloc
      - initClause
      - methodExprCall
      - nilValReturn
      - octalLiteral
      - offBy1
      - rangeExprCopy
      - regexpMust
      - sloppyLen
      - stringXbytes
      - switchTrue
      - typeAssertChain
      - typeSwitchVar
      - typeUnparen
      - underef
      - unlambda
      - unnecessaryBlock
      - unslice
      - valSwap
      - weakCond

      # Unused
      # - yodaStyleExpr
      # - appendAssign
      # - commentFormatting
      # - emptyStringTest
      # - exitAfterDefer
      # - ifElseChain
      # - hugeParam
      # - importShadow
      # - nestingReduce
      # - paramTypeCombine
      # - ptrToRefParam
      # - rangeValCopy
      # - singleCaseSwitch
      # - sloppyReassign
      # - unlabelStmt
      # - unnamedResult
      # - wrapperFunc

issues:
  # List of regexps of issue texts to exclude, empty list by default.
  # But independently from this option we use default exclude patterns,
  # it can be disabled by `exclude-use-default: false`. To list all
  # excluded by default patterns execute `golangci-lint run --help`
  exclude:
    - composite literal uses unkeyed fields

  exclude-rules:
    # Exclude some linters from running on test files.
    - path: _test\.go$|^tests/|^samples/
      linters:
        - errcheck
        - maligned

  # Independently from option `exclude` we use default exclude patterns,
  # it can be disabled by this option. To list all
  # excluded by default patterns execute `golangci-lint run --help`.
  # Default value for this option is true.
  exclude-use-default: true

  # Maximum issues count per one linter. Set to 0 to disable. Default is 50.
  max-per-linter: 0

  # Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
  max-same-issues: 0
Go environment
$ go version && go env
1.13.4
Verbose output of running
$ golangci-lint run -v
WARN [runner] Can't run linter goanalysis_metalinter: assign: failed prerequisites: inspect@istio.io/istio/pilot/pkg/bootstrap
WARN [runner] Can't run linter unused: buildssa: analysis skipped: errors in package: [/work/pilot/pkg/bootstrap/sidecarinjector.go:34:15: undeclared name: pilotDnsCertDir]

Basically what is happening is we checked in a change to a test that is not run in CI, so all of our tests pass and the change gets merged. golangci-lint lints this file, but skips it because it doesn't build.

I would argue that it should fail if the build fails. This is especially important because it makes the entire lint process skips linting the entire code base because one random file was invalid. See this test, where I finally found what was going on and fixed the bad file, now we fail 50 lints because we haven't had it running for about a month: https://prow.istio.io/view/gcs/istio-prow/pr-logs/pull/istio_istio/19137/lint_istio/4192.

@tpounds tpounds added the bug Something isn't working label Nov 23, 2019
rhcarvalho added a commit to rhcarvalho/sentry-go that referenced this issue Dec 13, 2019
The current recommended installation steps use githubusercontent.com
instead of goreleaser.com. There has been a reported issue in which the
installer code differed between the two sites.
golangci/golangci-lint#575

Additionally, pin to a specific tagged version of the install script to
ensure reproducible installations of the tool.

Use version 1.19.1.

The latest two releases (1.21.0, 1.20.0) have a flaky bug (at least on
macOS) that prevents the linter to run while still exiting with code 0
(success).

```
~/s/sentry-go ❯❯❯ golangci-lint run
WARN [runner] Can't run linter goanalysis_metalinter: assign: failed
prerequisites: inspect@github.com/getsentry/sentry-go/echo
~/s/sentry-go ❯❯❯ golangci-lint run
WARN [runner] Can't run linter goanalysis_metalinter: interfacer: failed
prerequisites: buildssa@github.com/getsentry/sentry-go/echo
```

See
- golangci/golangci-lint#866
- golangci/golangci-lint#827
rhcarvalho added a commit to rhcarvalho/sentry-go that referenced this issue Dec 13, 2019
The current recommended installation steps use githubusercontent.com
instead of goreleaser.com. There has been a reported issue in which the
installer code differed between the two sites.
golangci/golangci-lint#575

Additionally, pin to a specific tagged version of the install script to
ensure reproducible installations of the tool.

Use version 1.19.1.

The latest two releases (1.21.0, 1.20.0) have a flaky bug (at least on
macOS) that prevents the linter to run while still exiting with code 0
(success).

```
~/s/sentry-go ❯❯❯ golangci-lint run
WARN [runner] Can't run linter goanalysis_metalinter: assign: failed
prerequisites: inspect@github.com/getsentry/sentry-go/echo
~/s/sentry-go ❯❯❯ golangci-lint run
WARN [runner] Can't run linter goanalysis_metalinter: interfacer: failed
prerequisites: buildssa@github.com/getsentry/sentry-go/echo
```

See
- golangci/golangci-lint#866
- golangci/golangci-lint#827
rhcarvalho added a commit to getsentry/sentry-go that referenced this issue Dec 13, 2019
The current recommended installation steps use githubusercontent.com
instead of goreleaser.com. There has been a reported issue in which the
installer code differed between the two sites.
golangci/golangci-lint#575

Additionally, pin to a specific tagged version of the install script to
ensure reproducible installations of the tool.

Use version 1.19.1.

The latest two releases (1.21.0, 1.20.0) have a flaky bug (at least on
macOS) that prevents the linter to run while still exiting with code 0
(success).

```
~/s/sentry-go ❯❯❯ golangci-lint run
WARN [runner] Can't run linter goanalysis_metalinter: assign: failed
prerequisites: inspect@github.com/getsentry/sentry-go/echo
~/s/sentry-go ❯❯❯ golangci-lint run
WARN [runner] Can't run linter goanalysis_metalinter: interfacer: failed
prerequisites: buildssa@github.com/getsentry/sentry-go/echo
```

See
- golangci/golangci-lint#866
- golangci/golangci-lint#827
@tpounds tpounds added the false negative An error is not reported when one exists label Dec 30, 2019
@ernado
Copy link
Member

ernado commented Feb 4, 2020

This should error in latest versions, we've switched from warnings to errors in this place.

@ernado ernado closed this as completed Feb 4, 2020
@howardjohn
Copy link
Author

howardjohn commented Feb 4, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working false negative An error is not reported when one exists
Projects
None yet
Development

No branches or pull requests

3 participants