Skip to content

Commit

Permalink
ci: enhanced linting
Browse files Browse the repository at this point in the history
Update golangci-lint and add a configuration file which makes it much
more strict.

Bump version of go so we get all the latest linters.
  • Loading branch information
stevenh committed Sep 7, 2024
1 parent e8ed9c9 commit 4412164
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 6 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: golangci-lint
uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 # v4
uses: golangci/golangci-lint-action@v6
with:
version: v1.55.2
args: --timeout=3m
version: v1.60.3
83 changes: 83 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
run:
timeout: 2m

linters-settings:
gosec:
excludes:
- G601 ## Implicit memory aliasing of items from a range statement - not possible in go 1.22.
cyclop:
max-complexity: 15
nestif:
min-complexity: 10
govet:
settings:
shadow:
strict: true
enable-all: true
nolintlint:
require-explanation: true
godot:
scope: all

linters:
enable-all: true
disable:
# Spammy / low value
- varnamelen
- exhaustruct
- nlreturn
- wsl
- lll
- paralleltest
# Duplicate functionality.
- funlen
- gocognit
# Deprecated.
- execinquery
- gomnd
# Good but gets in the way too often.
- testpackage
# Unknown details about how Artemis works are flagged with TODO's.
- godox
# Seems to be broken.
- depguard
# Makes it messy for multiple optional tags.
- tagalign
# Not needed for go 1.22+.
- exportloopref
- errchkjson # Duplicate functionality for errcheck.

issues:
include:
- EXC0012
- EXC0014
exclude-rules:
# Exclude linters which aren't an issue in tests.
- path: _test\.go
linters:
- gochecknoglobals
- wrapcheck

# File mode permissions are fine for constants.
- text: "Magic number: 0o\\d+"
linters:
- mnd

# Field alignment in tests isn't a performance issue.
- text: fieldalignment
path: _test\.go

# Dynamic errors can provide useful context.
- text: "do not define dynamic errors, use wrapped static errors instead:"
linters:
- err113

# We need to use the `err` named return for error handling.
- text: 'named return "err" with type "error" found'
linters:
- nonamedreturns

# Interface casting is fine in mock.
- path: mock_test\.go
linters:
- forcetypeassert
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/testcontainers/moby-ryuk

go 1.21
go 1.23

require (
github.com/docker/docker v27.1.1+incompatible
Expand Down

0 comments on commit 4412164

Please sign in to comment.