package staticcheck
import "honnef.co/go/tools/staticcheck"
Package staticcheck contains analyzes that find bugs and performance issues. Barring the rare false positive, any code flagged by these analyzes needs to be fixed.
Index ¶
- Constants
- Variables
- func CanBinaryMarshal(pass *analysis.Pass, v Value) bool
- func CheckAddressIsNil(pass *analysis.Pass) (interface{}, error)
- func CheckAllocationNilCheck(pass *analysis.Pass) (interface{}, error)
- func CheckArgOverwritten(pass *analysis.Pass) (interface{}, error)
- func CheckBadRemoveAll(pass *analysis.Pass) (interface{}, error)
- func CheckBenchmarkN(pass *analysis.Pass) (interface{}, error)
- func CheckBuiltinZeroComparison(pass *analysis.Pass) (interface{}, error)
- func CheckCanonicalHeaderKey(pass *analysis.Pass) (interface{}, error)
- func CheckConcurrentTesting(pass *analysis.Pass) (interface{}, error)
- func CheckCyclicFinalizer(pass *analysis.Pass) (interface{}, error)
- func CheckDeferInInfiniteLoop(pass *analysis.Pass) (interface{}, error)
- func CheckDeferLock(pass *analysis.Pass) (interface{}, error)
- func CheckDeprecated(pass *analysis.Pass) (interface{}, error)
- func CheckDoubleNegation(pass *analysis.Pass) (interface{}, error)
- func CheckDubiousDeferInChannelRangeLoop(pass *analysis.Pass) (interface{}, error)
- func CheckDuplicateBuildConstraints(pass *analysis.Pass) (interface{}, error)
- func CheckEarlyDefer(pass *analysis.Pass) (interface{}, error)
- func CheckEmptyBranch(pass *analysis.Pass) (interface{}, error)
- func CheckEmptyCriticalSection(pass *analysis.Pass) (interface{}, error)
- func CheckEvenSliceLength(pass *analysis.Pass) (interface{}, error)
- func CheckExec(pass *analysis.Pass) (interface{}, error)
- func CheckExtremeComparison(pass *analysis.Pass) (interface{}, error)
- func CheckImpossibleTypeAssertion(pass *analysis.Pass) (interface{}, error)
- func CheckIneffectiveAppend(pass *analysis.Pass) (interface{}, error)
- func CheckIneffectiveCopy(pass *analysis.Pass) (interface{}, error)
- func CheckIneffectiveFieldAssignments(pass *analysis.Pass) (interface{}, error)
- func CheckIneffectiveLoop(pass *analysis.Pass) (interface{}, error)
- func CheckIneffectiveRandInt(pass *analysis.Pass) (interface{}, error)
- func CheckIneffectiveSort(pass *analysis.Pass) (interface{}, error)
- func CheckIneffectiveURLQueryModification(pass *analysis.Pass) (interface{}, error)
- func CheckInfiniteEmptyLoop(pass *analysis.Pass) (interface{}, error)
- func CheckInfiniteRecursion(pass *analysis.Pass) (interface{}, error)
- func CheckIntegerDivisionEqualsZero(pass *analysis.Pass) (interface{}, error)
- func CheckLeakyTimeTick(pass *analysis.Pass) (interface{}, error)
- func CheckLhsRhsIdentical(pass *analysis.Pass) (interface{}, error)
- func CheckLoopCondition(pass *analysis.Pass) (interface{}, error)
- func CheckLoopEmptyDefault(pass *analysis.Pass) (interface{}, error)
- func CheckMapBytesKey(pass *analysis.Pass) (interface{}, error)
- func CheckMaybeNil(pass *analysis.Pass) (interface{}, error)
- func CheckMissingEnumTypesInDeclaration(pass *analysis.Pass) (interface{}, error)
- func CheckModuloOne(pass *analysis.Pass) (interface{}, error)
- func CheckNaNComparison(pass *analysis.Pass) (interface{}, error)
- func CheckNegativeZeroFloat(pass *analysis.Pass) (interface{}, error)
- func CheckNilContext(pass *analysis.Pass) (interface{}, error)
- func CheckNilMaps(pass *analysis.Pass) (interface{}, error)
- func CheckNonOctalFileMode(pass *analysis.Pass) (interface{}, error)
- func CheckPredeterminedBooleanExprs(pass *analysis.Pass) (interface{}, error)
- func CheckRangeStringRunes(pass *analysis.Pass) (interface{}, error)
- func CheckRepeatedIfElse(pass *analysis.Pass) (interface{}, error)
- func CheckScopedBreak(pass *analysis.Pass) (interface{}, error)
- func CheckSeeker(pass *analysis.Pass) (interface{}, error)
- func CheckSelfAssignment(pass *analysis.Pass) (interface{}, error)
- func CheckSideEffectFreeCalls(pass *analysis.Pass) (interface{}, error)
- func CheckSillyBitwiseOps(pass *analysis.Pass) (interface{}, error)
- func CheckSillyRegexp(pass *analysis.Pass) (interface{}, error)
- func CheckSingleArgAppend(pass *analysis.Pass) (interface{}, error)
- func CheckStaticBitShift(pass *analysis.Pass) (interface{}, error)
- func CheckStructTags(pass *analysis.Pass) (interface{}, error)
- func CheckTemplate(pass *analysis.Pass) (interface{}, error)
- func CheckTestMainExit(pass *analysis.Pass) (interface{}, error)
- func CheckTimeSleepConstant(pass *analysis.Pass) (interface{}, error)
- func CheckTimerResetReturnValue(pass *analysis.Pass) (interface{}, error)
- func CheckToLowerToUpperComparison(pass *analysis.Pass) (interface{}, error)
- func CheckTypeAssertionShadowingElse(pass *analysis.Pass) (interface{}, error)
- func CheckTypedNilInterface(pass *analysis.Pass) (interface{}, error)
- func CheckUnreachableTypeCases(pass *analysis.Pass) (interface{}, error)
- func CheckUnreadVariableValues(pass *analysis.Pass) (interface{}, error)
- func CheckUnsafePrintf(pass *analysis.Pass) (interface{}, error)
- func CheckUntrappableSignal(pass *analysis.Pass) (interface{}, error)
- func CheckWaitgroupAdd(pass *analysis.Pass) (interface{}, error)
- func CheckWriterBufferModified(pass *analysis.Pass) (interface{}, error)
- func ConvertedFrom(v Value, typ string) bool
- func ConvertedFromInt(v Value) bool
- func InvalidUTF8(v Value) bool
- func Pointer(v Value) bool
- func UnbufferedChannel(v Value) bool
- func UniqueStringCutset(v Value) bool
- func ValidHostPort(v Value) bool
- func ValidateRegexp(v Value) error
- func ValidateTimeLayout(v Value) error
- func ValidateURL(v Value) error
- type Argument
- type Call
- type CallCheck
- type Value
Constants ¶
const ( MsgInvalidHostPort = "invalid port or service name in host:port pair" MsgInvalidUTF8 = "argument is not a valid UTF-8 encoded string" MsgNonUniqueCutset = "cutset contains duplicate characters" )
Variables ¶
var Analyzers = lint.InitializeAnalyzers(Docs, map[string]*analysis.Analyzer{ "SA1000": makeCallCheckerAnalyzer(checkRegexpRules), "SA1001": { Run: CheckTemplate, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA1002": makeCallCheckerAnalyzer(checkTimeParseRules), "SA1003": makeCallCheckerAnalyzer(checkEncodingBinaryRules), "SA1004": { Run: CheckTimeSleepConstant, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA1005": { Run: CheckExec, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA1006": { Run: CheckUnsafePrintf, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA1007": makeCallCheckerAnalyzer(checkURLsRules), "SA1008": { Run: CheckCanonicalHeaderKey, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA1010": makeCallCheckerAnalyzer(checkRegexpFindAllRules), "SA1011": makeCallCheckerAnalyzer(checkUTF8CutsetRules), "SA1012": { Run: CheckNilContext, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA1013": { Run: CheckSeeker, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA1014": makeCallCheckerAnalyzer(checkUnmarshalPointerRules), "SA1015": { Run: CheckLeakyTimeTick, Requires: []*analysis.Analyzer{buildir.Analyzer}, }, "SA1016": { Run: CheckUntrappableSignal, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA1017": makeCallCheckerAnalyzer(checkUnbufferedSignalChanRules), "SA1018": makeCallCheckerAnalyzer(checkStringsReplaceZeroRules), "SA1019": { Run: CheckDeprecated, Requires: []*analysis.Analyzer{inspect.Analyzer, deprecated.Analyzer, generated.Analyzer}, }, "SA1020": makeCallCheckerAnalyzer(checkListenAddressRules), "SA1021": makeCallCheckerAnalyzer(checkBytesEqualIPRules), "SA1023": { Run: CheckWriterBufferModified, Requires: []*analysis.Analyzer{buildir.Analyzer}, }, "SA1024": makeCallCheckerAnalyzer(checkUniqueCutsetRules), "SA1025": { Run: CheckTimerResetReturnValue, Requires: []*analysis.Analyzer{buildir.Analyzer}, }, "SA1026": makeCallCheckerAnalyzer(checkUnsupportedMarshal), "SA1027": makeCallCheckerAnalyzer(checkAtomicAlignment), "SA1028": makeCallCheckerAnalyzer(checkSortSliceRules), "SA1029": makeCallCheckerAnalyzer(checkWithValueKeyRules), "SA1030": makeCallCheckerAnalyzer(checkStrconvRules), "SA2000": { Run: CheckWaitgroupAdd, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA2001": { Run: CheckEmptyCriticalSection, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA2002": { Run: CheckConcurrentTesting, Requires: []*analysis.Analyzer{buildir.Analyzer}, }, "SA2003": { Run: CheckDeferLock, Requires: []*analysis.Analyzer{buildir.Analyzer}, }, "SA3000": { Run: CheckTestMainExit, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA3001": { Run: CheckBenchmarkN, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA4000": { Run: CheckLhsRhsIdentical, Requires: []*analysis.Analyzer{inspect.Analyzer, tokenfile.Analyzer, generated.Analyzer}, }, "SA4001": { Run: CheckIneffectiveCopy, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA4003": { Run: CheckExtremeComparison, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA4004": { Run: CheckIneffectiveLoop, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA4005": { Run: CheckIneffectiveFieldAssignments, Requires: []*analysis.Analyzer{buildir.Analyzer}, }, "SA4006": { Run: CheckUnreadVariableValues, Requires: []*analysis.Analyzer{buildir.Analyzer, generated.Analyzer}, }, "SA4008": { Run: CheckLoopCondition, Requires: []*analysis.Analyzer{buildir.Analyzer}, }, "SA4009": { Run: CheckArgOverwritten, Requires: []*analysis.Analyzer{buildir.Analyzer}, }, "SA4010": { Run: CheckIneffectiveAppend, Requires: []*analysis.Analyzer{buildir.Analyzer}, }, "SA4011": { Run: CheckScopedBreak, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA4012": { Run: CheckNaNComparison, Requires: []*analysis.Analyzer{buildir.Analyzer}, }, "SA4013": { Run: CheckDoubleNegation, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA4014": { Run: CheckRepeatedIfElse, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA4015": makeCallCheckerAnalyzer(checkMathIntRules), "SA4016": { Run: CheckSillyBitwiseOps, Requires: []*analysis.Analyzer{inspect.Analyzer, tokenfile.Analyzer}, }, "SA4017": { Run: CheckSideEffectFreeCalls, Requires: []*analysis.Analyzer{buildir.Analyzer, purity.Analyzer}, }, "SA4018": { Run: CheckSelfAssignment, Requires: []*analysis.Analyzer{inspect.Analyzer, generated.Analyzer, tokenfile.Analyzer, purity.Analyzer}, }, "SA4019": { Run: CheckDuplicateBuildConstraints, Requires: []*analysis.Analyzer{generated.Analyzer}, }, "SA4020": { Run: CheckUnreachableTypeCases, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA4021": { Run: CheckSingleArgAppend, Requires: []*analysis.Analyzer{inspect.Analyzer, generated.Analyzer, tokenfile.Analyzer}, }, "SA4022": { Run: CheckAddressIsNil, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA4023": { Run: CheckTypedNilInterface, Requires: []*analysis.Analyzer{buildir.Analyzer, typedness.Analysis, nilness.Analysis}, }, "SA4024": { Run: CheckBuiltinZeroComparison, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA4025": { Run: CheckIntegerDivisionEqualsZero, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA4026": { Run: CheckNegativeZeroFloat, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA4027": { Run: CheckIneffectiveURLQueryModification, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA4028": { Run: CheckModuloOne, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA4029": { Run: CheckIneffectiveSort, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA4030": { Run: CheckIneffectiveRandInt, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA4031": { Run: CheckAllocationNilCheck, Requires: []*analysis.Analyzer{buildir.Analyzer, inspect.Analyzer, tokenfile.Analyzer}, }, "SA5000": { Run: CheckNilMaps, Requires: []*analysis.Analyzer{buildir.Analyzer}, }, "SA5001": { Run: CheckEarlyDefer, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA5002": { Run: CheckInfiniteEmptyLoop, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA5003": { Run: CheckDeferInInfiniteLoop, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA5004": { Run: CheckLoopEmptyDefault, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA5005": { Run: CheckCyclicFinalizer, Requires: []*analysis.Analyzer{buildir.Analyzer}, }, "SA5007": { Run: CheckInfiniteRecursion, Requires: []*analysis.Analyzer{buildir.Analyzer}, }, "SA5008": { Run: CheckStructTags, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA5009": makeCallCheckerAnalyzer(checkPrintfRules), "SA5010": { Run: CheckImpossibleTypeAssertion, Requires: []*analysis.Analyzer{buildir.Analyzer, tokenfile.Analyzer}, }, "SA5011": { Run: CheckMaybeNil, Requires: []*analysis.Analyzer{buildir.Analyzer}, }, "SA5012": { Run: CheckEvenSliceLength, FactTypes: []analysis.Fact{new(evenElements)}, Requires: []*analysis.Analyzer{buildir.Analyzer}, }, "SA6000": makeCallCheckerAnalyzer(checkRegexpMatchLoopRules), "SA6001": { Run: CheckMapBytesKey, Requires: []*analysis.Analyzer{buildir.Analyzer}, }, "SA6002": makeCallCheckerAnalyzer(checkSyncPoolValueRules), "SA6003": { Run: CheckRangeStringRunes, Requires: []*analysis.Analyzer{buildir.Analyzer}, }, "SA6005": { Run: CheckToLowerToUpperComparison, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA9001": { Run: CheckDubiousDeferInChannelRangeLoop, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA9002": { Run: CheckNonOctalFileMode, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA9003": { Run: CheckEmptyBranch, Requires: []*analysis.Analyzer{buildir.Analyzer, tokenfile.Analyzer, generated.Analyzer}, }, "SA9004": { Run: CheckMissingEnumTypesInDeclaration, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA9005": makeCallCheckerAnalyzer(checkNoopMarshal, generated.Analyzer), "SA9006": { Run: CheckStaticBitShift, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "SA9007": { Run: CheckBadRemoveAll, Requires: []*analysis.Analyzer{buildir.Analyzer}, }, "SA9008": { Run: CheckTypeAssertionShadowingElse, Requires: []*analysis.Analyzer{inspect.Analyzer, buildir.Analyzer, tokenfile.Analyzer}, }, })
var Docs = lint.Markdownify(map[string]*lint.RawDocumentation{ "SA1000": { Title: `Invalid regular expression`, Since: "2017.1", Severity: lint.SeverityError, MergeIf: lint.MergeIfAny, }, "SA1001": { Title: `Invalid template`, Since: "2017.1", Severity: lint.SeverityError, MergeIf: lint.MergeIfAny, }, "SA1002": { Title: `Invalid format in \'time.Parse\'`, Since: "2017.1", Severity: lint.SeverityError, MergeIf: lint.MergeIfAny, }, "SA1003": { Title: `Unsupported argument to functions in \'encoding/binary\'`, Text: "" /* 318 byte string literal not displayed */, Since: "2017.1", Severity: lint.SeverityError, MergeIf: lint.MergeIfAny, }, "SA1004": { Title: `Suspiciously small untyped constant in \'time.Sleep\'`, Text: "" /* 665 byte string literal not displayed */, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA1005": { Title: `Invalid first argument to \'exec.Command\'`, Text: "" /* 686 byte string literal not displayed */, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA1006": { Title: `\'Printf\' with dynamic first argument and no further arguments`, Text: "" /* 627 byte string literal not displayed */, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA1007": { Title: `Invalid URL in \'net/url.Parse\'`, Since: "2017.1", Severity: lint.SeverityError, MergeIf: lint.MergeIfAny, }, "SA1008": { Title: `Non-canonical key in \'http.Header\' map`, Text: "" /* 744 byte string literal not displayed */, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA1010": { 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", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA1011": { Title: `Various methods in the \"strings\" package expect valid UTF-8, but invalid input is provided`, Since: "2017.1", Severity: lint.SeverityError, MergeIf: lint.MergeIfAny, }, "SA1012": { Title: `A nil \'context.Context\' is being passed to a function, consider using \'context.TODO\' instead`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA1013": { Title: `\'io.Seeker.Seek\' is being called with the whence constant as the first argument, but it should be the second`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA1014": { Title: `Non-pointer value passed to \'Unmarshal\' or \'Decode\'`, Since: "2017.1", Severity: lint.SeverityError, MergeIf: lint.MergeIfAny, }, "SA1015": { Title: "" /* 149 byte string literal not displayed */, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA1016": { Title: `Trapping a signal that cannot be trapped`, Text: "" /* 278 byte string literal not displayed */, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA1017": { Title: `Channels used with \'os/signal.Notify\' should be buffered`, Text: "" /* 388 byte string literal not displayed */, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA1018": { Title: `\'strings.Replace\' called with \'n == 0\', which does nothing`, Text: "" /* 131 byte string literal not displayed */, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA1019": { Title: `Using a deprecated function, variable, constant or field`, Since: "2017.1", Severity: lint.SeverityDeprecated, MergeIf: lint.MergeIfAny, }, "SA1020": { Title: `Using an invalid host:port pair with a \'net.Listen\'-related function`, Since: "2017.1", Severity: lint.SeverityError, MergeIf: lint.MergeIfAny, }, "SA1021": { Title: `Using \'bytes.Equal\' to compare two \'net.IP\'`, Text: "" /* 345 byte string literal not displayed */, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA1023": { Title: `Modifying the buffer in an \'io.Writer\' implementation`, Text: `\'Write\' must not modify the slice data, even temporarily.`, Since: "2017.1", Severity: lint.SeverityError, MergeIf: lint.MergeIfAny, }, "SA1024": { Title: `A string cutset contains duplicate characters`, Text: "" /* 411 byte string literal not displayed */, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA1025": { Title: `It is not possible to use \'(*time.Timer).Reset\''s return value correctly`, Since: "2019.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA1026": { Title: `Cannot marshal channels or functions`, Since: "2019.2", Severity: lint.SeverityError, MergeIf: lint.MergeIfAny, }, "SA1027": { Title: `Atomic access to 64-bit variable must be 64-bit aligned`, Text: "" /* 333 byte string literal not displayed */, Since: "2019.2", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA1028": { Title: `\'sort.Slice\' can only be used on slices`, Text: `The first argument of \'sort.Slice\' must be a slice.`, Since: "2020.1", Severity: lint.SeverityError, MergeIf: lint.MergeIfAny, }, "SA1029": { Title: `Inappropriate key in call to \'context.WithValue\'`, Text: "" /* 420 byte string literal not displayed */, Since: "2020.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA1030": { Title: `Invalid argument in call to a \'strconv\' function`, Text: "" /* 133 byte string literal not displayed */, Since: "2021.1", Severity: lint.SeverityError, MergeIf: lint.MergeIfAny, }, "SA2000": { Title: `\'sync.WaitGroup.Add\' called inside the goroutine, leading to a race condition`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA2001": { Title: `Empty critical section, did you mean to defer the unlock?`, Text: "" /* 540 byte string literal not displayed */, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA2002": { Title: `Called \'testing.T.FailNow\' or \'SkipNow\' in a goroutine, which isn't allowed`, Since: "2017.1", Severity: lint.SeverityError, MergeIf: lint.MergeIfAny, }, "SA2003": { Title: `Deferred \'Lock\' right after locking, likely meant to defer \'Unlock\' instead`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA3000": { Title: `\'TestMain\' doesn't call \'os.Exit\', hiding test failures`, Text: "" /* 379 byte string literal not displayed */, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA3001": { Title: `Assigning to \'b.N\' in benchmarks distorts the results`, Text: "" /* 233 byte string literal not displayed */, Since: "2017.1", Severity: lint.SeverityError, MergeIf: lint.MergeIfAny, }, "SA4000": { Title: `Binary operator has identical expressions on both sides`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA4001": { Title: `\'&*x\' gets simplified to \'x\', it does not copy \'x\'`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA4003": { Title: `Comparing unsigned values against negative values is pointless`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAll, }, "SA4004": { Title: `The loop exits unconditionally after one iteration`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAll, }, "SA4005": { Title: `Field assignment that will never be observed. Did you mean to use a pointer receiver?`, Since: "2021.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA4006": { Title: `A value assigned to a variable is never read before being overwritten. Forgotten error check or dead code?`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAll, }, "SA4008": { Title: `The variable in the loop condition never changes, are you incrementing the wrong variable?`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAll, }, "SA4009": { Title: `A function argument is overwritten before its first use`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA4010": { Title: `The result of \'append\' will never be observed anywhere`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAll, }, "SA4011": { Title: `Break statement with no effect. Did you mean to break out of an outer loop?`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA4012": { Title: `Comparing a value against NaN even though no value is equal to NaN`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA4013": { Title: `Negating a boolean twice (\'!!b\') is the same as writing \'b\'. This is either redundant, or a typo.`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA4014": { Title: "" /* 151 byte string literal not displayed */, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAll, }, "SA4015": { Title: `Calling functions like \'math.Ceil\' on floats converted from integers doesn't do anything useful`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAll, }, "SA4016": { Title: `Certain bitwise operations, such as \'x ^ 0\', do not do anything useful`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA4017": { Title: `Discarding the return values of a function without side effects, making the call pointless`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAll, }, "SA4018": { Title: `Self-assignment of variables`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA4019": { Title: `Multiple, identical build constraints in the same file`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA4020": { Title: `Unreachable case clause in a type switch`, Text: "" /* 1555 byte string literal not displayed */, Since: "2019.2", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAll, }, "SA4021": { Title: `\"x = append(y)\" is equivalent to \"x = y\"`, Since: "2019.2", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA4022": { Title: `Comparing the address of a variable against nil`, Text: `Code such as \"if &x == nil\" is meaningless, because taking the address of a variable always yields a non-nil pointer.`, Since: "2020.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA4023": { Title: `Impossible comparison of interface value with untyped nil`, Text: "" /* 2418 byte string literal not displayed */, Since: "2020.2", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA4024": { Title: `Checking for impossible return value from a builtin function`, Text: "" /* 234 byte string literal not displayed */, Since: "2021.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA4025": { Title: "Integer division of literals that results in zero", Text: "" /* 513 byte string literal not displayed */, Since: "2021.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA4026": { Title: "Go constants cannot express negative zero", Text: "" /* 438 byte string literal not displayed */, Since: "2021.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA4027": { Title: `\'(*net/url.URL).Query\' returns a copy, modifying it doesn't change the URL`, Text: "" /* 354 byte string literal not displayed */, Since: "2021.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA4028": { Title: `\'x % 1\' is always zero`, Since: "2022.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA4029": { Title: "Ineffective attempt at sorting slice", Text: "" /* 369 byte string literal not displayed */, Since: "2022.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA4030": { Title: "Ineffective attempt at generating random number", Text: "" /* 326 byte string literal not displayed */, Since: "2022.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA4031": { Title: `Checking never-nil value against nil`, Since: "2022.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA5000": { Title: `Assignment to nil map`, Since: "2017.1", Severity: lint.SeverityError, MergeIf: lint.MergeIfAny, }, "SA5001": { Title: `Deferring \'Close\' before checking for a possible error`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA5002": { Title: `The empty for loop (\"for {}\") spins and can block the scheduler`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA5003": { Title: `Defers in infinite loops will never execute`, Text: "" /* 174 byte string literal not displayed */, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA5004": { Title: `\"for { select { ...\" with an empty default branch spins`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA5005": { Title: `The finalizer references the finalized object, preventing garbage collection`, Text: "" /* 656 byte string literal not displayed */, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA5007": { Title: `Infinite recursive call`, Text: "" /* 447 byte string literal not displayed */, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA5008": { Title: `Invalid struct tag`, Since: "2019.2", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA5009": { Title: `Invalid Printf call`, Since: "2019.2", Severity: lint.SeverityError, MergeIf: lint.MergeIfAny, }, "SA5010": { Title: `Impossible type assertion`, Text: "" /* 690 byte string literal not displayed */, Since: "2020.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA5011": { Title: `Possible nil pointer dereference`, Text: "" /* 1836 byte string literal not displayed */, Since: "2020.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA5012": { Title: "Passing odd-sized slice to function expecting even size", Text: "" /* 301 byte string literal not displayed */, Since: "2020.2", Severity: lint.SeverityError, MergeIf: lint.MergeIfAny, }, "SA6000": { Title: `Using \'regexp.Match\' or related in a loop, should use \'regexp.Compile\'`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA6001": { Title: `Missing an optimization opportunity when indexing maps by byte slices`, Text: "" /* 818 byte string literal not displayed */, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA6002": { Title: `Storing non-pointer values in \'sync.Pool\' allocates memory`, Text: "" /* 600 byte string literal not displayed */, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA6003": { Title: `Converting a string to a slice of runes before ranging over it`, Text: "" /* 579 byte string literal not displayed */, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA6005": { Title: `Inefficient string comparison with \'strings.ToLower\' or \'strings.ToUpper\'`, Text: "" /* 781 byte string literal not displayed */, Since: "2019.2", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA9001": { Title: `Defers in range loops may not run when you expect them to`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA9002": { Title: `Using a non-octal \'os.FileMode\' that looks like it was meant to be in octal.`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA9003": { Title: `Empty body in an if or else branch`, Since: "2017.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA9004": { Title: `Only the first constant has an explicit type`, Text: "" /* 1687 byte string literal not displayed */, Since: "2019.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA9005": { Title: `Trying to marshal a struct with no public fields nor custom marshaling`, Text: "" /* 371 byte string literal not displayed */, Since: "2019.2", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAll, }, "SA9006": { Title: `Dubious bit shifting of a fixed size integer value`, Text: "" /* 512 byte string literal not displayed */, Since: "2020.2", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA9007": { Title: "Deleting a directory that shouldn't be deleted", Text: "" /* 579 byte string literal not displayed */, Since: "2022.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, "SA9008": { Title: `\'else\' branch of a type assertion is probably not reading the right value`, Text: "" /* 625 byte string literal not displayed */, Since: "2022.1", Severity: lint.SeverityWarning, MergeIf: lint.MergeIfAny, }, })
Functions ¶
func CanBinaryMarshal ¶
func CheckAddressIsNil ¶
func CheckAllocationNilCheck ¶
func CheckArgOverwritten ¶
func CheckBadRemoveAll ¶
func CheckBenchmarkN ¶
func CheckBuiltinZeroComparison ¶
func CheckCanonicalHeaderKey ¶
func CheckConcurrentTesting ¶
func CheckCyclicFinalizer ¶
func CheckDeferInInfiniteLoop ¶
func CheckDeferLock ¶
func CheckDeprecated ¶
func CheckDoubleNegation ¶
func CheckDubiousDeferInChannelRangeLoop ¶
func CheckDuplicateBuildConstraints ¶
func CheckEarlyDefer ¶
func CheckEmptyBranch ¶
func CheckEmptyCriticalSection ¶
func CheckEvenSliceLength ¶
func CheckExec ¶
func CheckExtremeComparison ¶
func CheckImpossibleTypeAssertion ¶
func CheckIneffectiveAppend ¶
func CheckIneffectiveCopy ¶
func CheckIneffectiveFieldAssignments ¶
func CheckIneffectiveLoop ¶
func CheckIneffectiveRandInt ¶
func CheckIneffectiveSort ¶
func CheckIneffectiveURLQueryModification ¶
func CheckInfiniteEmptyLoop ¶
func CheckInfiniteRecursion ¶
func CheckIntegerDivisionEqualsZero ¶
func CheckLeakyTimeTick ¶
func CheckLhsRhsIdentical ¶
func CheckLoopCondition ¶
func CheckLoopEmptyDefault ¶
func CheckMapBytesKey ¶
func CheckMaybeNil ¶
func CheckMissingEnumTypesInDeclaration ¶
func CheckModuloOne ¶
func CheckNaNComparison ¶
func CheckNegativeZeroFloat ¶
func CheckNilContext ¶
func CheckNilMaps ¶
func CheckNonOctalFileMode ¶
func CheckPredeterminedBooleanExprs ¶
func CheckRangeStringRunes ¶
func CheckRepeatedIfElse ¶
func CheckScopedBreak ¶
func CheckSeeker ¶
func CheckSelfAssignment ¶
func CheckSideEffectFreeCalls ¶
func CheckSillyBitwiseOps ¶
func CheckSillyRegexp ¶
func CheckSingleArgAppend ¶
func CheckStaticBitShift ¶
func CheckStructTags ¶
func CheckTemplate ¶
func CheckTestMainExit ¶
func CheckTimeSleepConstant ¶
func CheckTimerResetReturnValue ¶
func CheckToLowerToUpperComparison ¶
func CheckTypeAssertionShadowingElse ¶
func CheckTypedNilInterface ¶
func CheckUnreachableTypeCases ¶
func CheckUnreadVariableValues ¶
func CheckUnsafePrintf ¶
func CheckUntrappableSignal ¶
func CheckWaitgroupAdd ¶
func CheckWriterBufferModified ¶
func ConvertedFrom ¶
ConvertedFrom reports whether value v was converted from type typ.
func ConvertedFromInt ¶
func InvalidUTF8 ¶
func Pointer ¶
func UnbufferedChannel ¶
func UniqueStringCutset ¶
func ValidHostPort ¶
func ValidateRegexp ¶
func ValidateTimeLayout ¶
func ValidateURL ¶
Types ¶
type Argument ¶
type Argument struct { Value Value // contains filtered or unexported fields }
func (*Argument) Invalid ¶
type Call ¶
type Call struct { Pass *analysis.Pass Instr ir.CallInstruction Args []*Argument Parent *ir.Function // contains filtered or unexported fields }
func (*Call) Invalid ¶
type CallCheck ¶
type CallCheck func(call *Call)
func RepeatZeroTimes ¶
type Value ¶
Source Files ¶
analysis.go buildtag.go doc.go lint.go rules.go structtag.go
Directories ¶
Path | Synopsis |
---|---|
staticcheck/fakejson | |
staticcheck/fakereflect | |
staticcheck/fakexml |
- Version
- v0.4.2
- Published
- Feb 16, 2023
- Platform
- linux/amd64
- Imports
- 46 packages
- Last checked
- 2 minutes ago –
Tools for package owners.