-
Notifications
You must be signed in to change notification settings - Fork 186
fix: Enable gocognit linter rule
#4879
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
base: v3
Are you sure you want to change the base?
fix: Enable gocognit linter rule
#4879
Conversation
Enables the gocognit linter by removing it from the disabled list in .golangci.yml and adds //nolint:gocognit directives to functions that trigger warnings. Also removes an unused //nolint:gocognit directive that was revealed by enabling the linter. Signed-off-by: majiayu000 <[email protected]>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## v3 #4879 +/- ##
=======================================
Coverage 45.93% 45.93%
=======================================
Files 364 364
Lines 37880 37880
=======================================
Hits 17399 17399
- Misses 18805 18806 +1
+ Partials 1676 1675 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I've fixed the CI failure by removing |
Summary
This PR fixes #2343
Changes
gocognitfrom the disabled linters list in.golangci.ymlto enable the linter//nolint:gocognitdirectives to 36 functions that trigger gocognit warnings, as these functions have high cognitive complexity that is inherent to their functionality//nolint:gocognitdirective inmanaged/services/telemetry/config.gothat was revealed when the linter was enabledThe approach of using
//nolint:gocognitdirectives rather than refactoring the functions is appropriate here because:gocognitlinter is already excluded for test files (in.golangci.ymlexclusions)Test plan
golangci-lint run --enable-only gocognitreturns 0 issues//nolint:gocognitdirectives remain