Restructure linter
This commit is contained in:
parent
b64cdc7149
commit
cf5cc8abae
|
@ -14,6 +14,7 @@ steps:
|
|||
image: golangci/golangci-lint:v1.50
|
||||
pull: if-not-exists
|
||||
commands:
|
||||
- cd src
|
||||
- golangci-lint run
|
||||
|
||||
- name: "build and publish docker image"
|
||||
|
|
110
.golangci.yml
110
.golangci.yml
|
@ -1,110 +0,0 @@
|
|||
timeout: 30m
|
||||
|
||||
output:
|
||||
format: tab
|
||||
sort-results: true
|
||||
|
||||
linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
# checks whether HTTP response body is closed successfully
|
||||
- bodyclose
|
||||
|
||||
# Tool for code clone detection
|
||||
- dupl
|
||||
|
||||
# Errcheck is a program for checking for unchecked errors in go programs.
|
||||
# These unchecked errors can be critical bugs in some cases
|
||||
- errcheck
|
||||
|
||||
# Tool for detection of long functions
|
||||
- funlen
|
||||
|
||||
# Checks that no init functions are present in Go code
|
||||
- gochecknoinits
|
||||
|
||||
# Computes and checks the cyclomatic complexity of functions
|
||||
- gocyclo
|
||||
|
||||
# Gofmt checks whether code was gofmt-ed.
|
||||
# By default this tool runs with -s option to check for code simplification
|
||||
- gofmt
|
||||
|
||||
# In addition to fixing imports, goimports also formats your code in the same style as gofmt.
|
||||
- goimports
|
||||
|
||||
# Detects when assignments to existing variables are not used
|
||||
- ineffassign
|
||||
|
||||
# Checks Go code for unused constants, variables, functions and types
|
||||
- unused
|
||||
|
||||
# Inspects source code for security problems
|
||||
- gosec
|
||||
|
||||
linters-settings:
|
||||
gocyclo:
|
||||
# Minimal code complexity to report.
|
||||
# Default: 30 (but we recommend 10-20)
|
||||
min-complexity: 40
|
||||
|
||||
funlen:
|
||||
# Checks the number of lines in a function.
|
||||
# If lower than 0, disable the check.
|
||||
# Default: 60
|
||||
lines: 200
|
||||
# Checks the number of statements in a function.
|
||||
# If lower than 0, disable the check.
|
||||
# Default: 40
|
||||
statements: 200
|
||||
|
||||
gofmt:
|
||||
# Simplify code: gofmt with `-s` option.
|
||||
# Default: true
|
||||
simplify: true
|
||||
|
||||
goconst:
|
||||
# Minimal length of string constant.
|
||||
# Default: 3
|
||||
min-len: 3
|
||||
# Minimum occurrences of constant string count to trigger issue.
|
||||
# Default: 3
|
||||
min-occurrences: 2
|
||||
# Ignore test files.
|
||||
# Default: false
|
||||
ignore-tests: true
|
||||
# Look for existing constants matching the values.
|
||||
# Default: true
|
||||
match-constant: false
|
||||
# Search also for duplicated numbers.
|
||||
# Default: false
|
||||
numbers: true
|
||||
# Minimum value, only works with goconst.numbers
|
||||
# Default: 3
|
||||
min: 2
|
||||
# Maximum value, only works with goconst.numbers
|
||||
# Default: 3
|
||||
max: 2
|
||||
# Ignore when constant is not used as function argument.
|
||||
# Default: true
|
||||
ignore-calls: false
|
||||
|
||||
goimports:
|
||||
# Put imports beginning with prefix after 3rd-party packages.
|
||||
# It's a comma-separated list of prefixes.
|
||||
# Default: ""
|
||||
local-prefixes: ""
|
||||
|
||||
issues:
|
||||
# Report all issues
|
||||
max-issues-per-linter: 0
|
||||
max-same-issues: 0
|
||||
# Disable some
|
||||
exclude-rules:
|
||||
- path: main.go|app.go
|
||||
linters:
|
||||
- funlen
|
||||
- path: _test\.go|mock|integration
|
||||
linters:
|
||||
- funlen
|
||||
- goconst
|
5
makefile
5
makefile
|
@ -1,2 +1,5 @@
|
|||
example:
|
||||
go run main.go ./examples/in/ ./examples/out/
|
||||
go run main.go ./examples/in/ ./examples/out/
|
||||
|
||||
lint:
|
||||
docker run --rm -v "${PWD}/src:/src" golangci/golangci-lint:v1.50 /bin/sh -c "cd /src && golangci-lint run"
|
|
@ -0,0 +1,52 @@
|
|||
# See https://golangci-lint.run/usage/configuration/#config-file
|
||||
output:
|
||||
format: tab
|
||||
sort-results: true
|
||||
|
||||
run:
|
||||
tests: false
|
||||
allow-parallel-runners: true
|
||||
|
||||
issues:
|
||||
max-issues-per-linter: 0
|
||||
max-same-issues: 0
|
||||
fix: false
|
||||
|
||||
linters-settings:
|
||||
stylecheck:
|
||||
checks: ["all", "-ST1003"]
|
||||
|
||||
linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
- bodyclose
|
||||
- unused
|
||||
- depguard
|
||||
- dogsled
|
||||
- dupl
|
||||
- errcheck
|
||||
- exportloopref
|
||||
- funlen
|
||||
- gochecknoinits
|
||||
- goconst
|
||||
- gocritic
|
||||
- gocyclo
|
||||
- gofmt
|
||||
- goimports
|
||||
- goprintffuncname
|
||||
- gosec
|
||||
- gosimple
|
||||
- govet
|
||||
- ineffassign
|
||||
- misspell
|
||||
- nakedret
|
||||
- noctx
|
||||
- staticcheck
|
||||
- structcheck
|
||||
- stylecheck
|
||||
- typecheck
|
||||
- unconvert
|
||||
- unparam
|
||||
- unused
|
||||
- varcheck
|
||||
- whitespace
|
Loading…
Reference in New Issue