redundant-test-main-exit: allow flag.Parse() in TestMain#1599
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #1598 by modifying the redundant-test-main-exit rule to allow flag.Parse() calls in TestMain functions. The change recognizes that flag.Parse() is commonly used in TestMain to enable checking of test flags like testing.Short().
Key Changes
- Added logic to skip flagging
flag.Parse()calls as redundant inTestMainfunctions - Added a test case demonstrating the valid use of
flag.Parse()withtesting.Short()inTestMain
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
rule/redundant_test_main_exit.go |
Added check to skip all flag package calls before checking for exit functions |
testdata/go1.15/redundant_test_main_exit_test.go |
Added test case showing flag.Parse() used with testing.Short() that should not be flagged |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ccoVeille
left a comment
There was a problem hiding this comment.
OK for a quick fix, but I wonder if it could be better
I propose to skip functions from the package
flag:flag.Parse,flag.NewFlagSet.Fixes #1598.