github.com/gogf/gf/v2@v2.7.4/.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: 340
   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      # Sxxxx checks in https://staticcheck.io/docs/configuration/options/#checks
   176      # Default: ["*"]
   177      checks: [
   178        "all", "-S1000", "-S1001", "-S1002", "-S1008", "-S1009", "-S1016", "-S1023", "-S1025", "-S1029", "-S1034", "-S1040"
   179      ]
   180  
   181    # https://golangci-lint.run/usage/linters/#govet
   182    govet:
   183      # Settings per analyzer.
   184      settings:
   185        # Analyzer name, run `go tool vet help` to see all analyzers.
   186        printf:
   187          # Comma-separated list of print function names to check (in addition to default, see `go tool vet help printf`).
   188          # Default: []
   189          funcs:
   190            - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
   191            - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
   192            - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
   193            - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
   194          # shadow:
   195          # Whether to be strict about shadowing; can be noisy.
   196          # Default: false
   197          # strict: false
   198        unusedresult:
   199          # Comma-separated list of functions whose results must be used
   200          # (in addition to defaults context.WithCancel,context.WithDeadline,context.WithTimeout,context.WithValue,
   201          # errors.New,fmt.Errorf,fmt.Sprint,fmt.Sprintf,sort.Reverse)
   202          # Default []
   203          funcs:
   204            - pkg.MyFunc
   205            - context.WithCancel
   206          # Comma-separated list of names of methods of type func() string whose results must be used
   207          # (in addition to default Error,String)
   208          # Default []
   209          stringmethods:
   210            - MyMethod
   211      # Enable all analyzers.
   212      # Default: false
   213      enable-all: true
   214      # Disable analyzers by name.
   215      # Run `go tool vet help` to see all analyzers.
   216      # Default: []
   217      disable:
   218        - asmdecl
   219        - assign
   220        - atomic
   221        - atomicalign
   222        - bools
   223        - buildtag
   224        - cgocall
   225        - composites
   226        - copylocks
   227        - deepequalerrors
   228        - errorsas
   229        - fieldalignment
   230        - findcall
   231        - framepointer
   232        - httpresponse
   233        - ifaceassert
   234        - loopclosure
   235        - lostcancel
   236        - nilfunc
   237        - nilness
   238        - reflectvaluecompare
   239        - shift
   240        - shadow
   241        - sigchanyzer
   242        - sortslice
   243        - stdmethods
   244        - stringintconv
   245        - structtag
   246        - testinggoroutine
   247        - tests
   248        - unmarshal
   249        - unreachable
   250        - unsafeptr
   251        - unusedwrite
   252  
   253    # https://golangci-lint.run/usage/linters/#staticcheck
   254    staticcheck:
   255      # SAxxxx checks in https://staticcheck.io/docs/configuration/options/#checks
   256      # Default: ["*"]
   257      checks: [ "all","-SA1019","-SA4015","-SA1029","-SA1016","-SA9003","-SA4006","-SA6003" ]
   258  
   259    # https://golangci-lint.run/usage/linters/#gofmt
   260    gofmt:
   261      # Simplify code: gofmt with `-s` option.
   262      # Default: true
   263      simplify: true
   264      # Apply the rewrite rules to the source before reformatting.
   265      # https://pkg.go.dev/cmd/gofmt
   266      # Default: []
   267      rewrite-rules: [ ]
   268        # - pattern: 'interface{}'
   269        #   replacement: 'any'
   270        # - pattern: 'a[b:len(a)]'
   271        #   replacement: 'a[b:]'