-
-
Notifications
You must be signed in to change notification settings - Fork 506
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
[TESTING/CLEANUP] Replace deprecated tenv linter for usetesting #3087
Conversation
Signed-off-by: Ilya Eryomenko <[email protected]>
Signed-off-by: Ilya Eryomenko <[email protected]>
…tion and comply with usetesting linter Signed-off-by: Ilya Eryomenko <[email protected]>
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.
Hello @GLobyNew, 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!
Summary of Changes
This pull request addresses a deprecation warning from golangci-lint
regarding the tenv
linter, which is being replaced by usetesting
. The author, GLobyNew, has replaced the linter in .golangci.yml
and addressed the new issues that arose from using usetesting
, specifically related to the use of os.Setenv()
and os.MkdirTemp()
in tests. These have been replaced with t.Setenv()
and t.TempDir()
respectively, which are considered more robust for testing and isolation. Additionally, some minor formatting issues in internal/action/find.go
were fixed.
Highlights
- Linter Replacement: The
tenv
linter has been replaced withusetesting
in.golangci.yml
to address a deprecation warning. - Test Improvements: Instances of
os.Setenv()
andos.MkdirTemp()
in tests have been replaced witht.Setenv()
andt.TempDir()
for better test isolation and robustness ininternal/updater/update_test.go
,pkg/tempfile/file_test.go
, andtests/tester.go
. - Code Formatting: Minor formatting issues in
internal/action/find.go
have been resolved.
Changelog
- .golangci.yml
- Replaced the deprecated
tenv
linter withusetesting
.
- Replaced the deprecated
- internal/action/find.go
- Added a newline to fix formatting issues.
- internal/updater/update_test.go
- Replaced
os.Setenv()
witht.Setenv()
inTestIsUpdateable
for better test isolation on lines 51 and 66.
- Replaced
- pkg/tempfile/file_test.go
- Replaced
os.MkdirTemp()
witht.TempDir()
inTestTempdirBase
for better test isolation on line 49.
- Replaced
- tests/tester.go
- Replaced
os.MkdirTemp()
witht.TempDir()
innewTester
for better test isolation on line 73.
- Replaced
Using Gemini Code Assist
The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
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 .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and 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 to provide feedback.
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.
A linter's warning, a gentle nudge,
To keep our codebase free from sludge.
From deprecated paths, we now depart,
With testing's embrace, a brand new start.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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
The pull request replaces the deprecated tenv
linter with usetesting
and addresses the issues it raised. The changes generally improve the testing practices by using t.Setenv()
and t.TempDir()
. However, there are a few areas that could be improved for clarity and robustness.
Summary of Findings
- Redundant nil return: The
return nil
statements ininternal/updater/update_test.go
are redundant becauset.Setenv
does not return an error. Removing them simplifies the code. - Unnecessary error check removal: The removal of
require.NoError(t, err)
intests/tester.go
andpkg/tempfile/file_test.go
is concerning. Whilet.TempDir()
handles the error internally, explicitly checking for an error provides better context and control during testing. Reintroducing the error check would enhance the robustness of the tests. - Code formatting: The added blank lines in
internal/action/find.go
do not seem to add any value and should be removed.
Merge Readiness
The pull request is almost ready for merging. Addressing the redundant return nil
statements and reintroducing the error check after t.TempDir()
would improve the code. The formatting in internal/action/find.go
should also be corrected. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging.
Signed-off-by: Ilya Eryomenko <[email protected]>
Commited additional checks as Gimini suggested. |
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.
Thanks for replacing the linter and fixing the issues. All very good improvements.
When I try to run
make codequality
I receive:GOLANGCI-LINT WARN The linter 'tenv' is deprecated (since v1.64.0) due to: Duplicate feature in another linter. Replaced by usetesting.
By recommendation above I replaced linter and it showed me new issues:
All fixed, I believe the testing's Setenv() and TempDir() is more robust for testing and isolation.
Also there was some problems with find.go file also by codequality test. Fixed them as well.
All tests are passed.