Skip to content

Commit

Permalink
Proposal of enabled linters and their settings. (influxdata#8951)
Browse files Browse the repository at this point in the history
* Proposal of enabled linters and their settings.

* Workaround to skip weird "plugins/parsers/influx/plugins/parsers/influx" directory

* Update to reflect changes in github actions

* Back to the last state

* Fix

Co-authored-by: Pawel Zak <Pawel Zak>
Co-authored-by: Sebastian Spaink <[email protected]>
  • Loading branch information
zak-pawel and Sebastian Spaink authored Mar 12, 2021
1 parent 97da596 commit 9ddd189
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 24 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
with:
version: v1.38
only-new-issues: true
args: --timeout=5m0s
golangci-master:
if: github.ref == 'refs/heads/master'
name: lint-master-all
Expand All @@ -33,4 +32,4 @@ jobs:
with:
version: v1.38
only-new-issues: true
args: --timeout=5m0s --issues-exit-code=0
args: --issues-exit-code=0
152 changes: 131 additions & 21 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,149 @@
linters:
enable:
- bodyclose
- dogsled
- errcheck
- goprintffuncname
- gosimple
- govet
- ineffassign
- nakedret
- nilerr
- predeclared
- revive
- sqlclosecheck
- staticcheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
disable:
- asciicheck
- deadcode
- depguard
- dupl
- exhaustive
- funlen
- gci
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gocritic
- gocyclo
- godot
- godox
- goerr113
- gofmt
- gofumpt
- goheader
- goimports
- golint
- gomnd
- gomodguard
- gosec
- ifshort
- interfacer
- lll
- makezero
- maligned
- megacheck
- misspell
- nestif
- nlreturn
- noctx
- nolintlint
- paralleltest
- prealloc
- rowserrcheck
- scopelint
- structcheck
- stylecheck
- testpackage
- thelper
- tparallel
- wastedassign
- whitespace
- wrapcheck
- wsl

linters-settings:
revive:
rules:
- name: argument-limit
arguments: [ 6 ]
- name: atomic
- name: bare-return
- name: blank-imports
- name: bool-literal-in-expr
- name: call-to-gc
- name: confusing-naming
- name: confusing-results
- name: constant-logical-expr
- name: context-as-argument
- name: context-keys-type
- name: deep-exit
- name: defer
- name: dot-imports
- name: duplicated-imports
- name: early-return
- name: empty-block
- name: empty-lines
- name: error-naming
- name: error-return
- name: error-strings
- name: error-naming
- name: exported
- name: errorf
- name: flag-parameter
- name: function-result-limit
arguments: [ 3 ]
- name: identical-branches
- name: if-return
- name: imports-blacklist
arguments: [ "log" ]
- name: import-shadowing
- name: increment-decrement
- name: var-naming
- name: var-declaration
- name: indent-error-flow
- name: modifies-parameter
- name: modifies-value-receiver
- name: package-comments
- name: range
- name: range-val-address
- name: range-val-in-closure
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
- name: empty-block
- name: redefines-builtin-id
- name: string-of-int
- name: struct-tag
- name: superfluous-else
- name: unused-parameter
- name: time-naming
- name: unconditional-recursion
- name: unexported-naming
- name: unhandled-error
- name: unnecessary-stmt
- name: unreachable-code
- name: redefines-builtin-id
- name: unused-parameter
- name: var-declaration
- name: var-naming
- name: waitgroup-by-value
nakedret:
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
max-func-lines: 1

run:
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 5m

# which dirs to skip: issues from them won't be reported;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but default dirs are skipped independently
# from this option's value (see skip-dirs-use-default).
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
skip-dirs:
- scripts
- assets
- docs
- etc
- scripts

# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
Expand All @@ -52,17 +155,24 @@ run:
- plugins/parsers/influx/machine.go*

issues:
# List of regexps of issue texts to exclude, empty list by default.
# But independently from this option we use default exclude patterns,
# it can be disabled by `exclude-use-default: false`. To list all
# excluded by default patterns execute `golangci-lint run --help`
exclude:
- don't use an underscore in package name
- exported.*should have comment.*or be unexported
- comment on exported.*should be of the form

# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
max-issues-per-linter: 0

# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0

exclude:
- don't use an underscore in package name #revive:var-naming

exclude-rules:
- path: plugins/parsers/influx
linters:
- govet

# Show only new issues created after git revision `HEAD~`
# Great for CI setups
# It's not practical to fix all existing issues at the moment of integration: much better to not allow issues in new code.
# new-from-rev: "HEAD~"

output:
format: tab
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ ifeq (, $(shell which golangci-lint))
exit 1
endif

golangci-lint run --timeout 5m0s --issues-exit-code 0
golangci-lint -v run

.PHONY: tidy
tidy:
Expand Down

0 comments on commit 9ddd189

Please sign in to comment.