From 1cd0a9bb3777a0a8733f4ecf1afcc94f8ea903f6 Mon Sep 17 00:00:00 2001 From: Nino Kodabande Date: Tue, 21 Nov 2023 09:47:37 -0800 Subject: [PATCH] Enable golangci-lint for build monitor Signed-off-by: Nino Kodabande --- .github/workflows/.golangci.yaml | 111 ++++++++++++++++++ .../github-runner-monitor-build.yaml | 1 + 2 files changed, 112 insertions(+) create mode 100644 .github/workflows/.golangci.yaml diff --git a/.github/workflows/.golangci.yaml b/.github/workflows/.golangci.yaml new file mode 100644 index 00000000000..22a815a9b86 --- /dev/null +++ b/.github/workflows/.golangci.yaml @@ -0,0 +1,111 @@ +linters-settings: + dupl: + threshold: 100 + funlen: + lines: 100 + statements: 50 + goconst: + min-len: 2 + min-occurrences: 3 + gocritic: + enabled-tags: + - diagnostic + - experimental + - opinionated + - performance + - style + disabled-checks: + - dupImport # https://github.com/go-critic/go-critic/issues/845 + - ifElseChain + - octalLiteral + - whyNoLint + - wrapperFunc + gocyclo: + min-complexity: 15 + gomnd: + # don't include the "operation" and "assign" + checks: + - argument + - case + - condition + - return + ignored-numbers: + - '0' + - '1' + - '2' + - '3' + ignored-functions: + - strings.SplitN + + lll: + line-length: 140 + misspell: + locale: US + nolintlint: + allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space) + allow-unused: false # report any unused nolint directives + require-explanation: false # don't require an explanation for nolint directives + require-specific: false # don't require nolint directives to be specific about which linter is being skipped + +linters: + disable-all: true + enable: + - bodyclose + - deadcode + - dogsled + - dupl + - errcheck + - exportloopref + - gochecknoinits + - goconst + - gocritic + - gocyclo + - gofmt + - goimports + - gomnd + - goprintffuncname + - gosec + - gosimple + - govet + - ineffassign + - lll + - misspell + - nakedret + - noctx + - nolintlint + - staticcheck + - structcheck + - stylecheck + - typecheck + - unconvert + - unparam + - unused + - varcheck + - whitespace + + # don't enable: + # - asciicheck + # - funlen + # - scopelint + # - gochecknoglobals + # - gocognit + # - godot + # - godox + # - goerr113 + # - interfacer + # - maligned + # - nestif + # - prealloc + # - testpackage + # - revive + # - wsl + # - depguard # Requires configuration and by default only allows stdlib imports + +issues: + # Excluding configuration per-path, per-linter, per-text and per-source + exclude-rules: + - path: _test\.go + linters: + - gosec + - errcheck + - gocritic diff --git a/.github/workflows/github-runner-monitor-build.yaml b/.github/workflows/github-runner-monitor-build.yaml index bedb1545eba..cc1167f5203 100644 --- a/.github/workflows/github-runner-monitor-build.yaml +++ b/.github/workflows/github-runner-monitor-build.yaml @@ -36,5 +36,6 @@ jobs: - uses: golangci/golangci-lint-action@v3.7.0 # This is only safe because this workflow does not allow writing with: + args: --config=.golangci.yaml --verbose --timeout 3m working-directory: src/go/github-runner-monitor only-new-issues: true