code.pfad.fr/gohmekit@v0.2.1/.golangci.yml (about)

     1  ## Golden config for golangci-lint v1.43.0
     2  #
     3  # This is the best config for golangci-lint based on my experience and opinion.
     4  # It is very strict, but not extremely strict.
     5  # Feel free to adopt and change it for your needs.
     6  
     7  run:
     8    timeout: 1m # default 1m
     9  
    10  linters-settings:
    11    errcheck:
    12      check-type-assertions: true # default false
    13      check-blank: false # default false
    14      ignore: "fmt:.*" # default fmt:.*
    15      exclude-functions: # see https://github.com/kisielk/errcheck#excluding-functions for detail
    16        - (github.com/go-kit/log.Logger).Log
    17    gosimple:
    18      go: "1.17" # default 1.13
    19      checks: ["*"] # https://staticcheck.io/docs/options#checks # default ["*"]
    20    govet:
    21      enable-all: true
    22      disable:
    23        - fieldalignment # too strict
    24      settings:
    25        shadow:
    26          strict: false # default false
    27    staticcheck:
    28      go: "1.17" # default 1.13
    29      checks: ["*"] # https://staticcheck.io/docs/options#checks # default ["*"]
    30    unused:
    31      check-exported: false # default false # TODO: enable after fixing false positives
    32  
    33    cyclop:
    34      max-complexity: 30 # the maximal code complexity to report # default 10
    35      package-average: 10.0 # the maximal average package complexity. If it's higher than 0.0 (float) the check is enabled # default 0.0
    36      skip-tests: false # should ignore tests # default false
    37    dupl:
    38      threshold: 150 # default 150
    39    errorlint:
    40      # Check whether fmt.Errorf uses the %w verb for formatting errors. See the readme for caveats
    41      errorf: true # default true
    42      # Check for plain type assertions and type switches
    43      asserts: true # default true
    44      # Check for plain error comparisons
    45      comparison: true # default true
    46    exhaustive:
    47      check-generated: false # indicates whether to check switch statements in generated Go source files # default false
    48      default-signifies-exhaustive: true # if true, switch is considered exhaustive as long as a 'default' case is present # default false
    49      ignore-pattern: "" # enum members matching regexp (including import path) do not require a case clause to satisfy exhaustiveness # default ""
    50    funlen:
    51      lines: 100 # default 60
    52      statements: 50 # default 40
    53    gocognit:
    54      min-complexity: 20 # minimal code complexity to report, 30 by default (but we recommend 10-20)
    55    goconst:
    56      match-constant: true # look for existing constants matching the values # default true
    57      min-len: 3 # minimal length of string constant # default 3
    58      min-occurrences: 3 # minimum occurrences of constant string count to trigger issue # default 3
    59      numbers: true # search also for duplicated numbers # default false
    60      min: 3 # minimum value, only works with goconst.numbers # default 3
    61      max: 3 # maximum value, only works with goconst.numbers # default 3
    62      ignore-calls: true # ignore when constant is not used as function argument # default true
    63      ignore-tests: false # ignore test files # default false
    64    gocritic:
    65      settings:
    66        captLocal:
    67          paramsOnly: false # whether to restrict checker to params only # default true
    68        elseif:
    69          skipBalanced: false # whether to skip balanced if-else pairs # default true
    70        #hugeParam: # disabled by default
    71        #  sizeThreshold: 80 # size in bytes that makes the warning trigger # default 80
    72        #nestingReduce: # disabled by default
    73        #  bodyWidth: 5 # min number of statements inside a branch to trigger a warning # default 5
    74        #rangeExprCopy: # disabled by default
    75        #  sizeThreshold: 512 # size in bytes that makes the warning trigger # default 512
    76        #  skipTestFuncs: true # whether to check test functions # default true
    77        #rangeValCopy: # disabled by default
    78        #  sizeThreshold: 128 # size in bytes that makes the warning trigger # default 128
    79        #  skipTestFuncs: true # whether to check test functions # default true
    80        #ruleguard: # disabled by default
    81        #  rules: "" # path to a gorules file # default ""
    82        #tooManyResultsChecker: # disabled by default
    83        #  maxResults: 5 # maximum number of results # default 5
    84        #truncateCmp: # disabled by default
    85        #  skipArchDependent: true # whether to skip int/uint/uintptr types # default true
    86        underef:
    87          skipRecvDeref: false # whether to skip (*x).method() calls where x is a pointer receiver # default true
    88        #unnamedResult: # disabled by default
    89        #  checkExported: false # whether to check exported functions # default false
    90    gocyclo:
    91      min-complexity: 30 # default 30
    92    godot:
    93      scope: declarations # comments to be checked: `declarations` (default), `toplevel`, or `all`
    94      exclude: [] # list of regexps for excluding particular comment lines from check # default []
    95      capital: false # check that each sentence starts with a capital letter # default false
    96    gomnd:
    97      settings:
    98        mnd:
    99          # the list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.
   100          checks: argument,case,condition,operation,return,assign # default argument,case,condition,operation,return,assign
   101          ignored-numbers: 0,1 # default 0,1
   102          # ignored-files: "_test.go" # default "_test.go" # don't use this setting because of bug inside gomnd
   103          ignored-functions:
   104            - "time.Date" # default "time.Date"
   105            - "strconv.FormatInt"
   106            - "strconv.ParseUint"
   107    gomoddirectives:
   108      replace-allow-list:
   109        - github.com/hirochachacha/go-smb2
   110      replace-local: false # allow local `replace` directives # default false
   111      exclude-forbidden: false # forbid the use of `exclude` directives # default false
   112      retract-allow-no-explanation: false # allow to use `retract` directives without explanation # default false
   113    gomodguard:
   114      allowed:
   115        modules: [] # default []
   116        domains: [] # default []
   117      blocked:
   118        modules:
   119          - github.com/golang/protobuf:
   120              recommendations:
   121                - google.golang.org/protobuf
   122              reason: "see https://developers.google.com/protocol-buffers/docs/reference/go/faq#modules"
   123          - github.com/satori/go.uuid:
   124              recommendations:
   125                - github.com/google/uuid
   126              reason: "satori's package is not maintained"
   127          - github.com/gofrs/uuid:
   128              recommendations:
   129                - github.com/google/uuid
   130              reason: "see recommendation from dev-infra team: https://confluence.gtforge.com/x/gQI6Aw"
   131        versions: [] # default []
   132        local_replace_directives: true # default false
   133    depguard:
   134      list-type: blacklist
   135      include-go-root: true # to check stdlib packages as well
   136      packages-with-error-message:
   137        - io/ioutil: "replaced by io ans os packages since Go 1.16: https://tip.golang.org/doc/go1.16#ioutil"
   138    makezero:
   139      always: false # default false
   140    maligned:
   141      suggest-new: true # default false
   142    misspell:
   143      locale: us
   144      ignore-words: "" # default: ""
   145    nakedret:
   146      max-func-lines: 0 # default 30
   147    nestif:
   148      min-complexity: 4 # default 5
   149    nilnil:
   150      checked-types: # default [ptr, func, iface, map, chan]
   151        - ptr
   152        - func
   153        - iface
   154        - map
   155        - chan
   156    nolintlint:
   157      allow-unused: false # default false
   158      allow-leading-space: true # default true
   159      allow-no-explanation: [funlen, gocognit] # default []
   160      require-explanation: false # default false
   161      require-specific: true # default false
   162    prealloc:
   163      simple: false # default true
   164      range-loops: true # default true
   165      for-loops: false # default false
   166    predeclared:
   167      ignore: "" # comma-separated list of predeclared identifiers to not report on # default ""
   168      q: false # include method names and field names (i.e., qualified names) in checks # default false
   169    promlinter:
   170      # Promlinter cannot infer all metrics name in static analysis.
   171      # Enable strict mode will also include the errors caused by failing to parse the args.
   172      strict: false # default false
   173      # Please refer to https://github.com/yeya24/promlinter#usage for detailed usage.
   174      disabled-linters:
   175      #  - "Help"
   176      #  - "MetricUnits"
   177      #  - "Counter"
   178      #  - "HistogramSummaryReserved"
   179      #  - "MetricTypeInName"
   180      #  - "ReservedChars"
   181      #  - "CamelCase"
   182      #  - "lintUnitAbbreviations"
   183    revive: # default rules are ignored if any of following settings is defined
   184      ignore-generated-header: false # when set to false, ignores files with "GENERATED" header, similar to golint # default false
   185      #confidence: 0.3 # default failure confidence, this means that linting errors with less than X confidence will be ignored # default 0.8
   186      #severity: "warning" # minimal rule severity to fail {"error", "warning"} # default "warning"
   187      #enable-all-rules: false # default false
   188      # There is a list of default rules, but it can be redefined, see https://github.com/mgechev/revive#available-rules
   189      #rules:
   190      #  - name: "xxx"
   191      #    disabled: false
   192      #    arguments: []
   193      #    severity: "xxx"
   194      # allows to redefine rule severity (without changing default rules list)
   195      #directives:
   196      #  - name: "xxx"
   197      #    severity: "xxx"
   198      rules:
   199        # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-naming
   200        - name: var-naming
   201          disabled: true
   202    rowserrcheck:
   203      packages:
   204        - database/sql
   205        - github.com/jmoiron/sqlx
   206    stylecheck:
   207      go: "1.17" # default 1.13
   208      checks: ["all", "-ST1003"] # https://staticcheck.io/docs/options#checks # default ["*"]
   209      dot-import-whitelist: [] # https://staticcheck.io/docs/options#dot_import_whitelist  # default []
   210      initialisms: [
   211          "ACL",
   212          "API",
   213          "ASCII",
   214          "CPU",
   215          "CSS",
   216          "DNS",
   217          "EOF",
   218          "GUID",
   219          "HTML",
   220          "HTTP",
   221          "HTTPS",
   222          "ID",
   223          "IP",
   224          "JSON",
   225          "QPS",
   226          "RAM",
   227          "RPC",
   228          "SLA",
   229          "SMTP",
   230          "SQL",
   231          "SSH",
   232          "TCP",
   233          "TLS",
   234          "TTL",
   235          "UDP",
   236          "UI",
   237          "GID",
   238          "UID",
   239          "UUID",
   240          "URI",
   241          "URL",
   242          "UTF8",
   243          "VM",
   244          "XML",
   245          "XMPP",
   246          "XSRF",
   247          "XSS",
   248        ] # https://staticcheck.io/docs/options#initialisms
   249      http-status-code-whitelist: ["200", "400", "404", "500"] # https://staticcheck.io/docs/options#http_status_code_whitelist
   250    tenv:
   251      all: true # check all functions in _test.go, not only test functions # default false
   252    testpackage:
   253      skip-regexp: (export|internal)_test\.go # default (export|internal)_test\.go
   254    unparam:
   255      check-exported: true # default false
   256    wrapcheck:
   257      ignoreSigs: [] # specifies substrings of signatures to ignore. Overrides default https://github.com/tomarrell/wrapcheck#configuration # default []
   258      ignoreSigRegexps: [] # this is similar to the ignoreSigs, but gives slightly more flexibility # default []
   259      ignorePackageGlobs: [] # see https://github.com/tomarrell/wrapcheck#configuration # default []
   260    gosec:
   261      excludes:
   262        - G102 # binds all network
   263        - G112 # Slowloris
   264  
   265  linters:
   266    disable-all: true
   267    enable:
   268      ## enabled by default
   269      - errcheck
   270      - gosimple
   271      - govet
   272      - ineffassign
   273      - staticcheck
   274      - typecheck
   275      - unused
   276      ## disabled by default
   277      - asciicheck
   278      - bidichk
   279      - bodyclose
   280      - contextcheck
   281      - cyclop
   282      - dupl
   283      - durationcheck
   284      - errname
   285      - errorlint
   286      - exhaustive
   287      - exportloopref
   288      # - funlen
   289      # - forbidigo
   290      # - gochecknoglobals
   291      - gochecknoinits
   292      # - gocognit
   293      - goconst
   294      - gocritic
   295      - gocyclo
   296      - godot
   297      - goimports
   298      # - gomnd
   299      - gomoddirectives
   300      - gomodguard
   301      - goprintffuncname
   302      - gosec
   303      - makezero
   304      - nakedret
   305      - nestif
   306      - nilerr
   307      - nilnil
   308      # - noctx
   309      - nolintlint
   310      - prealloc
   311      - predeclared
   312      - promlinter
   313      - revive
   314      - rowserrcheck
   315      - sqlclosecheck
   316      - stylecheck
   317      - tenv
   318      - tparallel
   319      - unconvert
   320      - unparam
   321      - wastedassign
   322      - whitespace
   323      ## disabled
   324      - depguard # replaced with gomodguard for non stdlib: https://github.com/ryancurrah/gomodguard/issues/12
   325      #- dogsled # is not used - сhecks assignments with too many blank identifiers (e.g. x, _, _, _, := f())
   326      #- exhaustivestruct # too strict - finds structs that have uninitialized fields # TODO: maybe enable for some packages?
   327      #- forcetypeassert # errcheck is used instead
   328      #- gci # is not used - sorts imports
   329      #- godox # is not used - complains about TODOs in comments
   330      #- goerr113 # too strict - checks the errors handling expressions
   331      #- gofmt # replaced with goimports
   332      #- gofumpt # replaced with goimports, gofumports is not available yet
   333      #- goheader # is not used - checks that each file has the licence at the beginning
   334      #- golint # deprecated - revive is used instead
   335      #- ifshort # is not used - checks that your code uses short syntax for if-statements whenever possible
   336      #- importas # is not used - enforces consistent import aliases
   337      #- interfacer # deprecated and has false positives
   338      #- ireturn # good, but too strict - accept interfaces, return concrete types
   339      #- maligned # deprecated
   340      #- misspell # useless - correct commonly misspelled English words... quickly
   341      #- nlreturn # too strict - requires a new line before return and branch statements
   342      #- paralleltest # too many false positives
   343      #- scopelint # deprecated
   344      #- tagliatelle # is not used - checks the struct tags
   345      #- thelper # is not used - requires to use t.Helper()
   346      #- wrapcheck # too strict - requires wrapping errors from external packages (even from the same repo) and interfaces
   347      #- varnamelen # great idea, but too many false positives - checking length of variable's name matches its usage scope
   348      #- wsl # too strict - enforces empty lines at the right places
   349  
   350  output:
   351    uniq-by-line: false # default true
   352  
   353  issues:
   354    new-from-rev: d4a1258
   355    max-issues-per-linter: 0
   356    max-same-issues: 0
   357    exclude-rules:
   358      - source: "^//\\s*go:generate\\s"
   359        linters: lll
   360      - source: "(noinspection|TODO)"
   361        linters: godot
   362      - source: "//noinspection"
   363        linters: gocritic
   364      - source: "^\\s+if _, ok := err\\.\\([^.]+\\.InternalError\\); ok {"
   365        linters: errorlint
   366      - path: "_test\\.go"
   367        linters:
   368          - bodyclose
   369          - dupl
   370          - funlen
   371          - goconst
   372          - noctx
   373          - wrapcheck