1
0

Update module spf13/viper to v1.7.0 (#494)

Update module spf13/viper to v1.7.0

Reviewed-on: https://kolaente.dev/vikunja/api/pulls/494
This commit is contained in:
renovate
2020-05-09 13:44:17 +00:00
committed by konrad
parent 18f6e31b54
commit def2362682
89 changed files with 9018 additions and 4502 deletions

View File

@ -0,0 +1,525 @@
package staticcheck
import (
"flag"
"honnef.co/go/tools/facts"
"honnef.co/go/tools/internal/passes/buildssa"
"honnef.co/go/tools/lint/lintutil"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/inspect"
)
func newFlagSet() flag.FlagSet {
fs := flag.NewFlagSet("", flag.PanicOnError)
fs.Var(lintutil.NewVersionFlag(), "go", "Target Go version")
return *fs
}
var Analyzers = map[string]*analysis.Analyzer{
"SA1000": {
Name: "SA1000",
Run: callChecker(checkRegexpRules),
Doc: Docs["SA1000"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer, valueRangesAnalyzer},
Flags: newFlagSet(),
},
"SA1001": {
Name: "SA1001",
Run: CheckTemplate,
Doc: Docs["SA1001"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA1002": {
Name: "SA1002",
Run: callChecker(checkTimeParseRules),
Doc: Docs["SA1002"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer, valueRangesAnalyzer},
Flags: newFlagSet(),
},
"SA1003": {
Name: "SA1003",
Run: callChecker(checkEncodingBinaryRules),
Doc: Docs["SA1003"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer, valueRangesAnalyzer},
Flags: newFlagSet(),
},
"SA1004": {
Name: "SA1004",
Run: CheckTimeSleepConstant,
Doc: Docs["SA1004"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA1005": {
Name: "SA1005",
Run: CheckExec,
Doc: Docs["SA1005"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA1006": {
Name: "SA1006",
Run: CheckUnsafePrintf,
Doc: Docs["SA1006"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA1007": {
Name: "SA1007",
Run: callChecker(checkURLsRules),
Doc: Docs["SA1007"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer, valueRangesAnalyzer},
Flags: newFlagSet(),
},
"SA1008": {
Name: "SA1008",
Run: CheckCanonicalHeaderKey,
Doc: Docs["SA1008"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA1010": {
Name: "SA1010",
Run: callChecker(checkRegexpFindAllRules),
Doc: Docs["SA1010"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer, valueRangesAnalyzer},
Flags: newFlagSet(),
},
"SA1011": {
Name: "SA1011",
Run: callChecker(checkUTF8CutsetRules),
Doc: Docs["SA1011"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer, valueRangesAnalyzer},
Flags: newFlagSet(),
},
"SA1012": {
Name: "SA1012",
Run: CheckNilContext,
Doc: Docs["SA1012"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA1013": {
Name: "SA1013",
Run: CheckSeeker,
Doc: Docs["SA1013"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA1014": {
Name: "SA1014",
Run: callChecker(checkUnmarshalPointerRules),
Doc: Docs["SA1014"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer, valueRangesAnalyzer},
Flags: newFlagSet(),
},
"SA1015": {
Name: "SA1015",
Run: CheckLeakyTimeTick,
Doc: Docs["SA1015"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer},
Flags: newFlagSet(),
},
"SA1016": {
Name: "SA1016",
Run: CheckUntrappableSignal,
Doc: Docs["SA1016"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA1017": {
Name: "SA1017",
Run: callChecker(checkUnbufferedSignalChanRules),
Doc: Docs["SA1017"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer, valueRangesAnalyzer},
Flags: newFlagSet(),
},
"SA1018": {
Name: "SA1018",
Run: callChecker(checkStringsReplaceZeroRules),
Doc: Docs["SA1018"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer, valueRangesAnalyzer},
Flags: newFlagSet(),
},
"SA1019": {
Name: "SA1019",
Run: CheckDeprecated,
Doc: Docs["SA1019"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Deprecated},
Flags: newFlagSet(),
},
"SA1020": {
Name: "SA1020",
Run: callChecker(checkListenAddressRules),
Doc: Docs["SA1020"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer, valueRangesAnalyzer},
Flags: newFlagSet(),
},
"SA1021": {
Name: "SA1021",
Run: callChecker(checkBytesEqualIPRules),
Doc: Docs["SA1021"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer, valueRangesAnalyzer},
Flags: newFlagSet(),
},
"SA1023": {
Name: "SA1023",
Run: CheckWriterBufferModified,
Doc: Docs["SA1023"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer},
Flags: newFlagSet(),
},
"SA1024": {
Name: "SA1024",
Run: callChecker(checkUniqueCutsetRules),
Doc: Docs["SA1024"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer, valueRangesAnalyzer},
Flags: newFlagSet(),
},
"SA1025": {
Name: "SA1025",
Run: CheckTimerResetReturnValue,
Doc: Docs["SA1025"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer},
Flags: newFlagSet(),
},
"SA1026": {
Name: "SA1026",
Run: callChecker(checkUnsupportedMarshal),
Doc: Docs["SA1026"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer, valueRangesAnalyzer},
Flags: newFlagSet(),
},
"SA1027": {
Name: "SA1027",
Run: callChecker(checkAtomicAlignment),
Doc: Docs["SA1027"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer, valueRangesAnalyzer},
Flags: newFlagSet(),
},
"SA2000": {
Name: "SA2000",
Run: CheckWaitgroupAdd,
Doc: Docs["SA2000"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA2001": {
Name: "SA2001",
Run: CheckEmptyCriticalSection,
Doc: Docs["SA2001"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA2002": {
Name: "SA2002",
Run: CheckConcurrentTesting,
Doc: Docs["SA2002"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer},
Flags: newFlagSet(),
},
"SA2003": {
Name: "SA2003",
Run: CheckDeferLock,
Doc: Docs["SA2003"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer},
Flags: newFlagSet(),
},
"SA3000": {
Name: "SA3000",
Run: CheckTestMainExit,
Doc: Docs["SA3000"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA3001": {
Name: "SA3001",
Run: CheckBenchmarkN,
Doc: Docs["SA3001"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA4000": {
Name: "SA4000",
Run: CheckLhsRhsIdentical,
Doc: Docs["SA4000"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer, facts.TokenFile, facts.Generated},
Flags: newFlagSet(),
},
"SA4001": {
Name: "SA4001",
Run: CheckIneffectiveCopy,
Doc: Docs["SA4001"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA4002": {
Name: "SA4002",
Run: CheckDiffSizeComparison,
Doc: Docs["SA4002"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer, valueRangesAnalyzer},
Flags: newFlagSet(),
},
"SA4003": {
Name: "SA4003",
Run: CheckExtremeComparison,
Doc: Docs["SA4003"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA4004": {
Name: "SA4004",
Run: CheckIneffectiveLoop,
Doc: Docs["SA4004"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA4006": {
Name: "SA4006",
Run: CheckUnreadVariableValues,
Doc: Docs["SA4006"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer, facts.Generated},
Flags: newFlagSet(),
},
"SA4008": {
Name: "SA4008",
Run: CheckLoopCondition,
Doc: Docs["SA4008"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer},
Flags: newFlagSet(),
},
"SA4009": {
Name: "SA4009",
Run: CheckArgOverwritten,
Doc: Docs["SA4009"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer},
Flags: newFlagSet(),
},
"SA4010": {
Name: "SA4010",
Run: CheckIneffectiveAppend,
Doc: Docs["SA4010"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer},
Flags: newFlagSet(),
},
"SA4011": {
Name: "SA4011",
Run: CheckScopedBreak,
Doc: Docs["SA4011"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA4012": {
Name: "SA4012",
Run: CheckNaNComparison,
Doc: Docs["SA4012"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer},
Flags: newFlagSet(),
},
"SA4013": {
Name: "SA4013",
Run: CheckDoubleNegation,
Doc: Docs["SA4013"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA4014": {
Name: "SA4014",
Run: CheckRepeatedIfElse,
Doc: Docs["SA4014"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA4015": {
Name: "SA4015",
Run: callChecker(checkMathIntRules),
Doc: Docs["SA4015"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer, valueRangesAnalyzer},
Flags: newFlagSet(),
},
"SA4016": {
Name: "SA4016",
Run: CheckSillyBitwiseOps,
Doc: Docs["SA4016"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer, facts.TokenFile},
Flags: newFlagSet(),
},
"SA4017": {
Name: "SA4017",
Run: CheckPureFunctions,
Doc: Docs["SA4017"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer, facts.Purity},
Flags: newFlagSet(),
},
"SA4018": {
Name: "SA4018",
Run: CheckSelfAssignment,
Doc: Docs["SA4018"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated, facts.TokenFile},
Flags: newFlagSet(),
},
"SA4019": {
Name: "SA4019",
Run: CheckDuplicateBuildConstraints,
Doc: Docs["SA4019"].String(),
Requires: []*analysis.Analyzer{facts.Generated},
Flags: newFlagSet(),
},
"SA4020": {
Name: "SA4020",
Run: CheckUnreachableTypeCases,
Doc: Docs["SA4020"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA4021": {
Name: "SA4021",
Run: CheckSingleArgAppend,
Doc: Docs["SA4021"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated, facts.TokenFile},
Flags: newFlagSet(),
},
"SA5000": {
Name: "SA5000",
Run: CheckNilMaps,
Doc: Docs["SA5000"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer},
Flags: newFlagSet(),
},
"SA5001": {
Name: "SA5001",
Run: CheckEarlyDefer,
Doc: Docs["SA5001"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA5002": {
Name: "SA5002",
Run: CheckInfiniteEmptyLoop,
Doc: Docs["SA5002"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA5003": {
Name: "SA5003",
Run: CheckDeferInInfiniteLoop,
Doc: Docs["SA5003"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA5004": {
Name: "SA5004",
Run: CheckLoopEmptyDefault,
Doc: Docs["SA5004"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA5005": {
Name: "SA5005",
Run: CheckCyclicFinalizer,
Doc: Docs["SA5005"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer},
Flags: newFlagSet(),
},
"SA5007": {
Name: "SA5007",
Run: CheckInfiniteRecursion,
Doc: Docs["SA5007"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer},
Flags: newFlagSet(),
},
"SA5008": {
Name: "SA5008",
Run: CheckStructTags,
Doc: Docs["SA5008"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA5009": {
Name: "SA5009",
Run: callChecker(checkPrintfRules),
Doc: Docs["SA5009"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer, valueRangesAnalyzer},
Flags: newFlagSet(),
},
"SA6000": {
Name: "SA6000",
Run: callChecker(checkRegexpMatchLoopRules),
Doc: Docs["SA6000"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer, valueRangesAnalyzer},
Flags: newFlagSet(),
},
"SA6001": {
Name: "SA6001",
Run: CheckMapBytesKey,
Doc: Docs["SA6001"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer},
Flags: newFlagSet(),
},
"SA6002": {
Name: "SA6002",
Run: callChecker(checkSyncPoolValueRules),
Doc: Docs["SA6002"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer, valueRangesAnalyzer},
Flags: newFlagSet(),
},
"SA6003": {
Name: "SA6003",
Run: CheckRangeStringRunes,
Doc: Docs["SA6003"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer},
Flags: newFlagSet(),
},
"SA6005": {
Name: "SA6005",
Run: CheckToLowerToUpperComparison,
Doc: Docs["SA6005"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA9001": {
Name: "SA9001",
Run: CheckDubiousDeferInChannelRangeLoop,
Doc: Docs["SA9001"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA9002": {
Name: "SA9002",
Run: CheckNonOctalFileMode,
Doc: Docs["SA9002"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
"SA9003": {
Name: "SA9003",
Run: CheckEmptyBranch,
Doc: Docs["SA9003"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer, facts.TokenFile, facts.Generated},
Flags: newFlagSet(),
},
"SA9004": {
Name: "SA9004",
Run: CheckMissingEnumTypesInDeclaration,
Doc: Docs["SA9004"].String(),
Requires: []*analysis.Analyzer{inspect.Analyzer},
Flags: newFlagSet(),
},
// Filtering generated code because it may include empty structs generated from data models.
"SA9005": {
Name: "SA9005",
Run: callChecker(checkNoopMarshal),
Doc: Docs["SA9005"].String(),
Requires: []*analysis.Analyzer{buildssa.Analyzer, valueRangesAnalyzer, facts.Generated, facts.TokenFile},
Flags: newFlagSet(),
},
}

View File

@ -1,39 +1,37 @@
package staticcheck
var docSA1000 = `Invalid regular expression
import "honnef.co/go/tools/lint"
Available since
2017.1
`
var Docs = map[string]*lint.Documentation{
"SA1000": &lint.Documentation{
Title: `Invalid regular expression`,
Since: "2017.1",
},
var docSA1001 = `Invalid template
"SA1001": &lint.Documentation{
Title: `Invalid template`,
Since: "2017.1",
},
Available since
2017.1
`
"SA1002": &lint.Documentation{
Title: `Invalid format in time.Parse`,
Since: "2017.1",
},
var docSA1002 = `Invalid format in time.Parse
Available since
2017.1
`
var docSA1003 = `Unsupported argument to functions in encoding/binary
The encoding/binary package can only serialize types with known sizes.
This precludes the use of the 'int' and 'uint' types, as their sizes
"SA1003": &lint.Documentation{
Title: `Unsupported argument to functions in encoding/binary`,
Text: `The encoding/binary package can only serialize types with known sizes.
This precludes the use of the int and uint types, as their sizes
differ on different architectures. Furthermore, it doesn't support
serializing maps, channels, strings, or functions.
Before Go 1.8, bool wasn't supported, either.
Before Go 1.8, bool wasn't supported, either.`,
Since: "2017.1",
},
Available since
2017.1
`
var docSA1004 = `Suspiciously small untyped constant in time.Sleep
The time.Sleep function takes a time.Duration as its only argument.
"SA1004": &lint.Documentation{
Title: `Suspiciously small untyped constant in time.Sleep`,
Text: `The time.Sleep function takes a time.Duration as its only argument.
Durations are expressed in nanoseconds. Thus, calling time.Sleep(1)
will sleep for 1 nanosecond. This is a common source of bugs, as sleep
functions in other languages often accept seconds or milliseconds.
@ -43,16 +41,14 @@ large durations. These can be combined with arithmetic to express
arbitrary durations, for example '5 * time.Second' for 5 seconds.
If you truly meant to sleep for a tiny amount of time, use
'n * time.Nanosecond" to signal to staticcheck that you did mean to sleep
for some amount of nanoseconds.
'n * time.Nanosecond' to signal to staticcheck that you did mean to sleep
for some amount of nanoseconds.`,
Since: "2017.1",
},
Available since
2017.1
`
var docSA1005 = `Invalid first argument to exec.Command
os/exec runs programs directly (using variants of the fork and exec
"SA1005": &lint.Documentation{
Title: `Invalid first argument to exec.Command`,
Text: `os/exec runs programs directly (using variants of the fork and exec
system calls on Unix systems). This shouldn't be confused with running
a command in a shell. The shell will allow for features such as input
redirection, pipes, and general scripting. The shell is also
@ -69,15 +65,13 @@ If you want to run a command in a shell, consider using something like
the following but be aware that not all systems, particularly
Windows, will have a /bin/sh program:
exec.Command("/bin/sh", "-c", "ls | grep Awesome")
exec.Command("/bin/sh", "-c", "ls | grep Awesome")`,
Since: "2017.1",
},
Available since
2017.1
`
var docSA1006 = `Printf with dynamic first argument and no further arguments
Using fmt.Printf with a dynamic first argument can lead to unexpected
"SA1006": &lint.Documentation{
Title: `Printf with dynamic first argument and no further arguments`,
Text: `Using fmt.Printf with a dynamic first argument can lead to unexpected
output. The first argument is a format string, where certain character
combinations have special meaning. If, for example, a user were to
enter a string such as
@ -86,335 +80,325 @@ enter a string such as
and you printed it with
fmt.Printf(s)
fmt.Printf(s)
it would lead to the following output:
Interest rate: 5%!(NOVERB).
Interest rate: 5%!(NOVERB).
Similarly, forming the first parameter via string concatenation with
user input should be avoided for the same reason. When printing user
input, either use a variant of fmt.Print, or use the %s Printf verb
and pass the string as an argument.
and pass the string as an argument.`,
Since: "2017.1",
},
Available since
2017.1
`
"SA1007": &lint.Documentation{
Title: `Invalid URL in net/url.Parse`,
Since: "2017.1",
},
var docSA1007 = `Invalid URL in net/url.Parse
"SA1008": &lint.Documentation{
Title: `Non-canonical key in http.Header map`,
Text: `Keys in http.Header maps are canonical, meaning they follow a specific
combination of uppercase and lowercase letters. Methods such as
http.Header.Add and http.Header.Del convert inputs into this canonical
form before manipulating the map.
Available since
2017.1
`
When manipulating http.Header maps directly, as opposed to using the
provided methods, care should be taken to stick to canonical form in
order to avoid inconsistencies. The following piece of code
demonstrates one such inconsistency:
var docSA1008 = `Non-canonical key in http.Header map
h := http.Header{}
h["etag"] = []string{"1234"}
h.Add("etag", "5678")
fmt.Println(h)
Available since
2017.1
`
// Output:
// map[Etag:[5678] etag:[1234]]
var docSA1010 = `(*regexp.Regexp).FindAll called with n == 0, which will always return zero results
The easiest way of obtaining the canonical form of a key is to use
http.CanonicalHeaderKey.`,
Since: "2017.1",
},
If n >= 0, the function returns at most n matches/submatches. To
return all results, specify a negative number.
"SA1010": &lint.Documentation{
Title: `(*regexp.Regexp).FindAll called with n == 0, which will always return zero results`,
Text: `If n >= 0, the function returns at most n matches/submatches. To
return all results, specify a negative number.`,
Since: "2017.1",
},
Available since
2017.1
`
"SA1011": &lint.Documentation{
Title: `Various methods in the strings package expect valid UTF-8, but invalid input is provided`,
Since: "2017.1",
},
var docSA1011 = `Various methods in the strings package expect valid UTF-8, but invalid input is provided
"SA1012": &lint.Documentation{
Title: `A nil context.Context is being passed to a function, consider using context.TODO instead`,
Since: "2017.1",
},
Available since
2017.1
`
"SA1013": &lint.Documentation{
Title: `io.Seeker.Seek is being called with the whence constant as the first argument, but it should be the second`,
Since: "2017.1",
},
var docSA1012 = `A nil context.Context is being passed to a function, consider using context.TODO instead
"SA1014": &lint.Documentation{
Title: `Non-pointer value passed to Unmarshal or Decode`,
Since: "2017.1",
},
Available since
2017.1
`
"SA1015": &lint.Documentation{
Title: `Using time.Tick in a way that will leak. Consider using time.NewTicker, and only use time.Tick in tests, commands and endless functions`,
Since: "2017.1",
},
var docSA1013 = `io.Seeker.Seek is being called with the whence constant as the first argument, but it should be the second
Available since
2017.1
`
var docSA1014 = `Non-pointer value passed to Unmarshal or Decode
Available since
2017.1
`
var docSA1015 = `Using time.Tick in a way that will leak. Consider using time.NewTicker, and only use time.Tick in tests, commands and endless functions
Available since
2017.1
`
var docSA1016 = `Trapping a signal that cannot be trapped
Not all signals can be intercepted by a process. Speficially, on
"SA1016": &lint.Documentation{
Title: `Trapping a signal that cannot be trapped`,
Text: `Not all signals can be intercepted by a process. Speficially, on
UNIX-like systems, the syscall.SIGKILL and syscall.SIGSTOP signals are
never passed to the process, but instead handled directly by the
kernel. It is therefore pointless to try and handle these signals.
kernel. It is therefore pointless to try and handle these signals.`,
Since: "2017.1",
},
Available since
2017.1
`
var docSA1017 = `Channels used with os/signal.Notify should be buffered
The os/signal package uses non-blocking channel sends when delivering
"SA1017": &lint.Documentation{
Title: `Channels used with os/signal.Notify should be buffered`,
Text: `The os/signal package uses non-blocking channel sends when delivering
signals. If the receiving end of the channel isn't ready and the
channel is either unbuffered or full, the signal will be dropped. To
avoid missing signals, the channel should be buffered and of the
appropriate size. For a channel used for notification of just one
signal value, a buffer of size 1 is sufficient.
signal value, a buffer of size 1 is sufficient.`,
Since: "2017.1",
},
"SA1018": &lint.Documentation{
Title: `strings.Replace called with n == 0, which does nothing`,
Text: `With n == 0, zero instances will be replaced. To replace all
instances, use a negative number, or use strings.ReplaceAll.`,
Since: "2017.1",
},
Available since
2017.1
`
"SA1019": &lint.Documentation{
Title: `Using a deprecated function, variable, constant or field`,
Since: "2017.1",
},
var docSA1018 = `strings.Replace called with n == 0, which does nothing
"SA1020": &lint.Documentation{
Title: `Using an invalid host:port pair with a net.Listen-related function`,
Since: "2017.1",
},
With n == 0, zero instances will be replaced. To replace all
instances, use a negative number, or use strings.ReplaceAll.
Available since
2017.1
`
var docSA1019 = `Using a deprecated function, variable, constant or field
Available since
2017.1
`
var docSA1020 = `Using an invalid host:port pair with a net.Listen-related function
Available since
2017.1
`
var docSA1021 = `Using bytes.Equal to compare two net.IP
A net.IP stores an IPv4 or IPv6 address as a slice of bytes. The
"SA1021": &lint.Documentation{
Title: `Using bytes.Equal to compare two net.IP`,
Text: `A net.IP stores an IPv4 or IPv6 address as a slice of bytes. The
length of the slice for an IPv4 address, however, can be either 4 or
16 bytes long, using different ways of representing IPv4 addresses. In
order to correctly compare two net.IPs, the net.IP.Equal method should
be used, as it takes both representations into account.
be used, as it takes both representations into account.`,
Since: "2017.1",
},
Available since
2017.1
`
"SA1023": &lint.Documentation{
Title: `Modifying the buffer in an io.Writer implementation`,
Text: `Write must not modify the slice data, even temporarily.`,
Since: "2017.1",
},
var docSA1023 = `Modifying the buffer in an io.Writer implementation
"SA1024": &lint.Documentation{
Title: `A string cutset contains duplicate characters`,
Text: `The strings.TrimLeft and strings.TrimRight functions take cutsets, not
prefixes. A cutset is treated as a set of characters to remove from a
string. For example,
Write must not modify the slice data, even temporarily.
strings.TrimLeft("42133word", "1234"))
Available since
2017.1
`
will result in the string "word" any characters that are 1, 2, 3 or
4 are cut from the left of the string.
var docSA1024 = `A string cutset contains duplicate characters, suggesting TrimPrefix or TrimSuffix should be used instead of TrimLeft or TrimRight
In order to remove one string from another, use strings.TrimPrefix instead.`,
Since: "2017.1",
},
Available since
2017.1
`
"SA1025": &lint.Documentation{
Title: `It is not possible to use (*time.Timer).Reset's return value correctly`,
Since: "2019.1",
},
var docSA1025 = `It is not possible to use Reset's return value correctly
"SA1026": &lint.Documentation{
Title: `Cannot marshal channels or functions`,
Since: "2019.2",
},
Available since
2019.1
`
var docSA1026 = `Cannot marshal channels or functions
Available since
Unreleased
`
var docSA1027 = `Atomic access to 64-bit variable must be 64-bit aligned
On ARM, x86-32, and 32-bit MIPS, it is the caller's responsibility to
"SA1027": &lint.Documentation{
Title: `Atomic access to 64-bit variable must be 64-bit aligned`,
Text: `On ARM, x86-32, and 32-bit MIPS, it is the caller's responsibility to
arrange for 64-bit alignment of 64-bit words accessed atomically. The
first word in a variable or in an allocated struct, array, or slice
can be relied upon to be 64-bit aligned.
You can use the structlayout tool to inspect the alignment of fields
in a struct.
in a struct.`,
Since: "2019.2",
},
Available since
Unreleased
`
"SA2000": &lint.Documentation{
Title: `sync.WaitGroup.Add called inside the goroutine, leading to a race condition`,
Since: "2017.1",
},
var docSA2000 = `sync.WaitGroup.Add called inside the goroutine, leading to a race condition
"SA2001": &lint.Documentation{
Title: `Empty critical section, did you mean to defer the unlock?`,
Text: `Empty critical sections of the kind
Available since
2017.1
`
mu.Lock()
mu.Unlock()
var docSA2001 = `Empty critical section, did you mean to defer the unlock?
are very often a typo, and the following was intended instead:
Available since
2017.1
`
mu.Lock()
defer mu.Unlock()
var docSA2002 = `Called testing.T.FailNow or SkipNow in a goroutine, which isn't allowed
Do note that sometimes empty critical sections can be useful, as a
form of signaling to wait on another goroutine. Many times, there are
simpler ways of achieving the same effect. When that isn't the case,
the code should be amply commented to avoid confusion. Combining such
comments with a //lint:ignore directive can be used to suppress this
rare false positive.`,
Since: "2017.1",
},
Available since
2017.1
`
"SA2002": &lint.Documentation{
Title: `Called testing.T.FailNow or SkipNow in a goroutine, which isn't allowed`,
Since: "2017.1",
},
var docSA2003 = `Deferred Lock right after locking, likely meant to defer Unlock instead
"SA2003": &lint.Documentation{
Title: `Deferred Lock right after locking, likely meant to defer Unlock instead`,
Since: "2017.1",
},
Available since
2017.1
`
var docSA3000 = `TestMain doesn't call os.Exit, hiding test failures
Test executables (and in turn 'go test') exit with a non-zero status
"SA3000": &lint.Documentation{
Title: `TestMain doesn't call os.Exit, hiding test failures`,
Text: `Test executables (and in turn 'go test') exit with a non-zero status
code if any tests failed. When specifying your own TestMain function,
it is your responsibility to arrange for this, by calling os.Exit with
the correct code. The correct code is returned by (*testing.M).Run, so
the usual way of implementing TestMain is to end it with
os.Exit(m.Run()).
os.Exit(m.Run()).`,
Since: "2017.1",
},
Available since
2017.1
`
var docSA3001 = `Assigning to b.N in benchmarks distorts the results
The testing package dynamically sets b.N to improve the reliability of
"SA3001": &lint.Documentation{
Title: `Assigning to b.N in benchmarks distorts the results`,
Text: `The testing package dynamically sets b.N to improve the reliability of
benchmarks and uses it in computations to determine the duration of a
single operation. Benchmark code must not alter b.N as this would
falsify results.
falsify results.`,
Since: "2017.1",
},
Available since
2017.1
`
"SA4000": &lint.Documentation{
Title: `Boolean expression has identical expressions on both sides`,
Since: "2017.1",
},
var docSA4000 = `Boolean expression has identical expressions on both sides
"SA4001": &lint.Documentation{
Title: `&*x gets simplified to x, it does not copy x`,
Since: "2017.1",
},
Available since
2017.1
`
"SA4002": &lint.Documentation{
Title: `Comparing strings with known different sizes has predictable results`,
Since: "2017.1",
},
var docSA4001 = `&*x gets simplified to x, it does not copy x
"SA4003": &lint.Documentation{
Title: `Comparing unsigned values against negative values is pointless`,
Since: "2017.1",
},
Available since
2017.1
`
"SA4004": &lint.Documentation{
Title: `The loop exits unconditionally after one iteration`,
Since: "2017.1",
},
var docSA4002 = `Comparing strings with known different sizes has predictable results
"SA4005": &lint.Documentation{
Title: `Field assignment that will never be observed. Did you mean to use a pointer receiver?`,
Since: "2017.1",
},
Available since
2017.1
`
"SA4006": &lint.Documentation{
Title: `A value assigned to a variable is never read before being overwritten. Forgotten error check or dead code?`,
Since: "2017.1",
},
var docSA4003 = `Comparing unsigned values against negative values is pointless
"SA4008": &lint.Documentation{
Title: `The variable in the loop condition never changes, are you incrementing the wrong variable?`,
Since: "2017.1",
},
Available since
2017.1
`
"SA4009": &lint.Documentation{
Title: `A function argument is overwritten before its first use`,
Since: "2017.1",
},
var docSA4004 = `The loop exits unconditionally after one iteration
"SA4010": &lint.Documentation{
Title: `The result of append will never be observed anywhere`,
Since: "2017.1",
},
Available since
2017.1
`
"SA4011": &lint.Documentation{
Title: `Break statement with no effect. Did you mean to break out of an outer loop?`,
Since: "2017.1",
},
var docSA4005 = `Field assignment that will never be observed. Did you mean to use a pointer receiver?
"SA4012": &lint.Documentation{
Title: `Comparing a value against NaN even though no value is equal to NaN`,
Since: "2017.1",
},
Available since
2017.1
`
"SA4013": &lint.Documentation{
Title: `Negating a boolean twice (!!b) is the same as writing b. This is either redundant, or a typo.`,
Since: "2017.1",
},
var docSA4006 = `A value assigned to a variable is never read before being overwritten. Forgotten error check or dead code?
"SA4014": &lint.Documentation{
Title: `An if/else if chain has repeated conditions and no side-effects; if the condition didn't match the first time, it won't match the second time, either`,
Since: "2017.1",
},
Available since
2017.1
`
"SA4015": &lint.Documentation{
Title: `Calling functions like math.Ceil on floats converted from integers doesn't do anything useful`,
Since: "2017.1",
},
var docSA4008 = `The variable in the loop condition never changes, are you incrementing the wrong variable?
"SA4016": &lint.Documentation{
Title: `Certain bitwise operations, such as x ^ 0, do not do anything useful`,
Since: "2017.1",
},
Available since
2017.1
`
"SA4017": &lint.Documentation{
Title: `A pure function's return value is discarded, making the call pointless`,
Since: "2017.1",
},
var docSA4009 = `A function argument is overwritten before its first use
"SA4018": &lint.Documentation{
Title: `Self-assignment of variables`,
Since: "2017.1",
},
Available since
2017.1
`
"SA4019": &lint.Documentation{
Title: `Multiple, identical build constraints in the same file`,
Since: "2017.1",
},
var docSA4010 = `The result of append will never be observed anywhere
Available since
2017.1
`
var docSA4011 = `Break statement with no effect. Did you mean to break out of an outer loop?
Available since
2017.1
`
var docSA4012 = `Comparing a value against NaN even though no value is equal to NaN
Available since
2017.1
`
var docSA4013 = `Negating a boolean twice (!!b) is the same as writing b. This is either redundant, or a typo.
Available since
2017.1
`
var docSA4014 = `An if/else if chain has repeated conditions and no side-effects; if the condition didn't match the first time, it won't match the second time, either
Available since
2017.1
`
var docSA4015 = `Calling functions like math.Ceil on floats converted from integers doesn't do anything useful
Available since
2017.1
`
var docSA4016 = `Certain bitwise operations, such as x ^ 0, do not do anything useful
Available since
2017.1
`
var docSA4017 = `A pure function's return value is discarded, making the call pointless
Available since
2017.1
`
var docSA4018 = `Self-assignment of variables
Available since
2017.1
`
var docSA4019 = `Multiple, identical build constraints in the same file
Available since
2017.1
`
var docSA4020 = `Unreachable case clause in a type switch
In a type switch like the following
"SA4020": &lint.Documentation{
Title: `Unreachable case clause in a type switch`,
Text: `In a type switch like the following
type T struct{}
func (T) Read(b []byte) (int, error) { return 0, nil }
@ -449,7 +433,7 @@ Another example:
Even though T has a Close method and thus implements io.ReadCloser,
io.Reader will always match first. The method set of io.Reader is a
subset of io.ReadCloser. Thus it is impossible to match the second
case without mtching the first case.
case without matching the first case.
Structurally equivalent interfaces
@ -479,55 +463,46 @@ the following type switch will have an unreachable case clause:
}
T will always match before V because they are structurally equivalent
and therefore doSomething()'s return value implements both.
and therefore doSomething()'s return value implements both.`,
Since: "2019.2",
},
Available since
Unreleased
`
"SA4021": &lint.Documentation{
Title: `x = append(y) is equivalent to x = y`,
Since: "2019.2",
},
var docSA4021 = `x = append(y) is equivalent to x = y
"SA5000": &lint.Documentation{
Title: `Assignment to nil map`,
Since: "2017.1",
},
Available since
Unreleased
`
"SA5001": &lint.Documentation{
Title: `Defering Close before checking for a possible error`,
Since: "2017.1",
},
var docSA5000 = `Assignment to nil map
"SA5002": &lint.Documentation{
Title: `The empty for loop (for {}) spins and can block the scheduler`,
Since: "2017.1",
},
Available since
2017.1
`
var docSA5001 = `Defering Close before checking for a possible error
Available since
2017.1
`
var docSA5002 = `The empty for loop (for {}) spins and can block the scheduler
Available since
2017.1
`
var docSA5003 = `Defers in infinite loops will never execute
Defers are scoped to the surrounding function, not the surrounding
"SA5003": &lint.Documentation{
Title: `Defers in infinite loops will never execute`,
Text: `Defers are scoped to the surrounding function, not the surrounding
block. In a function that never returns, i.e. one containing an
infinite loop, defers will never execute.
infinite loop, defers will never execute.`,
Since: "2017.1",
},
Available since
2017.1
`
"SA5004": &lint.Documentation{
Title: `for { select { ... with an empty default branch spins`,
Since: "2017.1",
},
var docSA5004 = `for { select { ... with an empty default branch spins
Available since
2017.1
`
var docSA5005 = `The finalizer references the finalized object, preventing garbage collection
A finalizer is a function associated with an object that runs when the
"SA5005": &lint.Documentation{
Title: `The finalizer references the finalized object, preventing garbage collection`,
Text: `A finalizer is a function associated with an object that runs when the
garbage collector is ready to collect said object, that is when the
object is no longer referenced by anything.
@ -537,21 +512,18 @@ collector from collecting the object. The finalizer will never run,
and the object will never be collected, leading to a memory leak. That
is why the finalizer should instead use its first argument to operate
on the object. That way, the number of references can temporarily go
to zero before the object is being passed to the finalizer.
to zero before the object is being passed to the finalizer.`,
Since: "2017.1",
},
Available since
2017.1
`
"SA5006": &lint.Documentation{
Title: `Slice index out of bounds`,
Since: "2017.1",
},
var docSA5006 = `Slice index out of bounds
Available since
2017.1
`
var docSA5007 = `Infinite recursive call
A function that calls itself recursively needs to have an exit
"SA5007": &lint.Documentation{
Title: `Infinite recursive call`,
Text: `A function that calls itself recursively needs to have an exit
condition. Otherwise it will recurse forever, until the system runs
out of memory.
@ -559,21 +531,29 @@ This issue can be caused by simple bugs such as forgetting to add an
exit condition. It can also happen "on purpose". Some languages have
tail call optimization which makes certain infinite recursive calls
safe to use. Go, however, does not implement TCO, and as such a loop
should be used instead.
should be used instead.`,
Since: "2017.1",
},
Available since
2017.1
`
"SA5008": &lint.Documentation{
Title: `Invalid struct tag`,
Since: "2019.2",
},
var docSA6000 = `Using regexp.Match or related in a loop, should use regexp.Compile
"SA5009": &lint.Documentation{
Title: `Invalid Printf call`,
Since: "2019.2",
},
Available since
2017.1
`
"SA6000": &lint.Documentation{
Title: `Using regexp.Match or related in a loop, should use regexp.Compile`,
Since: "2017.1",
},
var docSA6001 = `Missing an optimization opportunity when indexing maps by byte slices
"SA6001": &lint.Documentation{
Title: `Missing an optimization opportunity when indexing maps by byte slices`,
Map keys must be comparable, which precludes the use of byte slices.
Text: `Map keys must be comparable, which precludes the use of byte slices.
This usually leads to using string keys and converting byte slices to
strings.
@ -596,15 +576,13 @@ because the first version needs to copy and allocate, while the second
one does not.
For some history on this optimization, check out commit
f5f5a8b6209f84961687d993b93ea0d397f5d5bf in the Go repository.
f5f5a8b6209f84961687d993b93ea0d397f5d5bf in the Go repository.`,
Since: "2017.1",
},
Available since
2017.1
`
var docSA6002 = `Storing non-pointer values in sync.Pool allocates memory
A sync.Pool is used to avoid unnecessary allocations and reduce the
"SA6002": &lint.Documentation{
Title: `Storing non-pointer values in sync.Pool allocates memory`,
Text: `A sync.Pool is used to avoid unnecessary allocations and reduce the
amount of work the garbage collector has to do.
When passing a value that is not a pointer to a function that accepts
@ -615,15 +593,13 @@ an array). In order to avoid the extra allocation, one should store a
pointer to the slice instead.
See the comments on https://go-review.googlesource.com/c/go/+/24371
that discuss this problem.
that discuss this problem.`,
Since: "2017.1",
},
Available since
2017.1
`
var docSA6003 = `Converting a string to a slice of runes before ranging over it
You may want to loop over the runes in a string. Instead of converting
"SA6003": &lint.Documentation{
Title: `Converting a string to a slice of runes before ranging over it`,
Text: `You may want to loop over the runes in a string. Instead of converting
the string to a slice of runes and looping over that, you can loop
over the string itself. That is,
@ -639,15 +615,13 @@ and avoid unnecessary memory allocations.
Do note that if you are interested in the indices, ranging over a
string and over a slice of runes will yield different indices. The
first one yields byte offsets, while the second one yields indices in
the slice of runes.
the slice of runes.`,
Since: "2017.1",
},
Available since
2017.1
`
var docSA6005 = `Inefficient string comparison with strings.ToLower or strings.ToUpper
Converting two strings to the same case and comparing them like so
"SA6005": &lint.Documentation{
Title: `Inefficient string comparison with strings.ToLower or strings.ToUpper`,
Text: `Converting two strings to the same case and comparing them like so
if strings.ToLower(s1) == strings.ToLower(s2) {
...
@ -665,33 +639,29 @@ strings and can return as soon as the first non-matching character has
been found.
For a more in-depth explanation of this issue, see
https://blog.digitalocean.com/how-to-efficiently-compare-strings-in-go/
https://blog.digitalocean.com/how-to-efficiently-compare-strings-in-go/`,
Since: "2019.2",
},
Available since
Unreleased
`
"SA9001": &lint.Documentation{
Title: `Defers in range loops may not run when you expect them to`,
Since: "2017.1",
},
var docSA9001 = `Defers in 'for range' loops may not run when you expect them to
"SA9002": &lint.Documentation{
Title: `Using a non-octal os.FileMode that looks like it was meant to be in octal.`,
Since: "2017.1",
},
Available since
2017.1
`
"SA9003": &lint.Documentation{
Title: `Empty body in an if or else branch`,
Since: "2017.1",
},
var docSA9002 = `Using a non-octal os.FileMode that looks like it was meant to be in octal.
"SA9004": &lint.Documentation{
Title: `Only the first constant has an explicit type`,
Available since
2017.1
`
var docSA9003 = `Empty body in an if or else branch
Available since
2017.1
`
var docSA9004 = `Only the first constant has an explicit type
In a constant declaration such as the following:
Text: `In a constant declaration such as the following:
const (
First byte = 1
@ -727,7 +697,7 @@ Wrong type in variable declarations
The most obvious issue with such incorrect enumerations expresses
itself as a compile error:
package pkg
package pkg
const (
EnumFirst uint8 = 1
@ -776,22 +746,19 @@ This code will output
an enum
2
as EnumSecond has no explicit type, and thus defaults to int.
as EnumSecond has no explicit type, and thus defaults to int.`,
Since: "2019.1",
},
Available since
2019.1
`
var docSA9005 = `Trying to marshal a struct with no public fields nor custom marshaling
The encoding/json and encoding/xml packages only operate on exported
"SA9005": &lint.Documentation{
Title: `Trying to marshal a struct with no public fields nor custom marshaling`,
Text: `The encoding/json and encoding/xml packages only operate on exported
fields in structs, not unexported ones. It is usually an error to try
to (un)marshal structs that only consist of unexported fields.
This check will not flag calls involving types that define custom
marshaling behavior, e.g. via MarshalJSON methods. It will also not
flag empty structs.
Available since
Unreleased
`
flag empty structs.`,
Since: "2019.2",
},
}

View File

@ -0,0 +1,25 @@
package staticcheck
import (
"reflect"
"golang.org/x/tools/go/analysis"
"honnef.co/go/tools/internal/passes/buildssa"
"honnef.co/go/tools/ssa"
"honnef.co/go/tools/staticcheck/vrp"
)
var valueRangesAnalyzer = &analysis.Analyzer{
Name: "vrp",
Doc: "calculate value ranges of functions",
Run: func(pass *analysis.Pass) (interface{}, error) {
m := map[*ssa.Function]vrp.Ranges{}
for _, ssafn := range pass.ResultOf[buildssa.Analyzer].(*buildssa.SSA).SrcFuncs {
vr := vrp.BuildGraph(ssafn).Solve()
m[ssafn] = vr
}
return m, nil
},
Requires: []*analysis.Analyzer{buildssa.Analyzer},
ResultType: reflect.TypeOf(map[*ssa.Function]vrp.Ranges{}),
}

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,7 @@ import (
"time"
"unicode/utf8"
"honnef.co/go/tools/lint"
"golang.org/x/tools/go/analysis"
. "honnef.co/go/tools/lint/lintdsl"
"honnef.co/go/tools/ssa"
"honnef.co/go/tools/staticcheck/vrp"
@ -26,12 +26,11 @@ const (
)
type Call struct {
Job *lint.Job
Pass *analysis.Pass
Instr ssa.CallInstruction
Args []*Argument
Checker *Checker
Parent *ssa.Function
Parent *ssa.Function
invalids []string
}
@ -184,7 +183,7 @@ func ConvertedFromInt(v Value) bool {
return true
}
func validEncodingBinaryType(j *lint.Job, typ types.Type) bool {
func validEncodingBinaryType(pass *analysis.Pass, typ types.Type) bool {
typ = typ.Underlying()
switch typ := typ.(type) {
case *types.Basic:
@ -194,19 +193,19 @@ func validEncodingBinaryType(j *lint.Job, typ types.Type) bool {
types.Float32, types.Float64, types.Complex64, types.Complex128, types.Invalid:
return true
case types.Bool:
return IsGoVersion(j, 8)
return IsGoVersion(pass, 8)
}
return false
case *types.Struct:
n := typ.NumFields()
for i := 0; i < n; i++ {
if !validEncodingBinaryType(j, typ.Field(i).Type()) {
if !validEncodingBinaryType(pass, typ.Field(i).Type()) {
return false
}
}
return true
case *types.Array:
return validEncodingBinaryType(j, typ.Elem())
return validEncodingBinaryType(pass, typ.Elem())
case *types.Interface:
// we can't determine if it's a valid type or not
return true
@ -214,7 +213,7 @@ func validEncodingBinaryType(j *lint.Job, typ types.Type) bool {
return false
}
func CanBinaryMarshal(j *lint.Job, v Value) bool {
func CanBinaryMarshal(pass *analysis.Pass, v Value) bool {
typ := v.Value.Type().Underlying()
if ttyp, ok := typ.(*types.Pointer); ok {
typ = ttyp.Elem().Underlying()
@ -227,7 +226,7 @@ func CanBinaryMarshal(j *lint.Job, v Value) bool {
}
}
return validEncodingBinaryType(j, typ)
return validEncodingBinaryType(pass, typ)
}
func RepeatZeroTimes(name string, arg int) CallCheck {

View File

@ -722,16 +722,22 @@ func (g *Graph) widen(c Constraint, consts []Z) bool {
}
nlc := NInfinity
nuc := PInfinity
for _, co := range consts {
if co.Cmp(ni.Lower) <= 0 {
nlc = co
break
// Don't get stuck widening for an absurd amount of time due
// to an excess number of constants, as may be present in
// table-based scanners.
if len(consts) < 1000 {
for _, co := range consts {
if co.Cmp(ni.Lower) <= 0 {
nlc = co
break
}
}
}
for _, co := range consts {
if co.Cmp(ni.Upper) >= 0 {
nuc = co
break
for _, co := range consts {
if co.Cmp(ni.Upper) >= 0 {
nuc = co
break
}
}
}