Skip to content

revive add-constant arguments can't be parsed #2002

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
fighterlyt opened this issue May 19, 2021 · 0 comments · Fixed by #2003
Closed
4 tasks done

revive add-constant arguments can't be parsed #2002

fighterlyt opened this issue May 19, 2021 · 0 comments · Fixed by #2003
Assignees
Labels
bug Something isn't working

Comments

@fighterlyt
Copy link

fighterlyt commented May 19, 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/)
revive add-constant arguments can't be parsed

because the arguments has form {},so it is recognized as map[interface{}]interface{}

ERRO Failed to init hash salt: failed to calculate config salt: failed to json marshal config linter settings: json: unsupported type: map[interface {}]interface {} 
Version of golangci-lint
$ golangci-lint --version
# golangci-lint has version 1.40.1 built from 625445b on 2021-05-14T16:27:59Z
Config file
$ cat .golangci.yml
# linters-settings:
  depguard:
    list-type: blacklist
    packages:
      # logging is allowed only by logutils.Log, logrus
      # is allowed to use only in logutils package
      - github.com/sirupsen/logrus
    packages-with-error-message:
      - github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
  dupl:
    threshold: 100
  funlen:
    lines: 100
    statements: 50
  exhaustive:
    # check switch statements in generated files also
    check-generated: false
    # indicates that switch statements are to be considered exhaustive if a
    # 'default' case is present, even if all enum members aren't listed in the
    # switch
    default-signifies-exhaustive: true
  gci:
    local-prefixes: github.com/golangci/golangci-lint
  goconst:
    min-len: 2
    min-occurrences: 2
  gocritic:
    enabled-tags:
      - diagnostic
      - experimental
      - opinionated
      - performance
      - style
    disabled-checks:
      - dupImport # https://github.com/go-critic/go-critic/issues/845
      - ifElseChain
      - octalLiteral
      - whyNoLint
      - wrapperFunc
      - hugeParam
  gocyclo:
    min-complexity: 15
  goimports:
    local-prefixes: github.com/golangci/golangci-lint
  revive:
  # see https://github.com/mgechev/revive#available-rules for details.
    ignore-generated-header: true
    severity: warning
    confidence: 0.8
    error-code: 2
    warning-code: 1
    rules:
      - name: indent-error-flow
      - name: add-constant
        arguments: [{maxLitCount = "3",allowStrs ="\"\"",allowInts="0",allowFloats="0.0"}]
      - name: atomic
      - name: bare-return
      - name: blank-imports
      - name: call-to-gc
      - name: cognitive-complexity
        arguments: [7]
      - name: confusing-naming
      - name: constant-logical-expr
      - name: context-as-argument
      - name: context-keys-type
      - name: cyclomatic
        arguments: [7]
      - name: deep-exit
      - name: defer
        arguments: [["call-chain","loop","recover","return","method-call"]]
      - name: dot-imports
      - name: duplicated-imports
      - name: early-return
      - name: empty-block
      - name: empty-lines
      - name: error-naming
      - name: error-return
      - name: error-strings
      - name: errorf
      - name: exported
      - name: flag-parameter
      - name: function-result-limit
        arguments: [3]
      - name: function-length
        arguments: [50,50]

  gomnd:
    settings:
      mnd:
        # don't include the "operation" and "assign"
        checks: argument,case,condition,return
  govet:
    check-shadowing: true
    settings:
      printf:
        funcs:
          - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
          - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
          - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
          - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
  lll:
    line-length: 140
  maligned:
    suggest-new: true
  misspell:
    locale: US
  nolintlint:
    allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
    allow-unused: false # report any unused nolint directives
    require-explanation: false # don't require an explanation for nolint directives
    require-specific: false # don't require nolint directives to be specific about which linter is being skipped

linters:
  # please, do not use `enable-all`: it's deprecated and will be removed soon.
  # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
  disable-all: true
  enable:
    - bodyclose
    - deadcode
    - depguard
    - dogsled
    - dupl
    - errcheck
    - exportloopref
    - exhaustive
    - funlen
    - gochecknoinits
    - goconst
    - gocritic
    - gocyclo
    - gofmt
    - goimports
    - revive
    - gomnd
    - goprintffuncname
    - gosec
    - gosimple
    - govet
    - ineffassign
    - lll
    - misspell
    - nakedret
    - noctx
    # - nolintlint
    - rowserrcheck
    - staticcheck
    - structcheck
    - stylecheck
    - typecheck
    - unconvert
    - unparam
    - unused
    - varcheck
    - whitespace

    # don't enable:
    # - asciicheck
    # - scopelint
    # - gochecknoglobals
    # - gocognit
    # - godot
    # - godox
    # - goerr113
    # - interfacer
    # - maligned
    # - nestif
    # - prealloc
    # - testpackage
    # - revive
    - wsl

issues:
  # Excluding configuration per-path, per-linter, per-text and per-source
  exclude-rules:
    - path: _test\.go
      linters:
        - gomnd

    # https://github.com/go-critic/go-critic/issues/926
    - linters:
        - gocritic
      text: "unnecessaryDefer:"

run:
  skip-dirs:
    - test/testdata_etc
    - internal/cache
    - internal/renameio
    - internal/robustio
Go environment
$ go version && go env
# go version go1.16.3 darwin/amd64
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/liuyuntang/Library/Caches/go-build"
GOENV="/Users/liuyuntang/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/liuyuntang/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/liuyuntang/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.16.3/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.16.3/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.3"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/liuyuntang/projects/quantitative-transaction/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 -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/m0/c6dgtmld64j08nqt8hk15czc0000gn/T/go-build3976696894=/tmp/go-build -gno-record-gcc-switches -fno-common"
Verbose output of running
$ golangci-lint cache clean
$ golangci-lint run -v
# ERRO Failed to init hash salt: failed to calculate config salt: failed to json marshal config linter settings: json: unsupported type: map[interface {}]interface {} 
Code example or link to a public repository
// add your code here
@fighterlyt fighterlyt added the bug Something isn't working label May 19, 2021
@ldez ldez self-assigned this May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants