-
Notifications
You must be signed in to change notification settings - Fork 18
chore: add linter config file and fix findings #195
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
chore: add linter config file and fix findings #195
Conversation
Signed-off-by: Sahid Velji <sahidvelji@gmail.com>
Signed-off-by: Sahid Velji <sahidvelji@gmail.com>
Signed-off-by: Sahid Velji <sahidvelji@gmail.com>
Summary of ChangesHello @sahidvelji, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the project's code quality and maintainability by integrating Highlights
Ignored Files
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request introduces golangci-lint to the project and applies a wide range of fixes based on its findings. The changes significantly improve code style, correctness, and maintainability across the codebase. Key improvements include adopting modern Go testing practices (like t.Context() and t.TempDir()), using any instead of interface{}, refactoring for better readability, and ensuring consistent code formatting. The new linter configuration in .golangci.yml is a great addition for maintaining code quality going forward. I have a couple of suggestions regarding the golangci-lint installation command in the Makefile.
| @if ! command -v golangci-lint &> /dev/null; then \ | ||
| echo "Installing golangci-lint..."; \ | ||
| go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.0; \ | ||
| go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.7.1; \ |
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 golangci-lint installation path and version appear to be incorrect. The official golangci-lint tool does not use a /v2 in its module path, and version v2.7.1 (as well as the previous v1.64.0) does not seem to be a public release. The latest public version is v1.59.1.
This might be a typo or refer to a private fork. If it's a typo, this command could fail for contributors. To ensure it works for everyone, I'd recommend using an official version.
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1; \
| @if ! command -v golangci-lint &> /dev/null; then \ | ||
| echo "Installing golangci-lint..."; \ | ||
| go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.0; \ | ||
| go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.7.1; \ |
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 golangci-lint installation path and version appear to be incorrect. The official golangci-lint tool does not use a /v2 in its module path, and version v2.7.1 (as well as the previous v1.64.0) does not seem to be a public release. The latest public version is v1.59.1.
This might be a typo or refer to a private fork. If it's a typo, this command could fail for contributors. To ensure it works for everyone, I'd recommend using an official version.
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1; \
| t := reflect.TypeOf(BaseFlag{}) | ||
| for i := 0; i < t.NumField(); i++ { | ||
| t := reflect.TypeFor[BaseFlag]() | ||
| for i := range t.NumField() { |
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.
Using range over an integer value is a great use of a new Go 1.22 feature. However, to maintain compatibility with older Go versions (the go.mod file specifies Go 1.24 but the toolchain is 1.24.1, which is fine, but as a general practice for open source projects), it might be safer to stick to the traditional for loop. If the project's minimum Go version is strictly enforced as 1.22+, then this is perfectly fine.
This PR
Related Issues
Fixes #1234523
Notes
Follow-up Tasks
How to test