Skip to content

Conversation

mtardy
Copy link
Member

@mtardy mtardy commented Apr 8, 2025

This is built on top of #3607, adding new linters to simplify the codebase and/or fix it in some places.

I know this can make backports a bit annoying but the change should always be quite straightforward and I personally think linters are useful in two aspect: welcoming new contributors by enforcing automatic rules (thus reducing style friction) and finding actual issues.

Most of the linters I added can fix their own issues with golangci-lint run --fix.

@mtardy mtardy added the release-note/ci This PR makes changes to the CI. label Apr 8, 2025
This linter checks that sentinel errors are prefixed with the Err and
error types are suffixed with the Error.

Signed-off-by: Mahe Tardy <[email protected]>
@mtardy mtardy force-pushed the pr/mtardy/golangci-lint-v2-enable-more-linters branch from af6c896 to 4283762 Compare April 9, 2025 08:37
mtardy added 5 commits April 9, 2025 04:42
Errorlint is a linter for that can be used to find code that will cause
problems with the error wrapping scheme introduced in Go 1.13.

Signed-off-by: Mahe Tardy <[email protected]>
A dedicated linter is doing what we were trying to enforce with
gomodguard.

Signed-off-by: Mahe Tardy <[email protected]>
Intrange is a linter to find places where for loops could make use of an
integer range.

Signed-off-by: Mahe Tardy <[email protected]>
Reports wrong mirror patterns of bytes/strings usage.

Signed-off-by: Mahe Tardy <[email protected]>
Checks that fmt.Sprintf can be replaced with a faster alternative.

Signed-off-by: Mahe Tardy <[email protected]>
@mtardy mtardy force-pushed the pr/mtardy/golangci-lint-v2-enable-more-linters branch from 4283762 to 9495b2a Compare April 9, 2025 08:45
@mtardy mtardy marked this pull request as ready for review April 9, 2025 08:46
@mtardy mtardy requested a review from a team as a code owner April 9, 2025 08:46
@mtardy mtardy requested a review from olsajiri April 9, 2025 08:46
Loggercheck checks for odd number of key and value pairs for common
logger libraries such as klog. Fix three minor log bugs in which we did
not use klog correctly.

Signed-off-by: Mahe Tardy <[email protected]>
@mtardy
Copy link
Member Author

mtardy commented Apr 9, 2025

@olsajiri I can wait for you to merge the tracepoint before merging this one :)

@mtardy mtardy merged commit 922be55 into main Apr 9, 2025
46 checks passed
@mtardy mtardy deleted the pr/mtardy/golangci-lint-v2-enable-more-linters branch April 9, 2025 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note/ci This PR makes changes to the CI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants