-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
enable gocritic linter #4412
enable gocritic linter #4412
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #4412 +/- ##
==========================================
- Coverage 97.08% 97.07% -0.02%
==========================================
Files 300 300
Lines 17730 17728 -2
==========================================
- Hits 17214 17210 -4
- Misses 415 417 +2
Partials 101 101
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
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.
Some nice improvements, thanks!
return fmt.Errorf( | ||
"Field [%s]: Buckets should only be defined for Timer and Histogram metric types", | ||
field.Name) | ||
} | ||
} | ||
help := field.Tag.Get("help") | ||
var obj interface{} | ||
if field.Type.AssignableTo(counterPtrType) { | ||
switch { |
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 tend to prefer the switch
statement instead of if/else if chains because it's a bit cleaner and easier to read, but others maintainers may disagree.
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.
As I started to code with Java I used to be one of those. But different language, different best practices and switch case is one of those differences. Gocritic is widely used which means that the golang community follow it’s rules. If the majority of the developers of this project don’t want to conform to this rule it can be excuded in the golangci-lint config file.
By the way, I’m not aware of any golang linter forbidding switch cases let me know if you do ;)
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 rarely used switch in this manner, but why not. Readability is slightly higher, less boilerplate
Signed-off-by: Matthieu MOREL <[email protected]>
Signed-off-by: Matthieu MOREL <[email protected]>
Signed-off-by: Matthieu MOREL <[email protected]>
Head branch was pushed to by a user without write access
Short description of the changes
Signed-off-by: Matthieu MOREL [email protected]