How to configure upperCaseConst
for the var-naming
rule within golangci-lint
for revive?
#4092
-
Welcome
Description of the problemI'm confused how to configure The I tried this in my
If I run Version of golangci-lint$ golangci-lint --version
golangci-lint has version 1.54.2 built with go1.21.0 from 411e0bbb on 2023-08-21T12:04:32Z Configuration
linters-settings:
revive:
rules:
- name: unexported-return
disabled: true
- name: var-naming
arguments:
- []
- []
- [{upperCaseConst=true}]
linters:
enable:
- revive
[rule.package-comments]
[rule.var-naming]
arguments = [[], [], [{upperCaseConst=true}]] Go environment$ go version && go env
go version go1.20.3 darwin/arm64
GO111MODULE=""
GOARCH="arm64"
GOBIN="/Users/me/go/bin"
GOCACHE="/Users/me/Library/Caches/go-build"
GOENV="/Users/me/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/me/go/pkg/mod"
GONOPROXY="github.com/mycompany/*"
GONOSUMDB="github.com/mycompany/*"
GOOS="darwin"
GOPATH="/Users/me/go"
GOPRIVATE="github.com/mycompany/*"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/homebrew/Cellar/go/1.20.3/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.20.3/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.20.3"
GCCGO="gccgo"
AR="ar"
CC="cc"
CXX="c++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/v4/3h3xcz0n74x0_c7fwr00cln40000gq/T/go-build2106927852=/tmp/go-build -gno-record-gcc-switches -fno-common" Verbose output of running$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /Users/me/Documents/Repositories_external/golangci-lint-revive-upperCaseConst-demo /Users/me/Documents/Repositories_external /Users/me/Documents /Users/me /Users /]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 7 linters: [errcheck gosimple govet ineffassign revive staticcheck unused]
INFO [loader] Go packages loading at mode 575 (deps|exports_file|imports|compiled_files|files|name|types_sizes) took 237.375416ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 984.583µs
INFO [linters_context/goanalysis] analyzers took 719.635916ms with top 10 stages: buildir: 505.977996ms, inspect: 32.040998ms, printf: 31.530294ms, ctrlflow: 30.485089ms, fact_deprecated: 27.137495ms, nilness: 22.585125ms, SA5012: 22.257791ms, fact_purity: 21.420751ms, typedness: 16.309542ms, the_only_name: 2.912458ms
INFO [runner] Processors filtering stat (out/in): filename_unadjuster: 1/1, fixer: 1/1, severity-rules: 1/1, path_prettifier: 1/1, autogenerated_exclude: 1/1, uniq_by_line: 1/1, diff: 1/1, max_same_issues: 1/1, path_shortener: 1/1, cgo: 1/1, identifier_marker: 1/1, exclude-rules: 1/1, max_per_file_from_linter: 1/1, source_code: 1/1, path_prefixer: 1/1, sort_results: 1/1, skip_files: 1/1, skip_dirs: 1/1, exclude: 1/1, nolint: 1/1, max_from_linter: 1/1
INFO [runner] processing took 238.501µs with stages: path_prettifier: 85.376µs, nolint: 34.375µs, identifier_marker: 28.959µs, autogenerated_exclude: 28.875µs, exclude-rules: 26.75µs, source_code: 19.541µs, skip_dirs: 8.917µs, uniq_by_line: 1.208µs, max_same_issues: 792ns, cgo: 667ns, max_from_linter: 583ns, path_shortener: 375ns, filename_unadjuster: 334ns, exclude: 292ns, severity-rules: 291ns, max_per_file_from_linter: 250ns, skip_files: 209ns, sort_results: 208ns, fixer: 208ns, diff: 208ns, path_prefixer: 83ns
INFO [runner] linters took 537.616959ms with stages: goanalysis_metalinter: 537.327875ms
main.go:5:7: var-naming: don't use ALL_CAPS in Go names; use CamelCase (revive)
const NOUN_SUBJECT = "World"
^
INFO File cache stats: 1 entries of total size 116B
INFO Memory: 9 samples, avg is 112.5MB, max is 210.9MB
INFO Execution took 787.058167ms A minimal reproducible example or link to a public repositoryI've made an MVE repository here. You can view the output of the golangci-lint GitHub action on the main branch here. Validation
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors. |
Beta Was this translation helpful? Give feedback.
-
Hello, There are 2 problems with the configuration of revive: revive only understands structures filled with a TOML parser, and the options used untyped elements with mixed types. These approaches are not Go friendly or idiomatic. So the configuration of revive, as suggested in the revive doc, cannot work with golangci-lint. We have a dedicated section for revive configuration in our doc: https://golangci-lint.run/usage/linters/#revive This option seems relatively new, I need to find the right syntax. |
Beta Was this translation helpful? Give feedback.
This option doesn't work because it has been added in v1.3.3.
Golangci-lint (v1.54.2) use revive v1.3.2.
I feel like revive doesn't really follow semver.