Skip to content

Commit

Permalink
chore: fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
msvticket committed Oct 10, 2024
1 parent d3df2ee commit 1bde461
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 57 deletions.
62 changes: 19 additions & 43 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
linters-settings:
depguard:
list-type: blacklist
packages:
- github.com/jenkins-x/jx/v2/pkg/log/
- github.com/satori/go.uuid
- github.com/pborman/uuid
packages-with-error-message:
- github.com/jenkins-x/jx/v2/pkg/log/: "use jenkins-x/jx-logging instead"
- github.com/satori/go.uuid: "use github.com/google/uuid instead"
- github.com/pborman/uuid: "use github.com/google/uuid instead"
rules:
# Name of a rule.
Main:
list-mode: lax
deny:
- pkg: github.com/jenkins-x/jx/v2/pkg/log/
desc: "use jenkins-x/jx-logging instead"
- pkg: github.com/satori/go.uuid
desc: "use github.com/google/uuid instead"
- pkg: github.com/pborman/uuid
desc: "use github.com/google/uuid instead"
dupl:
threshold: 100
exhaustive:
Expand Down Expand Up @@ -37,17 +39,14 @@ linters-settings:
gocyclo:
min-complexity: 15
goimports: {}
golint:
min-confidence: 0
revive:
confidence: 0
gofmt:
simplify: true
gomnd:
settings:
mnd:
# don't include the "operation" and "assign"
checks: [argument, case, condition, return]
mnd:
# don't include the "operation" and "assign"
checks: [argument, case, condition, return]
govet:
check-shadowing: true
settings:
printf:
funcs:
Expand All @@ -58,11 +57,8 @@ linters-settings:
- (github.com/jenkins-x/jx-logging/v3/pkg/log/Logger()).Fatalf
lll:
line-length: 140
maligned:
suggest-new: true
misspell: {}
nolintlint:
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
allow-unused: false # report any unused nolint directives
require-explanation: false # don't require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
Expand All @@ -73,7 +69,6 @@ linters:
enable:
- asciicheck
- bodyclose
- deadcode
- depguard
- errcheck
- gofmt
Expand All @@ -86,36 +81,17 @@ linters:
- nakedret
- rowserrcheck
- staticcheck
- structcheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- revive
#- revive
- gocritic
- govet
issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
# - path: _test\.go
# linters:
# - gomnd
# https://github.com/go-critic/go-critic/issues/926
- linters:
- gocritic
text: "unnecessaryDefer:"
exclude:
- 'shadow: declaration of "err" shadows declaration at'
max-same-issues: 0

exclude-dirs:
- cmd/docs
run:
timeout: 30m
skip-dirs:
- cmd/docs
# golangci.com configuration
# https://github.com/golangci/golangci/wiki/Configuration
service:
golangci-lint-version: 1.42.x # use the fixed version to not introduce new linters unexpectedly
prepare:
- echo "here I can run custom commands, but no preparation needed for this repo"
29 changes: 15 additions & 14 deletions pkg/masker/watcher/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,22 @@ func (o *Options) RunWithChannel(stop chan struct{}) error {
log.Logger().Infof("Watching for Secret resources in namespace %s", ns)
listWatch := cache.NewListWatchFromClient(o.KubeClient.CoreV1().RESTClient(), "secrets", ns, fields.Everything())
kube.SortListWatchByName(listWatch)
_, ctrl := cache.NewInformer(
listWatch,
secret,
time.Minute*10,
cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
o.onSecret(ns, obj)
_, ctrl := cache.NewInformerWithOptions(
cache.InformerOptions{
ListerWatcher: listWatch,
ObjectType: secret,
Handler: cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
o.onSecret(ns, obj)
},
UpdateFunc: func(oldObj, newObj interface{}) {
o.onSecret(ns, newObj)
},
DeleteFunc: func(obj interface{}) {
},
},
UpdateFunc: func(oldObj, newObj interface{}) {
o.onSecret(ns, newObj)
},
DeleteFunc: func(obj interface{}) {
},
},
)
ResyncPeriod: time.Minute * 10,
})
go ctrl.Run(stop)
}
return nil
Expand Down

0 comments on commit 1bde461

Please sign in to comment.