Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(linter): update Golang linter configuration #1977

Merged
merged 21 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
# Global rule:
* @rhuairahrighairidh @karzak @pirtleshell @drklee3 @nddeluca @DracoLi @evgeniy-scherbina @sesheffield
sesheffield marked this conversation as resolved.
Show resolved Hide resolved
24 changes: 19 additions & 5 deletions .github/workflows/ci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,25 @@ jobs:
uses: ./.github/workflows/proto.yml
golangci-lint:
runs-on: ubuntu-latest
permissions:
checks: write # allow write access to checks to allow the action to annotate code in the PR.
steps:
- uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@v4
with: { fetch-depth: 0 }
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: Load Version
id: load-version
run: |
GOLANGCI_VERSION=$(cat .golangci-version)
REV=$(git merge-base origin/master HEAD)
echo "GOLANGCI_VERSION=$GOLANGCI_VERSION" >> $GITHUB_ENV
echo "REV=$REV" >> $GITHUB_ENV
- name: golangci-lint
uses: reviewdog/action-golangci-lint@v2
uses: golangci/golangci-lint-action@v6
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
golangci_lint_flags: --timeout 10m
version: ${{ env.GOLANGCI_VERSION }}
args: -v -c .golangci.yml --new-from-rev ${{ env.REV }}
1 change: 1 addition & 0 deletions .golangci-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v1.59
145 changes: 145 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
run:
timeout: 20m # set maximum time allowed for the linter to run. If the linting process exceeds this duration, it will be terminated
modules-download-mode: readonly # Ensures that modules are not modified during the linting process
allow-parallel-runners: true # enables parallel execution of linters to speed up linting process

linters:
disable-all: true
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
- decorder
- dogsled
# - dupl
# - dupword
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
# - exhaustive
- exportloopref
- funlen
- gci
- ginkgolinter
- gocheckcompilerdirectives
# - gochecknoglobals
# - gochecknoinits
- goconst
- gocritic
- godox
- gofmt
# - gofumpt
- goheader
- goimports
- mnd
# - gomodguard
- goprintffuncname
# - gosec
- gosimple
- govet
- grouper
- importas
- ineffassign
# - interfacebloat
- lll
- loggercheck
- makezero
- mirror
- misspell
- musttag
# - nakedret
# - nestif
- nilerr
# - nilnil
# - noctx
- nolintlint
# - nonamedreturns
- nosprintfhostport
- prealloc
- predeclared
- promlinter
# - reassign
- revive
- rowserrcheck
- staticcheck
# - stylecheck
- tagalign
# - testpackage
# - thelper
# - tparallel
- typecheck
# - unconvert
- unparam
- unused
# - usestdlibvars
- wastedassign
# - whitespace
- wrapcheck


linters-settings:
errcheck:
check-blank: true # check for assignments to the blank identifier '_' when errors are returned
check-type-assertions: false # check type assertion
errorlint:
check-generated: false # disabled linting of generated files
default-signifies-exhaustive: false # exhaustive handling of error types
exhaustive:
default-signifies-exhaustive: false # exhaustive handling of error types
gci:
sections: # defines the order of import sections
- standard
- default
goconst:
min-len: 3 # min length for string constants to be checked
min-occurrences: 3 # min occurrences of the same constant before it's flagged
godox:
keywords: # specific keywords to flag for further action
- BUG
- FIXME
- HACK
lll:
line-length: 120
nolintlint:
allow-leading-space: false
require-explanation: true
require-specific: true
unparam:
check-exported: true # checks exported functions and methods for unused params
misspell:
locale: US
ignore-words: expect
prealloc:
simple: true # enables simple preallocation checks
range-loops: true # enabled preallocation checks in range loops
for-loops: false # disables preallocation checks in for loops

issues:
exclude-rules:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we remove the exclusions until they rear their ugly heads in future commits?

- path: _test\.go
linters:
- cyclop
- dupl
- errcheck
- gochecknoglobals
- gochecknoinits
- goconst
- mnd
- noctx
- linters:
- gosec
text: "math/rand"
path: _test\.go
- linters:
- gosec
text: "TLS InsecureSkipVerify set true"
path: _test\.go
- linters:
- gosec
text: "G108: Profiling endpoint is automatically exposed on /debug/pprof"
path: _test\.go
52 changes: 0 additions & 52 deletions golangci.yml

This file was deleted.

Loading