Skip to content

Commit

Permalink
Merge pull request #94 from cpanato/updates
Browse files Browse the repository at this point in the history
bump golangci-lint to 1.55.1 and ko to 0.15.0
  • Loading branch information
k8s-ci-robot authored Oct 27, 2023
2 parents ff2d69b + ec79463 commit 05e0f47
Show file tree
Hide file tree
Showing 13 changed files with 145 additions and 94 deletions.
161 changes: 95 additions & 66 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
run:
concurrency: 6
deadline: 5m
timeout: 5m
issues:
exclude-rules:
# counterfeiter fakes are usually named 'fake_<something>.go'
Expand All @@ -10,22 +10,31 @@ issues:
- gocritic
- golint
- dupl

# 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
linters:
disable-all: true
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
- decorder
- dogsled
- dupl
- durationcheck
- errcheck
- errchkjson
- errname
- execinquery
- ginkgolinter
- gocheckcompilerdirectives
- gochecksumtype
- goconst
- gocritic
- gocyclo
Expand All @@ -37,37 +46,47 @@ linters:
- gomoddirectives
- gomodguard
- goprintffuncname
- gosec
- gosimple
- gosmopolitan
- govet
- grouper
- importas
- ineffassign
- interfacebloat
- ireturn
- logrlint
- maintidx
- loggercheck
- makezero
- mirror
- misspell
- musttag
- nakedret
- nilnil
- nolintlint
- nosprintfhostport
- perfsprint
- prealloc
- predeclared
- promlinter
- protogetter
- reassign
- revive
- rowserrcheck
- sloglint
- sqlclosecheck
- staticcheck
- stylecheck
- tagalign
- tenv
- testableexamples
- typecheck
- unconvert
- unparam
- unused
- usestdlibvars
- whitespace
- zerologlint
# - containedctx
# - cyclop
# - errname
# - depguard
# - dupword
# - errorlint
# - exhaustive
# - exhaustruct
Expand All @@ -82,16 +101,19 @@ linters:
# - godot
# - goerr113
# - gomnd
# - gosec
# - inamedparam
# - interfacebloat
# - ireturn
# - lll
# - maintidx
# - nestif
# - nilerr
# - nilnil
# - nlreturn
# - noctx
# - nolintlint
# - nonamedreturns
# - paralleltest
# - revive
# - testifylint
# - tagliatelle
# - testpackage
# - thelper
Expand All @@ -101,6 +123,8 @@ linters:
# - wrapcheck
# - wsl
linters-settings:
gocyclo:
min-complexity: 40
godox:
keywords:
- BUG
Expand All @@ -111,114 +135,119 @@ linters-settings:
check-blank: true
gocritic:
enabled-checks:
# Diagnostic
- appendAssign
- appendCombine
- argOrder
- assignOp
- badCall
- badCond
- badLock
- badRegexp
- badSorting
- boolExprSimplify
- builtinShadow
- builtinShadowDecl
- captLocal
- caseOrder
- codegenComment
- commentFormatting
- commentedOutCode
- commentedOutImport
- defaultCaseOrder
- deferInLoop
- deferUnlambda
- deprecatedComment
- docStub
- dupArg
- dupBranchBody
- dupCase
- dupImport
- dupSubExpr
- dynamicFmtString
- elseif
- emptyDecl
- emptyFallthrough
- emptyStringTest
- equalFold
- evalOrder
- exitAfterDefer
- exposedSyncMutex
- externalErrorReassign
- filepathJoin
- flagDeref
- flagName
- hexLiteral
- httpNoBody
- hugeParam
- ifElseChain
- importShadow
- indexAlloc
- initClause
- mapKey
- methodExprCall
- nestingReduce
- newDeref
- nilValReturn
- octalLiteral
- offBy1
- regexpPattern
- returnAfterHttpError
- sloppyReassign
- sloppyTypeAssert
- sortSlice
- sprintfQuotedString
- sqlQuery
- syncMapLoadAndDelete
- truncateCmp
- unnecessaryDefer
- weakCond

# Performance
- appendCombine
- equalFold
- hugeParam
- indexAlloc
- paramTypeCombine
- preferDecodeRune
- preferFilepathJoin
- preferFprint
- preferStringWriter
- preferWriteByte
- ptrToRefParam
- rangeExprCopy
- rangeValCopy
- sliceClear
- stringXbytes

