Skip to content

revive config is not loaded in v1.50.0 #3301

Closed
@itaranto

Description

@itaranto

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

The following config was working fine in v1.49.0, it stopped working in v1.50.0.

Version of golangci-lint

golangci-lint has version 1.50.0 built from 704109c6 on 2022-10-04T10:25:07Z

Configuration file

---
run:
  timeout: 5m
output:
  format: colored-line-number
linters:
  disable-all: true
  enable:
    - goimports
    - govet
    - revive
    - typecheck
linters-settings:
  goimports:
    local-prefixes: github.com/mattn/efm-langserver
  revive:
    ignore-generated-header: true
    severity: warning
    confidence: 0.8
    error-code: 0
    warning-code: 0
    rules:
      - name: add-constant
        arguments:
          - maxLitCount: "3"
            allowStrs: '""'
            allowInts: "0,1,2,3,4,5,0700,0660"
            allowFloats: "0.0,0.,1.0,1.,2.0,2."
      - name: blank-imports
      - name: context-as-argument
      - name: context-keys-type
      - name: dot-imports
      - name: empty-block
      - name: error-naming
      - name: error-return
      - name: error-strings
      - name: errorf
      - name: exported
      - name: if-return
      - name: increment-decrement
      - name: indent-error-flow
      - name: range
      - name: receiver-naming
      - name: redefines-builtin-id
      - name: superfluous-else
      - name: time-naming
      - name: unexported-return
      - name: unreachable-code
      - name: unused-parameter
      - name: var-declaration
      - name: var-naming
issues:
  exclude-rules:
    - linters:
        - goimports
      path: langserver/handler_go112.go
    - linters:
        - goimports
      path: langserver/handler_go113.go
    - linters:
        - revive
      path: '(.+)_test\.go'
      text: "add-constant:"
    - linters:
        - revive
      path: '(.+)_test\.go'
      text: "exported:"
    - linters:
        - revive
      path: langserver/diff.go
      text: "var-naming: don't use leading k in Go names"

Go environment

go version go1.19.2 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ignacio/.cache/go-build"
GOENV="/home/ignacio/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/ignacio/.local/share/go/pkg/mod"
GONOPROXY="gitlab.com/fproj"
GONOSUMDB="gitlab.com/fproj"
GOOS="linux"
GOPATH="/home/ignacio/.local/share/go"
GOPRIVATE="gitlab.com/fproj"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.2"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
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 -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3663421183=/tmp/go-build -gno-record-gcc-switches"

Verbose output of running

INFO [config_reader] Config search paths: [./ /home/ignacio/devel/external/efm-langserver /home/ignacio/devel/external /home/ignacio/devel /home/ignacio /home /]
INFO [config_reader] Used config file .golangci.yaml
INFO [lintersdb] Active 4 linters: [goimports govet revive typecheck]
INFO [loader] Go packages loading at mode 575 (files|name|types_sizes|compiled_files|deps|exports_file|imports) took 82.286823ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 4.98022ms
INFO [linters_context/goanalysis] analyzers took 431.795032ms with top 10 stages: printf: 124.123936ms, ctrlflow: 116.904391ms, inspect: 67.835065ms, the_only_name: 66.282198ms, goimports: 46.268834ms, copylocks: 1.61549ms, lostcancel: 1.347518ms, bools: 741.641µs, composites: 648.817µs, shift: 610.124µs
INFO [runner/max_same_issues] 55/58 issues with text "add-constant: avoid magic numbers like '0', create a named constant for it" were hidden, use --max-same-issues
INFO [runner/max_same_issues] 47/50 issues with text "add-constant: avoid magic numbers like '1', create a named constant for it" were hidden, use --max-same-issues
INFO [runner/max_same_issues] 9/12 issues with text "add-constant: avoid magic numbers like '2', create a named constant for it" were hidden, use --max-same-issues
INFO [runner/max_same_issues] 6/9 issues with text "add-constant: string literal \"\" appears, at least, 3 times, create a named constant for it" were hidden, use --max-same-issues
INFO [runner/max_same_issues] 6/9 issues with text "add-constant: avoid magic numbers like '3', create a named constant for it" were hidden, use --max-same-issues
INFO [runner/max_same_issues] 3/6 issues with text "add-constant: avoid magic numbers like '4', create a named constant for it" were hidden, use --max-same-issues
INFO [runner] Issues before processing: 327, after processing: 26
INFO [runner] Processors filtering stat (out/in): path_shortener: 26/26, identifier_marker: 327/327, nolint: 177/177, diff: 152/152, skip_dirs: 327/327, exclude: 327/327, uniq_by_line: 152/177, severity-rules: 26/26, sort_results: 26/26, filename_unadjuster: 327/327, path_prettifier: 327/327, skip_files: 327/327, max_per_file_from_linter: 152/152, max_same_issues: 26/152, max_from_linter: 26/26, source_code: 26/26, path_prefixer: 26/26, cgo: 327/327, autogenerated_exclude: 327/327, exclude-rules: 177/327
INFO [runner] processing took 35.413188ms with stages: exclude-rules: 15.320874ms, identifier_marker: 12.459367ms, nolint: 6.177727ms, path_prettifier: 586.6µs, autogenerated_exclude: 302.448µs, source_code: 207.92µs, max_same_issues: 123.701µs, skip_dirs: 84.649µs, uniq_by_line: 50.805µs, cgo: 46.387µs, filename_unadjuster: 23.565µs, max_per_file_from_linter: 11.502µs, path_shortener: 11.04µs, max_from_linter: 4.778µs, diff: 382ns, exclude: 340ns, sort_results: 322ns, skip_files: 321ns, severity-rules: 290ns, path_prefixer: 170ns
INFO [runner] linters took 850.312524ms with stages: goanalysis_metalinter: 814.799792ms
main.go:36:37: add-constant: avoid magic numbers like '1', create a named constant for it (revive)
	flag.IntVar(&loglevel, "loglevel", 1, "loglevel")
	                                   ^
