golangci: Enable new linter added to last release

Enable a new golangci-lint linter that has been added to the last
release. It reports a very little number of issues so they are fix it in
this commit.

Change-Id: I74fef4779c3f592aae19103fd9f70103586fe24e
This commit is contained in:
Ivan Fraixedes 2020-01-22 16:38:56 +01:00 committed by Ivan Fraixedes
parent f917fecc61
commit f5c9597d29
2 changed files with 36 additions and 34 deletions

View File

@ -10,41 +10,43 @@ run:
linters: linters:
enable: enable:
- govet # check standard vet rules - govet # check standard vet rules
- golint # check standard linting rules - golint # check standard linting rules
- staticcheck # comprehensive checks - staticcheck # comprehensive checks
- errcheck # find unchecked errors - errcheck # find unchecked errors
- ineffassign # find ineffective assignments - ineffassign # find ineffective assignments
- varcheck # find unused global variables and constants - varcheck # find unused global variables and constants
- structcheck # check for unused struct parameters - structcheck # check for unused struct parameters
- deadcode # find code that is not used - deadcode # find code that is not used
- bodyclose # find unclosed http response bodies - bodyclose # find unclosed http response bodies
- nakedret # check for naked returns - nakedret # check for naked returns
- gofmt # sanity check formatting - gofmt # sanity check formatting
- misspell # check spelling - misspell # check spelling
- unconvert # remove unnecessary conversions - unconvert # remove unnecessary conversions
- scopelint # checks for unpinned variables - scopelint # checks for unpinned variables
- gocritic # checks for style, performance issues, and common programming errors - gocritic # checks for style, performance issues, and common programming errors
- dogsled # checks for too many ignored arguments - dogsled # checks for too many ignored arguments
#TODO#- whitespace # checks for leading/trailing newlines - goprintffuncname # Checks that printf-like functions are named with `f` at the end [fast: true, auto-fix: false]
#TODO#- unparam # check for unused parameters #TODO#- whitespace # checks for leading/trailing newlines
#TODO#- maligned # check for better memory usage #TODO#- unparam # check for unused parameters
#TODO#- prealloc # easy optimizations #TODO#- maligned # check for better memory usage
#TODO#- prealloc # easy optimizations
#TODO#- gosec #TODO#- gosec
disable: disable:
- godox - godox
- wsl # too much noise - wsl # too much noise
- goimports # disabled, because it's slow, using scripts/check-imports.go instead. - goimports # disabled, because it's slow, using scripts/check-imports.go instead.
- goconst # check for things that could be replaced by constants - goconst # check for things that could be replaced by constants
- gocyclo # needs tweaking - gocyclo # needs tweaking
- depguard # unused - depguard # unused
- gosec # needs tweaking - gosec # needs tweaking
- stylecheck # has false positives - stylecheck # has false positives
- dupl # slow - dupl # slow
- interfacer # not that useful - interfacer # not that useful
- gosimple # part of staticcheck - gosimple # part of staticcheck
- unused # part of staticcheck - unused # part of staticcheck
- lll - lll
- rowserrcheck # checks if sql.Rows.Err is checked correctly - Disabled because it reports false positive with defer statements after Query call
fast: false fast: false
output: output:

View File

@ -17,8 +17,8 @@ var ErrValidation = errs.Class("validation error")
// validationError is slice of ErrValidation class errors // validationError is slice of ErrValidation class errors
type validationErrors []error type validationErrors []error
// Add new ErrValidation err // Addf adds a new ErrValidation error to validation.
func (validation *validationErrors) Add(format string, args ...interface{}) { func (validation *validationErrors) Addf(format string, args ...interface{}) {
*validation = append(*validation, ErrValidation.New(format, args...)) *validation = append(*validation, ErrValidation.New(format, args...))
} }
@ -37,7 +37,7 @@ func ValidatePassword(pass string) error {
var errs validationErrors var errs validationErrors
if len(pass) < passMinLength { if len(pass) < passMinLength {
errs.Add(passwordIncorrectErrMsg, passMinLength) errs.Addf(passwordIncorrectErrMsg, passMinLength)
} }
return errs.Combine() return errs.Combine()