# Style
- assignOp
- boolExprSimplify
- captLocal
- commentFormatting
- commentedOutImport
- defaultCaseOrder
- deferUnlambda
- docStub
- dupImport
- elseif
- emptyFallthrough
- emptyStringTest
- exposedSyncMutex
- hexLiteral
- httpNoBody
- ifElseChain
- methodExprCall
- newDeref
- octalLiteral
- preferFilepathJoin
- redundantSprint
- regexpMust
- regexpPattern
- regexpSimplify
- returnAfterHttpError
- ruleguard
- singleCaseSwitch
- sliceClear
- sloppyLen
- sloppyReassign
- sloppyTypeAssert
- sortSlice
- sprintfQuotedString
- sqlQuery
- stringConcatSimplify
- stringXbytes
- stringsCompare
- switchTrue
- syncMapLoadAndDelete
- timeCmpSimplify
- timeExprSimplify
- todoCommentWithoutDetail
- tooManyResultsChecker
- truncateCmp
- typeAssertChain
- typeDefFirst
- typeSwitchVar
- typeUnparen
- uncheckedInlineErr
- underef
- unlabelStmt
- unlambda
- unnamedResult
- unnecessaryBlock
- unnecessaryDefer
- unslice
- valSwap
- weakCond
- wrapperFunc
- yodaStyleExpr
# - whyNoLint

# Opinionated
- builtinShadow
- importShadow
- initClause
- nestingReduce
- paramTypeCombine
- ptrToRefParam
- typeUnparen
- unnamedResult
- unnecessaryBlock
nolintlint:
# Enable to ensure that nolint directives are all used. Default is true.
allow-unused: false
# Disable to ensure that nolint directives don't have a leading space. Default is true.
# TODO(lint): Enforce machine-readable `nolint` directives
allow-leading-space: true
# Exclude following linters from requiring an explanation. Default is [].
allow-no-explanation: []
# Enable to require an explanation of nonzero length after each nolint directive. Default is false.
# TODO(lint): Enforce explanations for `nolint` directives
require-explanation: false
# Enable to require nolint directives to mention the specific linter being suppressed. Default is false.
require-specific: true
6 changes: 3 additions & 3 deletions command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type Status struct {
}

// Stream combines standard output and error
type Stream struct {
type Stream struct { //nolint: errname
stdOut string
stdErr string
}
Expand Down Expand Up @@ -195,7 +195,7 @@ func (c *Command) RunSuccessOutput() (output *Stream, err error) {
// RunSuccess starts the command and waits for it to finish. It returns an
// error if the command execution was not successful.
func (c *Command) RunSuccess() error {
_, err := c.RunSuccessOutput() // nolint: errcheck
_, err := c.RunSuccessOutput() //nolint: errcheck
return err
}

Expand Down Expand Up @@ -242,7 +242,7 @@ func (c *Command) RunSilentSuccessOutput() (output *Stream, err error) {
// an error if the command execution was not successful. This method does not
// print the output of the command during its execution.
func (c *Command) RunSilentSuccess() error {
_, err := c.RunSilentSuccessOutput() // nolint: errcheck
_, err := c.RunSilentSuccessOutput() //nolint: errcheck
return err
}

Expand Down
2 changes: 1 addition & 1 deletion command/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var atomicInt int32

// SetGlobalVerbose sets the global command verbosity to the specified value
func SetGlobalVerbose(to bool) {
var i int32 = 0
var i int32
if to {
i = 1
}
Expand Down
6 changes: 3 additions & 3 deletions dependencies.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
dependencies:
# golangci/golangci-lint
- name: "golangci-lint"
version: 1.54.2
version: 1.55.1
refPaths:
- path: mage/golang.go
- path: mage/golangci-lint.go
match: defaultGolangCILintVersion\s+=\s+"v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?"

# ko
- name: "ko"
version: 0.14.1
version: 0.15.0
refPaths:
- path: mage/ko.go
match: defaultKoVersion\s+=\s+"(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?"
Expand Down
5 changes: 3 additions & 2 deletions editor/editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (e Editor) args(path string) []string {
last := args[len(args)-1]
args[len(args)-1] = fmt.Sprintf("%s %q", last, path)
} else {
args = append(args, path) // nolint: makezero
args = append(args, path) //nolint: makezero
}
return args
}
Expand All @@ -117,7 +117,8 @@ func (e Editor) Launch(path string) error {
return err
}
args := e.args(abs)
cmd := exec.Command(args[0], args[1:]...)
// TODO: check to validate the args and maybe sabitize those
cmd := exec.Command(args[0], args[1:]...) //nolint: gosec
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
Expand Down
5 changes: 3 additions & 2 deletions hash/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
package hash

import (
"crypto/sha1"
"crypto/sha1" //nolint: gosec
"crypto/sha256"
"crypto/sha512"
"encoding/hex"
Expand All @@ -41,8 +41,9 @@ func SHA256ForFile(filename string) (string, error) {
}

// SHA1ForFile returns the hex-encoded sha1 hash for the provided filename.
// TODO: check if we can remove this function
func SHA1ForFile(filename string) (string, error) {
return ForFile(filename, sha1.New())
return ForFile(filename, sha1.New()) //nolint: gosec
}

// ForFile returns the hex-encoded hash for the provided filename and hasher.
Expand Down
Loading

0 comments on commit 05e0f47

Please sign in to comment.