main.go:47:17: add-constant: string literal "" appears, at least, 3 times, create a named constant for it (revive)
	if yamlfile == "" {
	               ^
main.go:59:30: add-constant: avoid magic numbers like '0700', create a named constant for it (revive)
		if err := os.MkdirAll(dir, 0700); err != nil {
		                           ^
main.go:81:11: add-constant: avoid magic numbers like '0', create a named constant for it (revive)
		os.Exit(0)
		        ^
main.go:84:20: add-constant: avoid magic numbers like '0', create a named constant for it (revive)
	if flag.NArg() != 0 {
	                  ^
main.go:86:11: add-constant: avoid magic numbers like '1', create a named constant for it (revive)
		os.Exit(1)
		        ^
main.go:98:23: add-constant: avoid magic numbers like '0', create a named constant for it (revive)
	if config.LogLevel > 0 {
	                     ^
main.go:105:69: add-constant: avoid magic numbers like '0660', create a named constant for it (revive)
		f, err := os.OpenFile(logfile, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0660)
		                                                                  ^
main.go:111:18: add-constant: avoid magic numbers like '5', create a named constant for it (revive)
		if loglevel >= 5 {
		               ^
main.go:116:43: add-constant: avoid magic numbers like '5', create a named constant for it (revive)
	if quiet && (logfile == "" || loglevel < 5) {
	                                         ^
langserver/config.go:29:38: add-constant: avoid magic numbers like '2', create a named constant for it (revive)
	if err != nil || config1.Version == 2 {
	                                    ^
langserver/handle_text_document_did_change.go:20:35: add-constant: avoid magic numbers like '1', create a named constant for it (revive)
	if len(params.ContentChanges) == 1 {
	                                 ^
langserver/handle_text_document_completion.go:71:34: add-constant: string literal "" appears, at least, 3 times, create a named constant for it (revive)
		if config.CompletionCommand == "" {
		                               ^
langserver/handle_text_document_completion.go:101:20: add-constant: avoid magic numbers like '3', create a named constant for it (revive)
		if h.loglevel >= 3 {
		                 ^
langserver/handle_text_document_hover.go:102:29: add-constant: string literal "" appears, at least, 3 times, create a named constant for it (revive)
		if config.HoverCommand == "" {
		                          ^
langserver/handle_text_document_hover.go:127:20: add-constant: avoid magic numbers like '3', create a named constant for it (revive)
		if h.loglevel >= 3 {
		                 ^
langserver/handle_text_document_symbol.go:136:20: add-constant: avoid magic numbers like '3', create a named constant for it (revive)
		if h.loglevel >= 3 {
		                 ^
langserver/handle_text_document_symbol.go:161:24: add-constant: string literal "windows" appears, at least, 3 times, create a named constant for it (revive)
				if runtime.GOOS == "windows" {
				                   ^
langserver/handle_text_document_symbol.go:168:39: add-constant: avoid magic numbers like '2', create a named constant for it (revive)
				token := strings.SplitN(m.M, "!", 2)
				                                  ^
langserver/handle_text_document_symbol.go:170:22: add-constant: avoid magic numbers like '2', create a named constant for it (revive)
				if len(token) == 2 {
				                 ^
langserver/handle_text_document_definition.go:47:39: add-constant: avoid magic numbers like '4', create a named constant for it (revive)
		token := strings.SplitN(text, "\t", 4)
		                                    ^
langserver/handle_text_document_definition.go:48:19: add-constant: avoid magic numbers like '4', create a named constant for it (revive)
		if len(token) < 4 {
		                ^
langserver/handle_text_document_formatting.go:34:20: add-constant: avoid magic numbers like '4', create a named constant for it (revive)
		if h.loglevel >= 4 {
		                 ^
langserver/handle_text_document_formatting.go:144:29: add-constant: string literal ":" appears, at least, 3 times, create a named constant for it (revive)
			h.logger.Println(command+":", string(b))
			                         ^
langserver/handler.go:295:41: add-constant: string literal "/" appears, at least, 3 times, create a named constant for it (revive)
					marker = strings.TrimRight(marker, "/")
					                                   ^
langserver/handler.go:524:23: add-constant: string literal "windows" appears, at least, 3 times, create a named constant for it (revive)
			if runtime.GOOS == "windows" {
			                   ^
INFO File cache stats: 9 entries of total size 41.3KiB
INFO Memory: 11 samples, avg is 98.3MB, max is 137.5MB
INFO Execution took 944.721992ms

Code example or link to a public repository

https://github.com/itaranto/efm-langserver/tree/replace-golint-with-revive

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions