[go: up one dir, main page]

Skip to content

Use custom .golangci.yml file with improved lint rules

The following discussion from !264 (closed) should be addressed:

  • @krasio started a discussion: (+2 comments)

    Is this to avoid name clash with the client package?


We use automatic linting via golangci-lint with a default set of relaxed rules. To improve the code style we should add a custom .golangci.yml file enabling a set of useful linters.

We can use GitLab's Runner .golangci.yml for consistency or use as a base for the set of rules we want to apply to Pages.

cc @krasio @vshushlin @sean_carroll


Linters

From GitLab's Runner .golangci.yml

Linter Enable in iteration #
bodyclose 2
deadcode 2
dogsled 2
goconst 1
gocyclo 1
goimports 1
golint 1
gosec 1
gosimple 1
govet 1
ineffassign 2
misspell 2
structcheck 2
typecheck 2
unconvert 2
unused 2
varcheck 2
whitespace 2

Other linters to consider

List of supported linters by golangci-lint

Linter Description
wsl improve empty line spacing (annoying but makes the code more readable)
interfacer Linter that suggests narrower interface types
lll long lines
unparam Reports unused function parameters
gocritic The most opinionated Go source code linter
gochecknoinits This will help with #342

MRs

Edited by Jackie Porter