Skip to content

Stylecheck does not respect checks set in settings #2162

Closed
@holmes89

Description

@holmes89

Welcome

  • 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

When trying the following checks on stylecheck the values are not respected.
checks: ["all","ST1*", "ST1000"]
initialisms: ["ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS"]

As found in the [staticcheck](https://staticcheck.io/docs/options#checks) documentation. But it is not respected and I'm not getting the errors I want specifically for ST1000. I see the failures happen specifically using `staticcheck`. 

### Version of golangci-lint

<details>

```console
$ golangci-lint --version
golangci-lint has version 1.41.1 built from a2074809 on 2021-06-19T16:01:50Z

Configuration file

linters:
  enable:
    - gosec
    - stylecheck

linters-settings:
  stylecheck:
    # Select the Go version to target. The default is '1.13'.
    go: "1.15"
    checks: ["all","ST*"]
    initialisms: ["ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS"]


output:
  # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
  format: colored-line-number

  # print lines of code with issue, default is true
  print-issued-lines: false

  # print linter name in the end of issue text, default is true
  print-linter-name: true

Go environment

$ go version && go env
go version go1.16.5 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/xxx/.cache/go-build"
GOENV="/home/xxx/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/xxx/go/pkg/mod"
GONOPROXY="github.com/xxxx/*"
GONOSUMDB="github.com/xxxx/*"
GOOS="linux"
GOPATH="/home/xxxxxx/go"
GOPRIVATE="github.com/xxxx/*"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.5"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/xxxxxx/hello-api/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2203073724=/tmp/go-build -gno-record-gcc-switches"

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /home/jholmes/personal/hello-api /home/jholmes/personal /home/jholmes /home /] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 12 linters: [deadcode errcheck gosec gosimple govet ineffassign staticcheck structcheck stylecheck typecheck unused varcheck] 
INFO [loader] Go packages loading at mode 575 (name|types_sizes|exports_file|files|imports|compiled_files|deps) took 83.103315ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 277.043µs 
INFO [linters context/goanalysis] analyzers took 3.172869466s with top 10 stages: buildir: 2.262937334s, inspect: 159.679017ms, fact_purity: 101.675107ms, fact_deprecated: 94.967104ms, nilness: 88.29342ms, ctrlflow: 72.639529ms, SA5012: 60.374983ms, printf: 59.816934ms, typedness: 59.339292ms, gosec: 4.129992ms 
INFO [runner] Issues before processing: 8, after processing: 1 
INFO [runner] Processors filtering stat (out/in): cgo: 8/8, exclude-rules: 1/8, max_per_file_from_linter: 1/1, max_from_linter: 1/1, source_code: 1/1, path_prettifier: 8/8, skip_files: 8/8, skip_dirs: 8/8, uniq_by_line: 1/1, sort_results: 1/1, filename_unadjuster: 8/8, autogenerated_exclude: 8/8, identifier_marker: 8/8, exclude: 8/8, diff: 1/1, max_same_issues: 1/1, path_shortener: 1/1, nolint: 1/1, severity-rules: 1/1, path_prefixer: 1/1 
INFO [runner] processing took 2.040603ms with stages: exclude-rules: 868.012µs, identifier_marker: 370.146µs, nolint: 278.314µs, autogenerated_exclude: 181.851µs, path_prettifier: 180.416µs, skip_dirs: 88.356µs, source_code: 47.738µs, uniq_by_line: 6.434µs, max_same_issues: 4.162µs, cgo: 3.818µs, path_shortener: 2.893µs, max_from_linter: 2.082µs, filename_unadjuster: 1.962µs, max_per_file_from_linter: 1.06µs, skip_files: 887ns, exclude: 575ns, sort_results: 532ns, diff: 525ns, severity-rules: 521ns, path_prefixer: 319ns 
INFO [runner] linters took 1.605062281s with stages: goanalysis_metalinter: 1.602830634s 
handlers/rest/translate_test.go:54:17: Error return value of `json.Unmarshal` is not checked (errcheck)
INFO File cache stats: 1 entries of total size 1.4KiB 
INFO Memory: 18 samples, avg is 211.3MB, max is 275.4MB 
INFO Execution took 1.693728356s                  
jholmes:hello-api (task/test) $ golangci-lint cache clean
jholmes:hello-api (task/test) $ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /home/jholmes/personal/hello-api /home/jholmes/personal /home/jholmes /home /] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 12 linters: [deadcode errcheck gosec gosimple govet ineffassign staticcheck structcheck stylecheck typecheck unused varcheck] 
INFO [loader] Go packages loading at mode 575 (types_sizes|compiled_files|files|name|deps|exports_file|imports) took 84.826311ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 235.429µs 
INFO [linters context/goanalysis] analyzers took 2.971998267s with top 10 stages: buildir: 2.356277182s, inspect: 117.4764ms, ctrlflow: 93.576716ms, fact_purity: 75.33174ms, fact_deprecated: 75.260014ms, nilness: 71.422356ms, printf: 70.264797ms, SA5012: 52.931865ms, typedness: 34.528512ms, gosec: 2.258842ms 
INFO [runner] Issues before processing: 6, after processing: 0 
INFO [runner] Processors filtering stat (out/in): filename_unadjuster: 6/6, skip_files: 6/6, autogenerated_exclude: 6/6, identifier_marker: 6/6, exclude: 6/6, exclude-rules: 0/6, cgo: 6/6, path_prettifier: 6/6, skip_dirs: 6/6 
INFO [runner] processing took 431.958µs with stages: exclude-rules: 184.879µs, identifier_marker: 111.694µs, autogenerated_exclude: 54.238µs, path_prettifier: 46.02µs, skip_dirs: 29.601µs, cgo: 997ns, nolint: 784ns, filename_unadjuster: 698ns, max_from_linter: 517ns, max_same_issues: 459ns, uniq_by_line: 420ns, exclude: 283ns, diff: 271ns, sort_results: 214ns, source_code: 200ns, skip_files: 183ns, severity-rules: 175ns, path_shortener: 123ns, max_per_file_from_linter: 109ns, path_prefixer: 93ns 
INFO [runner] linters took 1.85330896s with stages: goanalysis_metalinter: 1.852824245s 
INFO File cache stats: 0 entries of total size 0B 
INFO Memory: 21 samples, avg is 188.6MB, max is 275.1MB 
INFO Execution took 1.943924808s       

Code example or link to a public repository

func TranslateHandler(w http.ResponseWriter, r *http.Request) {

Expect error about unexported function not having comment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions