Skip to content

Unable to change staticcheck severity to warning #1856

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
4 tasks done
DONSA opened this issue Mar 17, 2021 · 1 comment
Closed
4 tasks done

Unable to change staticcheck severity to warning #1856

DONSA opened this issue Mar 17, 2021 · 1 comment
Labels
area: severity question Further information is requested

Comments

@DONSA
Copy link

DONSA commented Mar 17, 2021

  • 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).
  • Yes, I've tried with the standalone linter if available. (https://golangci-lint.run/usage/linters/)
Description of the problem

I've deprecated some methods in my code and now the linter is flagging them as errors and returning exit code 1, which makes the pipeline fail.

Version of golangci-lint

golangci-lint has version 1.38.0 built from 507703b on 2021-03-03T13:53:01Z

Config file
run:
  concurrency: 4
  timeout: 5m
  tests: true

  # Skip generated files
  skip-files:
  - graph/generated/generated.go
  - graph/model/models_gen.go

  modules-download-mode: readonly

output:
  format: colored-line-number

linters-settings:
  dogsled:
    max-blank-identifiers: 2
  gofmt:
    simplify: true
  golint:
    min-confidence: 0.8
  govet:
    check-shadowing: true
    enable-all: true
  lll:
    line-length: 140
  #maligned:
    #suggest-new: true
  misspell:
    locale: UK
  unused:
    check-exported: false
  whitespace:
    multi-if: false
    multi-func: false
  #wsl:
  #  allow-multiline-assign: true
  #  allow-trailing-comment: false
  #  force-case-trailing-whitespace: 0

linters:
  disable-all: false
  enable:
  - dogsled
  - gofmt
  - golint
  - govet
  - lll
  #- maligned
  - misspell
  - unused
  - whitespace
  #- wsl
  disable: errcheck
  fast: false

severity:
  default-severity: error
  case-sensitive: false
  rules:
    - linters:
        - staticcheck
      severity: warning
Go environment
go version go1.15.8 darwin/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/nulop/Library/Caches/go-build"
GOENV="/Users/nulop/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/nulop/go/pkg/mod"
GONOPROXY="github.com"
GONOSUMDB="github.com"
GOOS="darwin"
GOPATH="/Users/nulop/go"
GOPRIVATE="github.com"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.15.8/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.15.8/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/nulop/go/src/github.com/donsa/list/go.mod"
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 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/fw/303jhf993zv1wr79_d3w9zm9vhc0f6/T/go-build309553539=/tmp/go-build -gno-record-gcc-switches -fno-common"
Verbose output of running
internal/graphql/resolver.go:366:26: SA1019: measurement.TotalWeightStore is deprecated: Weight is being calculated using weight value in StoreItemsWeight TotalWeightStore calculates how much a total list weighs in metric and imperial for store items (staticcheck)
	storeList.TotalWeight = measurement.TotalWeightStore(list.Store.Items)
Code example or link to a public repository
// Deprecated: Weight is being calculated using weight value in StoreItemsWeight
// TotalWeightStore calculates how much a total list weighs in metric and imperial for store items
func TotalWeightStore(items []*model.StoreItem) *model.TotalWeight {
    ...
}
@DONSA DONSA added the bug Something isn't working label Mar 17, 2021
@ldez
Copy link
Member

ldez commented Mar 17, 2021

Hello,

The warning and the error will result in the same output.

The severity configuration doesn't change the exit code but adds/changes the field severity into some output format.

I recommend adding an exclude rule:

issues:
  exclude-rules:
    - linters:
        - staticcheck
      text: "SA1019: measurement.TotalWeightStore is deprecated"

@ldez ldez closed this as completed Mar 17, 2021
@ldez ldez added question Further information is requested and removed bug Something isn't working labels Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: severity question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants