Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
193 changes: 193 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
# .golangci.yml
version: "2"

run:
timeout: 5m
tests: true
# Keep it simple: lint the whole module.
# If you need to exclude generated dirs, do it in exclusions.paths.

linters:
default: none
enable:
# correctness / bugs
- errcheck
- errorlint
- govet
- ineffassign
- staticcheck
- unused
- bodyclose
- copyloopvar
- intrange
- unconvert
- unparam
- noctx

# security
- gosec

# maintainability / readability
- revive
- gocritic
- gocyclo
- funlen
- dupl
- goconst
- misspell
- whitespace
- nolintlint
- godox
- lll
- dogsled
- nakedret
- testifylint

# numbers / magic constants (often noisy; keep, but tuned below)
- mnd

settings:
dupl:
threshold: 100

funlen:
# Lines are a poor signal; statements are a decent one.
lines: -1
statements: 50

goconst:
min-len: 3
min-occurrences: 3

gocritic:
enabled-tags:
- diagnostic
- performance
- style
# "opinionated" and "experimental" tend to create churn in most repos.
disabled-tags:
- opinionated
- experimental
disabled-checks:
- dupImport
- ifElseChain
- octalLiteral
- whyNoLint

gocyclo:
min-complexity: 15

godox:
keywords:
- TODO
- FIXME

mnd:
checks:
- argument
- case
- condition
- return
ignored-numbers:
- "0"
- "1"
- "2"
- "3"
ignored-functions:
- strings.SplitN
- time.Duration
- time.Sleep

govet:
enable:
- nilness
- shadow
# Keep govet defaults + these; avoid repo-specific printf funcs unless needed.

errorlint:
asserts: false

lll:
line-length: 140
tab-width: 1

misspell:
locale: US

nolintlint:
allow-unused: false
require-explanation: true
require-specific: true

revive:
# A small, stable ruleset. Add more only when you actually want them enforced.
rules:
- name: indent-error-flow
- name: empty-lines
- name: unused-parameter
- name: unused-receiver
- name: early-return
- name: var-naming
- name: exported
disabled: true # too chatty unless your repo is strict about comments

exclusions:
presets:
- comments
- std-error-handling
- common-false-positives
- legacy

# NOTE: exclusions.paths are REGEX (not globs, not plain paths).
# Anchor them so you only exclude those directories.
paths:
- pkg/apidb
- pkg/auth
- pkg/canton
- pkg/config
- pkg/db
- pkg/ethereum
- pkg/ethrpc
- pkg/keys
- pkg/registration
- pkg/relayer
- pkg/service
- cmd
- internal

rules:
- path: (.+)_test\.go$
linters: [dupl, funlen, gocyclo, mnd, lll]

- path: \.gen\.go$
linters: [revive, gocritic, goconst, gocyclo, funlen, lll, dupl, mnd]

formatters:
enable:
- gofmt
- goimports
settings:
gofmt:
rewrite-rules:
- pattern: "interface{}"
replacement: "any"
goimports:
local-prefixes:
- github.com/chainsafe/canton-middleware

exclusions:
# NOTE: these are REGEX patterns (not globs)
paths:
- pkg/apidb
- pkg/auth
- pkg/canton
- pkg/config
- pkg/db
- pkg/ethereum
- pkg/ethrpc
- pkg/keys
- pkg/registration
- pkg/relayer
- pkg/service
- cmd
- internal
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@ deps:
go mod download
go mod tidy

get_lint:
if [ ! -f ./bin/golangci-lint ]; then \
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v2.9.0; \
fi;

# Run linter
lint:
golangci-lint run
lint: get_lint
./bin/golangci-lint run

# Format code
fmt:
Expand Down
Loading