mirror of
https://github.com/mgechev/revive.git
synced 2025-11-23 22:04:49 +02:00
feature(deep-exit): detect exit-triggering flag usage (#1544)
This commit is contained in:
committed by
GitHub
parent
d32d4a008f
commit
1bc57ac6f3
13
testdata/deep_exit.go
vendored
13
testdata/deep_exit.go
vendored
@@ -1,6 +1,7 @@
|
||||
package fixtures
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"log"
|
||||
"os"
|
||||
"syscall"
|
||||
@@ -36,3 +37,15 @@ func TestMain(m *testing.M) {
|
||||
// must match because this is not a test file
|
||||
os.Exit(m.Run()) // MATCH /calls to os.Exit only in main() or init() functions/
|
||||
}
|
||||
|
||||
func flagParseOutsideMain() {
|
||||
flag.Parse() // MATCH /calls to flag.Parse only in main() or init() functions/
|
||||
}
|
||||
|
||||
func flagNewFlagSetExitOnErrorOutsideMain() {
|
||||
flag.NewFlagSet("cmd", flag.ExitOnError) // MATCH /calls to flag.NewFlagSet with flag.ExitOnError only in main() or init() functions/
|
||||
}
|
||||
|
||||
func flagNewFlagSetContinueOnErrorOK() {
|
||||
flag.NewFlagSet("cmd", flag.ContinueOnError)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user