diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bdf2a70..162f2b3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,26 +10,22 @@ jobs: uses: networkservicemesh/.github/.github/workflows/yamllint.yaml@main with: config_file: .ci/yamllint.yml - build-and-test: uses: networkservicemesh/.github/.github/workflows/build-and-test.yaml@main with: os: '["ubuntu-latest", "macos-latest", "windows-latest"]' - golangci-lint: uses: networkservicemesh/.github/.github/workflows/golangci-lint.yaml@main - + with: + linter-version: v2.13.2 exclude-fmt-errorf: uses: networkservicemesh/.github/.github/workflows/exclude-fmt-errorf.yaml@main - restrict-nsm-deps: uses: networkservicemesh/.github/.github/workflows/restrict-nsm-deps.yaml@main with: allowed_repositories: "" - checkgomod: uses: networkservicemesh/.github/.github/workflows/checkgomod.yaml@main - gogenerate: name: Check generated files runs-on: ubuntu-latest @@ -44,6 +40,5 @@ jobs: - name: Check for changes in generated code run: | git diff -- '*.pb.go' || (echo "Rerun go generate ./... locally and resubmit" && exit -1) - exclude-replace: uses: networkservicemesh/.github/.github/workflows/exclude-replace.yaml@main diff --git a/.golangci.yml b/.golangci.yml index 083e85d..17914f7 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,124 +1,14 @@ --- +version: "2" run: - # concurrency: 6 - go: "1.23" - timeout: 2m + go: "1.25" issues-exit-code: 1 tests: true -linters-settings: - goheader: - template-path: ".ci/license/template.txt" - values: - regexp: - company: .* - copyright-holder: Copyright \(c\) ({{mod-year-range}}) {{company}}\n\n - copyright-holders: ({{copyright-holder}})+ - errcheck: - check-type-assertions: false - check-blank: false - govet: - enable: - - shadow - settings: - printf: - funcs: - - (github.com/sirupsen/logrus.FieldLogger).Infof - - (github.com/sirupsen/logrus.FieldLogger).Warnf - - (github.com/sirupsen/logrus.FieldLogger).Errorf - - (github.com/sirupsen/logrus.FieldLogger).Fatalf - depguard: - rules: - main: - deny: - - pkg: "errors" - desc: "Please use \"github.com/pkg/errors\" instead of \"errors\" in go imports" - revive: - confidence: 0.8 - rules: - - name: exported - - name: blank-imports - - name: context-as-argument - - name: context-keys-type - - name: dot-imports - - name: error-return - - name: error-strings - - name: error-naming - - name: exported - - name: increment-decrement - - name: var-naming - - name: package-comments - - name: range - - name: receiver-naming - - name: time-naming - - name: unexported-return - - name: indent-error-flow - - name: errorf - - name: superfluous-else - - name: unreachable-code - goimports: - local-prefixes: github.com/networkservicemesh/api - gocyclo: - min-complexity: 15 - dupl: - threshold: 150 - goconst: - min-len: 2 - min-occurrences: 2 - lll: - line-length: 160 - misspell: - locale: US - unparam: - check-exported: false - nakedret: - max-func-lines: 30 - prealloc: - simple: true - range-loops: true - for-loops: false - gocritic: - enabled-checks: - - appendCombine - - boolExprSimplify - - builtinShadow - - commentedOutCode - - commentedOutImport - - docStub - - dupImport - - emptyFallthrough - - emptyStringTest - - equalFold - - evalOrder - - hexLiteral - - hugeParam - - importShadow - - indexAlloc - - initClause - - methodExprCall - - nestingReduce - - nilValReturn - - octalLiteral - - paramTypeCombine - - rangeExprCopy - - rangeValCopy - - regexpPattern - - sloppyReassign - - stringXbytes - - typeAssertChain - - typeUnparen - - unlabelStmt - - unnamedResult - - unnecessaryBlock - - weakCond - - yodaStyleExpr linters: - disable-all: true + default: none enable: - - depguard - - revive - - rowserrcheck - - goheader - bodyclose + - depguard - dogsled - dupl - errcheck @@ -127,32 +17,168 @@ linters: - goconst - gocritic - gocyclo - - gofmt - - goimports + - goheader - gosec - - gosimple - govet - ineffassign - lll - misspell - nakedret + - revive + - rowserrcheck - staticcheck - - stylecheck - - typecheck - unconvert - unparam - unused - whitespace + settings: + depguard: + rules: + main: + deny: + - pkg: errors + desc: Please use "github.com/pkg/errors" instead of "errors" in go imports + dupl: + threshold: 150 + errcheck: + check-type-assertions: false + check-blank: false + goconst: + min-len: 2 + min-occurrences: 3 + gocritic: + enabled-checks: + - appendCombine + - boolExprSimplify + - builtinShadow + - commentedOutCode + - commentedOutImport + - docStub + - dupImport + - emptyFallthrough + - emptyStringTest + - equalFold + - evalOrder + - hexLiteral + - hugeParam + - importShadow + - indexAlloc + - initClause + - methodExprCall + - nestingReduce + - nilValReturn + - octalLiteral + - paramTypeCombine + - rangeExprCopy + - rangeValCopy + - regexpPattern + - sloppyReassign + - stringXbytes + - typeAssertChain + - typeUnparen + - unlabelStmt + - unnamedResult + - unnecessaryBlock + - weakCond + - yodaStyleExpr + gocyclo: + min-complexity: 15 + goheader: + values: + regexp: + company: .* + copyright-holder: Copyright \(c\) ({{mod-year-range}}) {{company}}\n\n + copyright-holders: ({{copyright-holder}})+ + template-path: .ci/license/template.txt + govet: + enable: + - shadow + settings: + printf: + funcs: + - (github.com/sirupsen/logrus.FieldLogger).Infof + - (github.com/sirupsen/logrus.FieldLogger).Warnf + - (github.com/sirupsen/logrus.FieldLogger).Errorf + - (github.com/sirupsen/logrus.FieldLogger).Fatalf + disable: + - inline + lll: + line-length: 160 + misspell: + locale: US + nakedret: + max-func-lines: 30 + prealloc: + simple: true + range-loops: true + for-loops: false + revive: + confidence: 0.8 + rules: + - name: exported + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: error-return + - name: error-strings + - name: error-naming + - name: exported + - name: increment-decrement + - name: var-naming + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: unexported-return + - name: indent-error-flow + - name: errorf + - name: superfluous-else + - name: unreachable-code + unparam: + check-exported: false + gosec: + excludes: + - G304 + - G702 + - G703 + staticcheck: + checks: + - all + - -SA4023 + - -QF* + exclusions: + generated: lax + rules: + - linters: + - funlen + path: pkg/api/networkservice/connectioncontext_helpers_test.go + text: Function 'TestParsePortRange' is too long + - linters: + - gosec + path: pkg/api/networkservice + text: G115 + - linters: + - goconst + path: (_test\.go|/testutil/) + paths: + - third_party$ + - builtin$ + - examples$ issues: - exclude-use-default: false max-issues-per-linter: 0 max-same-issues: 0 - exclude-rules: - - path: pkg/api/networkservice/connectioncontext_helpers_test.go - linters: - - funlen - text: "Function 'TestParsePortRange' is too long" - - path: pkg/api/networkservice - linters: - - gosec - text: "G115" +formatters: + enable: + - gofmt + - goimports + settings: + goimports: + local-prefixes: + - github.com/networkservicemesh/api + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$