...

Text file src/go.opentelemetry.io/otel/.golangci.yml

Documentation: go.opentelemetry.io/otel

     1# See https://github.com/golangci/golangci-lint#config-file
     2run:
     3  issues-exit-code: 1 #Default
     4  tests: true #Default
     5
     6linters:
     7  # Disable everything by default so upgrades to not include new "default
     8  # enabled" linters.
     9  disable-all: true
    10  # Specifically enable linters we want to use.
    11  enable:
    12    - depguard
    13    - errcheck
    14    - godot
    15    - gofumpt
    16    - goimports
    17    - gosec
    18    - gosimple
    19    - govet
    20    - ineffassign
    21    - misspell
    22    - revive
    23    - staticcheck
    24    - typecheck
    25    - unused
    26
    27issues:
    28  # Maximum issues count per one linter.
    29  # Set to 0 to disable.
    30  # Default: 50
    31  # Setting to unlimited so the linter only is run once to debug all issues.
    32  max-issues-per-linter: 0
    33  # Maximum count of issues with the same text.
    34  # Set to 0 to disable.
    35  # Default: 3
    36  # Setting to unlimited so the linter only is run once to debug all issues.
    37  max-same-issues: 0
    38  # Excluding configuration per-path, per-linter, per-text and per-source.
    39  exclude-rules:
    40    # TODO: Having appropriate comments for exported objects helps development,
    41    # even for objects in internal packages. Appropriate comments for all
    42    # exported objects should be added and this exclusion removed.
    43    - path: '.*internal/.*'
    44      text: "exported (method|function|type|const) (.+) should have comment or be unexported"
    45      linters:
    46        - revive
    47    # Yes, they are, but it's okay in a test.
    48    - path: _test\.go
    49      text: "exported func.*returns unexported type.*which can be annoying to use"
    50      linters:
    51        - revive
    52    # Example test functions should be treated like main.
    53    - path: example.*_test\.go
    54      text: "calls to (.+) only in main[(][)] or init[(][)] functions"
    55      linters:
    56        - revive
    57    # It's okay to not run gosec in a test.
    58    - path: _test\.go
    59      linters:
    60        - gosec
    61    # Igonoring gosec G404: Use of weak random number generator (math/rand instead of crypto/rand)
    62    # as we commonly use it in tests and examples.
    63    - text: "G404:"
    64      linters:
    65        - gosec
    66    # Igonoring gosec G402: TLS MinVersion too low
    67    # as the https://pkg.go.dev/crypto/tls#Config handles MinVersion default well.
    68    - text: "G402: TLS MinVersion too low."
    69      linters:
    70        - gosec
    71  include:
    72    # revive exported should have comment or be unexported.
    73    - EXC0012
    74    # revive package comment should be of the form ...
    75    - EXC0013
    76
    77linters-settings:
    78  depguard:
    79    rules:
    80      non-tests:
    81        files:
    82          - "!$test"
    83          - "!**/*test/*.go"
    84          - "!**/internal/matchers/*.go"
    85        deny:
    86          - pkg: "testing"
    87          - pkg: "github.com/stretchr/testify"
    88          - pkg: "crypto/md5"
    89          - pkg: "crypto/sha1"
    90          - pkg: "crypto/**/pkix"
    91      otlp-internal:
    92        files:
    93          - "!**/exporters/otlp/internal/**/*.go"
    94        deny:
    95          - pkg: "go.opentelemetry.io/otel/exporters/otlp/internal"
    96            desc: Do not use cross-module internal packages.
    97      otlptrace-internal:
    98        files:
    99          - "!**/exporters/otlp/otlptrace/*.go"
   100          - "!**/exporters/otlp/otlptrace/internal/**.go"
   101        deny:
   102          - pkg: "go.opentelemetry.io/otel/exporters/otlp/otlptrace/internal"
   103            desc: Do not use cross-module internal packages.
   104      otlpmetric-internal:
   105        files:
   106          - "!**/exporters/otlp/otlpmetric/internal/*.go"
   107          - "!**/exporters/otlp/otlpmetric/internal/**/*.go"
   108        deny:
   109          - pkg: "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal"
   110            desc: Do not use cross-module internal packages.
   111      otel-internal:
   112        files:
   113          - "**/sdk/*.go"
   114          - "**/sdk/**/*.go"
   115          - "**/exporters/*.go"
   116          - "**/exporters/**/*.go"
   117          - "**/schema/*.go"
   118          - "**/schema/**/*.go"
   119          - "**/metric/*.go"
   120          - "**/metric/**/*.go"
   121          - "**/bridge/*.go"
   122          - "**/bridge/**/*.go"
   123          - "**/example/*.go"
   124          - "**/example/**/*.go"
   125          - "**/trace/*.go"
   126          - "**/trace/**/*.go"
   127        deny:
   128          - pkg: "go.opentelemetry.io/otel/internal$"
   129            desc: Do not use cross-module internal packages.
   130          - pkg: "go.opentelemetry.io/otel/internal/attribute"
   131            desc: Do not use cross-module internal packages.
   132          - pkg: "go.opentelemetry.io/otel/internal/internaltest"
   133            desc: Do not use cross-module internal packages.
   134          - pkg: "go.opentelemetry.io/otel/internal/matchers"
   135            desc: Do not use cross-module internal packages.
   136  godot:
   137    exclude:
   138      # Exclude links.
   139      - '^ *\[[^]]+\]:'
   140      # Exclude sentence fragments for lists.
   141      - '^[ ]*[-•]'
   142      # Exclude sentences prefixing a list.
   143      - ':$'
   144  goimports:
   145    local-prefixes: go.opentelemetry.io
   146  misspell:
   147    locale: US
   148    ignore-words:
   149      - cancelled
   150  revive:
   151    # Sets the default failure confidence.
   152    # This means that linting errors with less than 0.8 confidence will be ignored.
   153    # Default: 0.8
   154    confidence: 0.01
   155    rules:
   156      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#blank-imports
   157      - name: blank-imports
   158        disabled: false
   159      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bool-literal-in-expr
   160      - name: bool-literal-in-expr
   161        disabled: false
   162      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#constant-logical-expr
   163      - name: constant-logical-expr
   164        disabled: false
   165      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-as-argument
   166      # TODO (#3372) re-enable linter when it is compatible. https://github.com/golangci/golangci-lint/issues/3280
   167      - name: context-as-argument
   168        disabled: true
   169        arguments:
   170          allowTypesBefore: "*testing.T"
   171      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-keys-type
   172      - name: context-keys-type
   173        disabled: false
   174      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#deep-exit
   175      - name: deep-exit
   176        disabled: false
   177      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#defer
   178      - name: defer
   179        disabled: false
   180        arguments:
   181          - ["call-chain", "loop"]
   182      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#dot-imports
   183      - name: dot-imports
   184        disabled: false
   185      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#duplicated-imports
   186      - name: duplicated-imports
   187        disabled: false
   188      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#early-return
   189      - name: early-return
   190        disabled: false
   191      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-block
   192      - name: empty-block
   193        disabled: false
   194      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-lines
   195      - name: empty-lines
   196        disabled: false
   197      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-naming
   198      - name: error-naming
   199        disabled: false
   200      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-return
   201      - name: error-return
   202        disabled: false
   203      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-strings
   204      - name: error-strings
   205        disabled: false
   206      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#errorf
   207      - name: errorf
   208        disabled: false
   209      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#exported
   210      - name: exported
   211        disabled: false
   212        arguments:
   213          - "sayRepetitiveInsteadOfStutters"
   214      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#flag-parameter
   215      - name: flag-parameter
   216        disabled: false
   217      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#identical-branches
   218      - name: identical-branches
   219        disabled: false
   220      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#if-return
   221      - name: if-return
   222        disabled: false
   223      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#increment-decrement
   224      - name: increment-decrement
   225        disabled: false
   226      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#indent-error-flow
   227      - name: indent-error-flow
   228        disabled: false
   229      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#import-shadowing
   230      - name: import-shadowing
   231        disabled: false
   232      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#package-comments
   233      - name: package-comments
   234        disabled: false
   235      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range
   236      - name: range
   237        disabled: false
   238      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-in-closure
   239      - name: range-val-in-closure
   240        disabled: false
   241      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-address
   242      - name: range-val-address
   243        disabled: false
   244      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#redefines-builtin-id
   245      - name: redefines-builtin-id
   246        disabled: false
   247      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-format
   248      - name: string-format
   249        disabled: false
   250        arguments:
   251          - - panic
   252            - '/^[^\n]*$/'
   253            - must not contain line breaks
   254      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#struct-tag
   255      - name: struct-tag
   256        disabled: false
   257      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#superfluous-else
   258      - name: superfluous-else
   259        disabled: false
   260      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#time-equal
   261      - name: time-equal
   262        disabled: false
   263      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-naming
   264      - name: var-naming
   265        disabled: false
   266        arguments:
   267          - ["ID"] # AllowList
   268          - ["Otel", "Aws", "Gcp"] # DenyList
   269      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-declaration
   270      - name: var-declaration
   271        disabled: false
   272      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unconditional-recursion
   273      - name: unconditional-recursion
   274        disabled: false
   275      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-return
   276      - name: unexported-return
   277        disabled: false
   278      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unhandled-error
   279      - name: unhandled-error
   280        disabled: false
   281        arguments:
   282          - "fmt.Fprint"
   283          - "fmt.Fprintf"
   284          - "fmt.Fprintln"
   285          - "fmt.Print"
   286          - "fmt.Printf"
   287          - "fmt.Println"
   288      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unnecessary-stmt
   289      - name: unnecessary-stmt
   290        disabled: false
   291      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#useless-break
   292      - name: useless-break
   293        disabled: false
   294      # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#waitgroup-by-value
   295      - name: waitgroup-by-value
   296        disabled: false

View as plain text