Skip to content

Commit

Permalink
ci(golangci): add golangci config
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuar committed Oct 14, 2023
1 parent d56e15e commit 02b3ba9
Showing 1 changed file with 187 additions and 0 deletions.
187 changes: 187 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
# Copyright (c) 2023 Joshua Rich <[email protected]>
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT

linters-settings:
revive:
# Maximum number of open files at the same time.
# See https://github.com/mgechev/revive#command-line-flags
# Defaults to unlimited.
max-open-files: 512
gocyclo:
# Minimal code complexity to report.
# Default: 30 (but we recommend 10-20)
min-complexity: 50
# depguard:
# list-type: blacklist
# packages:
# # logging is allowed only by logutils.Log, logrus
# # is allowed to use only in logutils package
# - github.com/sirupsen/logrus
# packages-with-error-message:
# - github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
dupl:
threshold: 100
funlen:
lines: 180
statements: 100
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
# goimports:
# local-prefixes: github.com/joshuar/go-hass-agent
govet:
check-shadowing: true
settings:
printf:
funcs:
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
lll:
line-length: 140
misspell:
locale: UK
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
gosec:
# To select a subset of rules to run.
# Available rules: https://github.com/securego/gosec#available-rules
includes:
- G101
- G102
- G103
- G104
- G106
- G107
- G108
- G109
- G110
- G201
- G202
- G203
- G204
- G301
- G302
- G303
- G304
- G305
- G306
- G307
- G401
- G402
- G403
- G404
- G501
- G502
- G503
- G504
- G505
- G601
# To specify a set of rules to explicitly exclude.
# Available rules: https://github.com/securego/gosec#available-rules
excludes:
- G101
- G102
- G103
- G104
- G106
- G107
- G108
- G109
- G110
- G201
- G202
- G203
- G204
- G301
- G302
- G303
- G304
- G305
- G306
- G307
- G401
- G402
- G403
- G404
- G501
- G502
- G503
- G504
- G505
- G601
linters:
disable-all: true
enable:
- bodyclose
# - depguard
- decorder
- dogsled
- dupl
- errcheck
- exportloopref
- funlen
- goconst
- gocritic
- gocyclo
- gofmt
- goimports
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- lll
- misspell
- nakedret
- noctx
- nolintlint
- staticcheck
# - structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
# - varcheck
- whitespace
# - deadcode
- bodyclose

issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- path: _test\.go
linters:
- gomnd
- funlen
- dupl
- gochecknoinits
- stylecheck
- staticcheck

run:
timeout: 5m
skip-dirs:
- test/testdata_etc
# timeout for analysis, e.g. 30s, 5m, default is 1m
deadline: 10m

0 comments on commit 02b3ba9

Please sign in to comment.