Skip to content

Commit

Permalink
Merge pull request kubernetes-sigs#1507 from kubernetes-sigs/revert-1…
Browse files Browse the repository at this point in the history
…506-gocritic

Revert "Enable and fix all gocritic linters"
  • Loading branch information
k8s-ci-robot authored Jul 22, 2024
2 parents f016e27 + 011a460 commit fdcc742
Show file tree
Hide file tree
Showing 55 changed files with 521 additions and 461 deletions.
130 changes: 98 additions & 32 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,27 @@
---
run:
concurrency: 6
timeout: 5m
deadline: 5m
linters:
disable-all: true
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- canonicalheader
- containedctx
- contextcheck
- copyloopvar
- decorder
- dogsled
- dupl
- dupword
- durationcheck
- errchkjson
- errname
- errorlint
- exhaustive
- exportloopref
- fatcontext
- forcetypeassert
- gci
- ginkgolinter
- gocheckcompilerdirectives
- gochecksumtype
- gocritic
- godot
- gofmt
- gofumpt
- goheader
- goimports
- gomoddirectives
- gomodguard
- goprintffuncname
- gosimple
- gosmopolitan
- govet
- grouper
Expand All @@ -55,70 +38,153 @@ linters:
- musttag
- nakedret
- nilerr
- noctx
- nolintlint
- nosprintfhostport
- perfsprint
- prealloc
- predeclared
- promlinter
- protogetter
- reassign
- rowserrcheck
- sloglint
- spancheck
- sqlclosecheck
- staticcheck
- tagalign
- tagliatelle
- tenv
- testableexamples
- testifylint
- tparallel
- typecheck
- unconvert
- unparam
- unused
- usestdlibvars
- wastedassign
- whitespace
- zerologlint
# - asciicheck
# - bodyclose
# - contextcheck
# - cyclop
# - depguard
# - dogsled
# - err113
# - errcheck
# - errchkjson
# - errorlint
# - exhaustive
# - exhaustruct
# - exportloopref
# - forbidigo
# - funlen
# - gci
# - ginkgolinter
# - gochecknoglobals
# - gochecknoinits
# - gocognit
# - goconst
# - gocyclo
# - godot
# - godox
# - gofumpt
# - goheader
# - gomoddirectives
# - gomodguard
# - goprintffuncname
# - gosec
# - gosimple
# - ireturn
# - lll
# - mnd
# - nestif
# - nilnil
# - nlreturn
# - noctx
# - nolintlint
# - nonamedreturns
# - paralleltest
# - revive
# - rowserrcheck
# - sqlclosecheck
# - stylecheck
# - testpackage
# - thelper
# - tparallel
# - unconvert
# - unparam
# - varnamelen
# - whitespace
# - wrapcheck
# - wsl
linters-settings:
gci:
sections:
- standard
- default
- localmodule
staticcheck:
checks: ["SA1019"]
gocritic:
enable-all: true
enabled-checks:
- appendCombine
- badLock
- badRegexp
- badSorting
- badSyncOnceFunc
- boolExprSimplify
- builtinShadow
- builtinShadowDecl
- commentedOutCode
- commentedOutImport
- deferInLoop
- deferUnlambda
- docStub
- dupImport
- dynamicFmtString
- emptyDecl
- emptyFallthrough
- equalFold
- evalOrder
- exposedSyncMutex
- externalErrorReassign
- filepathJoin
- hexLiteral
- httpNoBody
- indexAlloc
- initClause
- methodExprCall
- nestingReduce
- nilValReturn
- preferDecodeRune
- preferFilepathJoin
- preferFprint
- preferStringWriter
- preferWriteByte
- ptrToRefParam
- rangeExprCopy
- rangeValCopy
- redundantSprint
- regexpPattern
- regexpSimplify
- returnAfterHttpError
- ruleguard
- sliceClear
- sloppyReassign
- sortSlice
- sprintfQuotedString
- sqlQuery
- stringConcatSimplify
- stringXbytes
- stringsCompare
- syncMapLoadAndDelete
- timeExprSimplify
- todoCommentWithoutDetail
- tooManyResultsChecker
- truncateCmp
- typeAssertChain
- typeDefFirst
- typeUnparen
- uncheckedInlineErr
- unlabelStmt
- unnecessaryBlock
- unnecessaryDefer
- weakCond
- yodaStyleExpr
# - emptyStringTest
# - hugeParam
# - importShadow
# - octalLiteral
# - paramTypeCombine
# - unnamedResult
# - whyNoLint
6 changes: 4 additions & 2 deletions cmd/crictl/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,24 @@ var runtimeAttachCommand = &cli.Command{
ctx, cancel := context.WithCancel(c.Context)
defer cancel()

opts := attachOptions{
var opts = attachOptions{
id: id,
tty: c.Bool("tty"),
stdin: c.Bool("stdin"),
}
if err = Attach(ctx, runtimeClient, opts); err != nil {
return fmt.Errorf("attaching running container failed: %w", err)

}
return nil
},
}

// Attach sends an AttachRequest to server, and parses the returned AttachResponse.
// Attach sends an AttachRequest to server, and parses the returned AttachResponse
func Attach(ctx context.Context, client internalapi.RuntimeService, opts attachOptions) error {
if opts.id == "" {
return errors.New("ID cannot be empty")

}
request := &pb.AttachRequest{
ContainerId: opts.id,
Expand Down
5 changes: 4 additions & 1 deletion cmd/crictl/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ func bashCompletion(c *cli.Context) error {
if command.Hidden {
continue
}
subcommands = append(subcommands, command.Names()...)
for _, name := range command.Names() {
subcommands = append(subcommands, name)
}
}

for _, flag := range c.App.Flags {
Expand Down Expand Up @@ -88,6 +90,7 @@ func zshCompletion(c *cli.Context) error {

fmt.Fprintln(c.App.Writer, fmt.Sprintf(zshCompletionTemplate, strings.Join(subcommands, "' '"), strings.Join(opts, "' '")))
return nil

}

func fishCompletion(c *cli.Context) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/crictl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ CRICTL OPTIONS:
}
return common.WriteConfig(config, configFile)
} else if c.Bool("list") {
display := newDefaultTableDisplay()
display := newTableDisplay(20, 1, 3, ' ', 0)
display.AddRow([]string{columnKey, columnValue})
display.AddRow([]string{"runtime-endpoint", config.RuntimeEndpoint})
display.AddRow([]string{"image-endpoint", config.ImageEndpoint})
Expand Down
Loading

0 comments on commit fdcc742

Please sign in to comment.