github.com/wangyougui/gf/v2@v2.6.5/.golangci.yml (about)

     1  ## This file contains all available configuration options
     2  ## with their default values.
     3  
     4  # See https://github.com/golangci/golangci-lint#config-file
     5  # See https://golangci-lint.run/usage/configuration/
     6  
     7  # Options for analysis running.
     8  run:
     9    # Exit code when at least one issue was found.
    10    # Default: 1
    11    issues-exit-code: 2
    12  
    13    # Include test files or not.
    14    # Default: true
    15    tests: false
    16  
    17    # Which dirs to skip: issues from them won't be reported.
    18    # Can use regexp here: `generated.*`, regexp is applied on full path.
    19    # Default value is empty list,
    20    # but default dirs are skipped independently of this option's value (see skip-dirs-use-default).
    21    # "/" will be replaced by current OS file path separator to properly work on Windows.
    22    skip-dirs: []
    23  
    24    # Which files to skip: they will be analyzed, but issues from them won't be reported.
    25    # Default value is empty list,
    26    # but there is no need to include all autogenerated files,
    27    # we confidently recognize autogenerated files.
    28    # If it's not please let us know.
    29    # "/" will be replaced by current OS file path separator to properly work on Windows.
    30    skip-files: []
    31  
    32  
    33  # Main linters configurations.
    34  # See https://golangci-lint.run/usage/linters
    35  linters:
    36    # Disable all default enabled linters.
    37    disable-all: true
    38    # Custom enable linters we want to use.
    39    enable:
    40      - errcheck      # Errcheck is a program for checking for unchecked errors in go programs.
    41      - errchkjson    # Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted.
    42      - funlen        # Tool for detection of long functions
    43      - goconst       # Finds repeated strings that could be replaced by a constant
    44      - gocritic      # Provides diagnostics that check for bugs, performance and style issues.
    45      - gofmt         # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification
    46      - gosimple      # Linter for Go source code that specializes in simplifying code
    47      - govet         # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
    48      - misspell      # Finds commonly misspelled English words in comments
    49      - nolintlint    # Reports ill-formed or insufficient nolint directives
    50      - revive        # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.
    51      - staticcheck   # It's a set of rules from staticcheck. It's not the same thing as the staticcheck binary.
    52      - typecheck     # Like the front-end of a Go compiler, parses and type-checks Go code
    53      - usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library.
    54      - whitespace    # Tool for detection of leading and trailing whitespace
    55  
    56  
    57  issues:
    58    exclude-rules:
    59      # helpers in tests often (rightfully) pass a *testing.T as their first argument
    60      - path: _test\.go
    61        text: "context.Context should be the first parameter of a function"
    62        linters:
    63          - revive
    64      # Yes, they are, but it's okay in a test
    65      - path: _test\.go
    66        text: "exported func.*returns unexported type.*which can be annoying to use"
    67        linters:
    68          - revive
    69      # https://github.com/go-critic/go-critic/issues/926
    70      - linters:
    71          - gocritic
    72        text: "unnecessaryDefer:"
    73  
    74  
    75  # https://golangci-lint.run/usage/linters
    76  linters-settings:
    77    # https://golangci-lint.run/usage/linters/#misspell
    78    misspell:
    79      locale: US
    80      ignore-words:
    81        - cancelled
    82  
    83    # https://golangci-lint.run/usage/linters/#revive
    84    # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md
    85    revive:
    86      ignore-generated-header: true
    87      severity: error
    88      rules:
    89        - name: atomic
    90        - name: line-length-limit
    91          severity: error
    92          arguments: [ 380 ]
    93        - name: unhandled-error
    94          severity: warning
    95          disabled: true
    96          arguments: []
    97        - name: var-naming
    98          severity: warning
    99          disabled: true
   100          arguments:
   101            # AllowList
   102            - [ "ID","URL","IP","HTTP","JSON","API","UID","Id","Api","Uid","Http","Json","Ip","Url" ]
   103            # DenyList
   104            - [ "VM" ]
   105        - name: string-format
   106          severity: warning
   107          disabled: false
   108          arguments:
   109            - - 'core.WriteError[1].Message'
   110              - '/^([^A-Z]|$)/'
   111              - must not start with a capital letter
   112            - - 'fmt.Errorf[0]'
   113              - '/(^|[^\.!?])$/'
   114              - must not end in punctuation
   115            - - panic
   116              - '/^[^\n]*$/'
   117              - must not contain line breaks
   118        - name: function-result-limit
   119          severity: warning
   120          disabled: false
   121          arguments: [ 4 ]
   122  
   123    # https://golangci-lint.run/usage/linters/#funlen
   124    funlen:
   125      # Checks the number of lines in a function.
   126      # If lower than 0, disable the check.
   127      # Default: 60
   128      lines: 330
   129      # Checks the number of statements in a function.
   130      # If lower than 0, disable the check.
   131      # Default: 40
   132      statements: -1
   133  
   134    # https://golangci-lint.run/usage/linters/#goconst
   135    goconst:
   136      # Minimal length of string constant.
   137      # Default: 3
   138      min-len: 4
   139      # Minimum occurrences of constant string count to trigger issue.
   140      # Default: 3
   141      # For subsequent optimization, the value is reduced.
   142      min-occurrences: 30
   143      # Ignore test files.
   144      # Default: false
   145      ignore-tests: true
   146      # Look for existing constants matching the values.
   147      # Default: true
   148      match-constant: false
   149      # Search also for duplicated numbers.
   150      # Default: false
   151      numbers: true
   152      # Minimum value, only works with goconst.numbers
   153      # Default: 3
   154      min: 5
   155      # Maximum value, only works with goconst.numbers
   156      # Default: 3
   157      max: 20
   158      # Ignore when constant is not used as function argument.
   159      # Default: true
   160      ignore-calls: false
   161  
   162    # https://golangci-lint.run/usage/linters/#gocritic
   163    gocritic:
   164      disabled-checks:
   165        - ifElseChain
   166        - assignOp
   167        - appendAssign
   168        - singleCaseSwitch
   169        - regexpMust
   170        - typeSwitchVar
   171        - elseif
   172  
   173    # https://golangci-lint.run/usage/linters/#gosimple
   174    gosimple:
   175      # Select the Go version to target.
   176      # Default: 1.13
   177      # Deprecated: use the global `run.go` instead.
   178      go: "1.15"
   179      # Sxxxx checks in https://staticcheck.io/docs/configuration/options/#checks
   180      # Default: ["*"]
   181      checks: [
   182        "all", "-S1000", "-S1001", "-S1002", "-S1008", "-S1009", "-S1016", "-S1023", "-S1025", "-S1029", "-S1034", "-S1040"
   183      ]
   184  
   185    # https://golangci-lint.run/usage/linters/#govet
   186    govet:
   187      # Report about shadowed variables.
   188      # Default: false
   189      check-shadowing: true
   190      # Settings per analyzer.
   191      settings:
   192        # Analyzer name, run `go tool vet help` to see all analyzers.
   193        printf:
   194          # Comma-separated list of print function names to check (in addition to default, see `go tool vet help printf`).
   195          # Default: []
   196          funcs:
   197            - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
   198            - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
   199            - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
   200            - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
   201          # shadow:
   202          # Whether to be strict about shadowing; can be noisy.
   203          # Default: false
   204          # strict: false
   205        unusedresult:
   206          # Comma-separated list of functions whose results must be used
   207          # (in addition to defaults context.WithCancel,context.WithDeadline,context.WithTimeout,context.WithValue,
   208          # errors.New,fmt.Errorf,fmt.Sprint,fmt.Sprintf,sort.Reverse)
   209          # Default []
   210          funcs:
   211            - pkg.MyFunc
   212            - context.WithCancel
   213          # Comma-separated list of names of methods of type func() string whose results must be used
   214          # (in addition to default Error,String)
   215          # Default []
   216          stringmethods:
   217            - MyMethod
   218      # Enable all analyzers.
   219      # Default: false
   220      enable-all: true
   221      # Disable analyzers by name.
   222      # Run `go tool vet help` to see all analyzers.
   223      # Default: []
   224      disable:
   225        - asmdecl
   226        - assign
   227        - atomic
   228        - atomicalign
   229        - bools
   230        - buildtag
   231        - cgocall
   232        - composites
   233        - copylocks
   234        - deepequalerrors
   235        - errorsas
   236        - fieldalignment
   237        - findcall
   238        - framepointer
   239        - httpresponse
   240        - ifaceassert
   241        - loopclosure
   242        - lostcancel
   243        - nilfunc
   244        - nilness
   245        - reflectvaluecompare
   246        - shift
   247        - shadow
   248        - sigchanyzer
   249        - sortslice
   250        - stdmethods
   251        - stringintconv
   252        - structtag
   253        - testinggoroutine
   254        - tests
   255        - unmarshal
   256        - unreachable
   257        - unsafeptr
   258        - unusedwrite
   259  
   260    # https://golangci-lint.run/usage/linters/#staticcheck
   261    staticcheck:
   262      # Select the Go version to target.
   263      # Default: "1.13"
   264      # Deprecated: use the global `run.go` instead.
   265      go: "1.20"
   266      # SAxxxx checks in https://staticcheck.io/docs/configuration/options/#checks
   267      # Default: ["*"]
   268      checks: [ "all","-SA1019","-SA4015","-SA1029","-SA1016","-SA9003","-SA4006","-SA6003" ]
   269  
   270    # https://golangci-lint.run/usage/linters/#gofmt
   271    gofmt:
   272      # Simplify code: gofmt with `-s` option.
   273      # Default: true
   274      simplify: true
   275      # Apply the rewrite rules to the source before reformatting.
   276      # https://pkg.go.dev/cmd/gofmt
   277      # Default: []
   278      rewrite-rules: [ ]
   279        # - pattern: 'interface{}'
   280        #   replacement: 'any'
   281        # - pattern: 'a[b:len(a)]'
   282        #   replacement: 'a[b:]'