-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change to the same way of linting as ocm repo, and upgrade golint-ci version and configuration. #481
Conversation
73b5e5d
to
2e14a18
Compare
/retest |
f3737a3
to
a483670
Compare
671c5ed
to
799b024
Compare
@@ -39,8 +39,7 @@ func extractBootstrapKubeConfigDataFromImportSecret(importSecret *corev1.Secret) | |||
|
|||
for _, yaml := range helpers.SplitYamls(importYaml) { | |||
obj := helpers.MustCreateObject(yaml) | |||
switch secret := obj.(type) { | |||
case *corev1.Secret: | |||
if secret, ok := obj.(*corev1.Secret); ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix:
pkg/controller/importconfig/cluster_info.go:42:3: singleCaseSwitch: should rewrite switch statement to if statement (gocritic)
switch secret := obj.(type) {
@@ -980,10 +980,10 @@ func ValidateNodeSelector(nodeSelector map[string]string) error { | |||
errs := []error{} | |||
for key, val := range nodeSelector { | |||
if errMsgs := validation.IsQualifiedName(key); len(errMsgs) != 0 { | |||
errs = append(errs, fmt.Errorf(strings.Join(errMsgs, ";"))) | |||
errs = append(errs, fmt.Errorf("%s", strings.Join(errMsgs, ";"))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A big type of lint errors is non-constant format string
:
pkg/source/source.go:120:17: printf: non-constant format string in call to k8s.io/klog/v2.Errorf (govet)
klog.Errorf(fmt.Sprintf("OnAdd missing Object, type %T", obj))
^
pkg/source/source.go:125:17: printf: non-constant format string in call to k8s.io/klog/v2.Errorf (govet)
klog.Errorf(fmt.Sprintf("OnAdd missing Object, type %T", obj))
^
pkg/source/source.go:142:17: printf: non-constant format string in call to k8s.io/klog/v2.Errorf (govet)
klog.Errorf(fmt.Sprintf("OnAdd missing Object, type %T", oldObj))
^
pkg/source/source.go:147:17: printf: non-constant format string in call to k8s.io/klog/v2.Errorf (govet)
klog.Errorf(fmt.Sprintf("OnAdd missing Object, type %T", oldObj))
^
pkg/source/source.go:153:17: printf: non-constant format string in call to k8s.io/klog/v2.Errorf (govet)
klog.Errorf(fmt.Sprintf("OnAdd missing Object, type %T", newObj))
^
pkg/source/source.go:158:17: printf: non-constant format string in call to k8s.io/klog/v2.Errorf (govet)
klog.Errorf(fmt.Sprintf("OnAdd missing Object, type %T", newObj))
^
pkg/source/source.go:177:18: printf: non-constant format string in call to k8s.io/klog/v2.Errorf (govet)
klog.Errorf(fmt.Sprintf("Error decoding objects. Expected cache.DeletedFinalStateUnknown, type %T", obj))
^
pkg/source/source.go:187:17: printf: non-constant format string in call to k8s.io/klog/v2.Errorf (govet)
klog.Errorf(fmt.Sprintf("OnDelete missing Object, type %T", obj))
^
pkg/helpers/helpers.go:983:35: printf: non-constant format string in call to fmt.Errorf (govet)
errs = append(errs, fmt.Errorf(strings.Join(errMsgs, ";")))
^
pkg/helpers/helpers.go:986:35: printf: non-constant format string in call to fmt.Errorf (govet)
errs = append(errs, fmt.Errorf(strings.Join(errMsgs, ";")))
^
pkg/helpers/helpers.go:999:36: printf: non-constant format string in call to fmt.Errorf (govet)
errs = append(errs, fmt.Errorf(strings.Join(errMsgs, ";")))
^
pkg/helpers/helpers.go:1020:36: printf: non-constant format string in call to fmt.Errorf (govet)
errs = append(errs, fmt.Errorf(strings.Join(errMsgs, ";")))
6a2c0f0
to
b65b6ad
Compare
@@ -124,7 +124,11 @@ func main() { | |||
pflag.Parse() | |||
|
|||
logs.InitLogs() | |||
defer logs.FlushLogs() | |||
exitCode := 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes:
exitAfterDefer: os.Exit will exit, and `defer logs.FlushLogs()` will not run (gocritic)
/assign @zhujian7 |
@@ -214,8 +127,15 @@ issues: | |||
# Default value for this option is true. | |||
exclude-use-default: true | |||
|
|||
# Maximum issues count per one linter. Set to 0 to disable. Default is 50. | |||
max-per-linter: 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The field is not supported by the latest golangci-lint, it will report error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's also a dup of max-issues-per-linter: 0
set above.
Makefile
Outdated
@@ -51,7 +51,8 @@ check-copyright: | |||
|
|||
.PHONY: lint | |||
lint: | |||
build/run-lint-check.sh | |||
go install github.com/golangci/golangci-lint/cmd/[email protected] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to install the golint to the current project sub dir, so it will affect the global linter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! Updated to put golint into _output
dir with other tools.
Signed-off-by: xuezhaojun <[email protected]>
b65b6ad
to
95e2fc7
Compare
|
/retest |
The EC check occasionally passes and sometimes fails. I'm unsure whether we need to address it or overwrite it. |
/retest |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: xuezhaojun, zhujian7 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
it seems there are 2 new cves:
@xuezhaojun can you use your script to figure out what they are? |
There are 3 High cve but not cases we can solve in our code:
|
golint get fail in the old way: https://prow.ci.openshift.org/view/gs/test-platform-results/pr-logs/pull/stolostron_managedcluster-import-controller/475/pull-ci-stolostron-managedcluster-import-controller-main-check/1887846831249952768