-
Notifications
You must be signed in to change notification settings - Fork 128
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
PMM-7 enable gocritic
linter rule
#2281
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2281 +/- ##
=======================================
Coverage 42.94% 42.95%
=======================================
Files 386 386
Lines 47994 47976 -18
=======================================
- Hits 20611 20607 -4
+ Misses 25455 25447 -8
+ Partials 1928 1922 -6
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 3 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@@ -201,7 +201,7 @@ func parseKeyValueFromComment(s string) (map[string]bool, error) { | |||
func prepareMultilineRegexp() error { | |||
// to compile regexp only once | |||
multilineOnce.Do(func() { | |||
multilineRegexp, errMultiline = regexp.Compile(`(?s)\/\*(.*?)\*\/`) | |||
multilineRegexp, errMultiline = regexp.Compile(`(?s)\/\*(.*?)\*\/`) //nolint:gocritic |
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.
@JiriCtvrtka I believe we can use regexp.MustCompile
everywhere in this file and simplify the code.
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.
and by using MustCompile
we can migrate the initialization of regexp
s to the top of the file
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.
Great job!
@@ -201,7 +201,7 @@ func parseKeyValueFromComment(s string) (map[string]bool, error) { | |||
func prepareMultilineRegexp() error { | |||
// to compile regexp only once | |||
multilineOnce.Do(func() { | |||
multilineRegexp, errMultiline = regexp.Compile(`(?s)\/\*(.*?)\*\/`) | |||
multilineRegexp, errMultiline = regexp.Compile(`(?s)\/\*(.*?)\*\/`) //nolint:gocritic |
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.
and by using MustCompile
we can migrate the initialization of regexp
s to the top of the file
//nolint:nestif | ||
if err == nil { | ||
switch { | ||
case err == nil: |
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.
I think it can be just
if err != nil {
if errors.Is(err, rest.ErrNotInCluster) {
in.l.Info("PMM is running outside a kubernetes cluster")
return nil
}
in.l.Errorf("failed getting kubeconfig inside cluster: %v", err)
return nil
}
// Code for case when we don't have error at all
I'll merge this PR to enable the rule and create another issue to address just the |
PMM-7
Ref: #1541
This PR: