Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( BytesFunctions = []checker.Violation{ { Targets: checker.Bytes, Type: checker.Function, Package: "bytes", Caller: "NewBuffer", Args: []int{0}, AltCaller: "NewBufferString", Generate: &checker.Generate{ Pattern: `NewBuffer($0)`, Returns: []string{"*bytes.Buffer"}, }, }, { Targets: checker.Strings, Type: checker.Function, Package: "bytes", Caller: "NewBufferString", Args: []int{0}, AltCaller: "NewBuffer", Generate: &checker.Generate{ Pattern: `NewBufferString($0)`, Returns: []string{"*bytes.Buffer"}, }, }, { Targets: checker.Bytes, Type: checker.Function, Package: "bytes", Caller: "Compare", Args: []int{0, 1}, AltPackage: "strings", AltCaller: "Compare", Generate: &checker.Generate{ Pattern: `Compare($0, $1)`, Returns: []string{"int"}, }, }, { Targets: checker.Bytes, Type: checker.Function, Package: "bytes", Caller: "Contains", Args: []int{0, 1}, AltPackage: "strings", AltCaller: "Contains", Generate: &checker.Generate{ Pattern: `Contains($0, $1)`, Returns: []string{"bool"}, }, }, { Targets: checker.Bytes, Type: checker.Function, Package: "bytes", Caller: "ContainsAny", Args: []int{0}, AltPackage: "strings", AltCaller: "ContainsAny", Generate: &checker.Generate{ Pattern: `ContainsAny($0, "f")`, Returns: []string{"bool"}, }, }, { Targets: checker.Bytes, Type: checker.Function, Package: "bytes", Caller: "ContainsRune", Args: []int{0}, AltPackage: "strings", AltCaller: "ContainsRune", Generate: &checker.Generate{ Pattern: `ContainsRune($0, 'ф')`, Returns: []string{"bool"}, }, }, { Targets: checker.Bytes, Type: checker.Function, Package: "bytes", Caller: "Count", Args: []int{0, 1}, AltPackage: "strings", AltCaller: "Count", Generate: &checker.Generate{ Pattern: `Count($0, $1)`, Returns: []string{"int"}, }, }, { Targets: checker.Bytes, Type: checker.Function, Package: "bytes", Caller: "EqualFold", Args: []int{0, 1}, AltPackage: "strings", AltCaller: "EqualFold", Generate: &checker.Generate{ Pattern: `EqualFold($0, $1)`, Returns: []string{"bool"}, }, }, { Targets: checker.Bytes, Type: checker.Function, Package: "bytes", Caller: "HasPrefix", Args: []int{0, 1}, AltPackage: "strings", AltCaller: "HasPrefix", Generate: &checker.Generate{ Pattern: `HasPrefix($0, $1)`, Returns: []string{"bool"}, }, }, { Targets: checker.Bytes, Type: checker.Function, Package: "bytes", Caller: "HasSuffix", Args: []int{0, 1}, AltPackage: "strings", AltCaller: "HasSuffix", Generate: &checker.Generate{ Pattern: `HasSuffix($0, $1)`, Returns: []string{"bool"}, }, }, { Targets: checker.Bytes, Type: checker.Function, Package: "bytes", Caller: "Index", Args: []int{0, 1}, AltPackage: "strings", AltCaller: "Index", Generate: &checker.Generate{ Pattern: `Index($0, $1)`, Returns: []string{"int"}, }, }, { Targets: checker.Bytes, Type: checker.Function, Package: "bytes", Caller: "IndexAny", Args: []int{0}, AltPackage: "strings", AltCaller: "IndexAny", Generate: &checker.Generate{ Pattern: `IndexAny($0, "f")`, Returns: []string{"int"}, }, }, { Targets: checker.Bytes, Type: checker.Function, Package: "bytes", Caller: "IndexByte", Args: []int{0}, AltPackage: "strings", AltCaller: "IndexByte", Generate: &checker.Generate{ Pattern: `IndexByte($0, 'f')`, Returns: []string{"int"}, }, }, { Targets: checker.Bytes, Type: checker.Function, Package: "bytes", Caller: "IndexFunc", Args: []int{0}, AltPackage: "strings", AltCaller: "IndexFunc", Generate: &checker.Generate{ Pattern: `IndexFunc($0, func(rune) bool {return true })`, Returns: []string{"int"}, }, }, { Targets: checker.Bytes, Type: checker.Function, Package: "bytes", Caller: "IndexRune", Args: []int{0}, AltPackage: "strings", AltCaller: "IndexRune", Generate: &checker.Generate{ Pattern: `IndexRune($0, rune('ф'))`, Returns: []string{"int"}, }, }, { Targets: checker.Bytes, Type: checker.Function, Package: "bytes", Caller: "LastIndex", Args: []int{0, 1}, AltPackage: "strings", AltCaller: "LastIndex", Generate: &checker.Generate{ Pattern: `LastIndex($0, $1)`, Returns: []string{"int"}, }, }, { Targets: checker.Bytes, Type: checker.Function, Package: "bytes", Caller: "LastIndexAny", Args: []int{0}, AltPackage: "strings", AltCaller: "LastIndexAny", Generate: &checker.Generate{ Pattern: `LastIndexAny($0, "ф")`, Returns: []string{"int"}, }, }, { Targets: checker.Bytes, Type: checker.Function, Package: "bytes", Caller: "LastIndexByte", Args: []int{0}, AltPackage: "strings", AltCaller: "LastIndexByte", Generate: &checker.Generate{ Pattern: `LastIndexByte($0, 'f')`, Returns: []string{"int"}, }, }, { Targets: checker.Bytes, Type: checker.Function, Package: "bytes", Caller: "LastIndexFunc", Args: []int{0}, AltPackage: "strings", AltCaller: "LastIndexFunc", Generate: &checker.Generate{ Pattern: `LastIndexFunc($0, func(rune) bool {return true })`, Returns: []string{"int"}, }, }, } BytesBufferMethods = []checker.Violation{ { Targets: checker.Bytes, Type: checker.Method, Package: "bytes", Struct: "Buffer", Caller: "Write", Args: []int{0}, AltCaller: "WriteString", Generate: &checker.Generate{ PreCondition: `bb := bytes.Buffer{}`, Pattern: `Write($0)`, Returns: []string{"int", "error"}, }, }, { Targets: checker.Strings, Type: checker.Method, Package: "bytes", Struct: "Buffer", Caller: "WriteString", Args: []int{0}, AltCaller: "Write", Generate: &checker.Generate{ PreCondition: `bb := bytes.Buffer{}`, Pattern: `WriteString($0)`, Returns: []string{"int", "error"}, }, }, { Targets: checker.Strings, Type: checker.Method, Package: "bytes", Struct: "Buffer", Caller: "WriteString", Args: []int{0}, ArgsType: checker.Rune, AltCaller: "WriteRune", Generate: &checker.Generate{ SkipGenerate: true, Pattern: `WriteString($0)`, Returns: []string{"int", "error"}, }, }, } )
View Source
var ( MaphashFunctions = []checker.Violation{ { Targets: checker.Bytes, Type: checker.Function, Package: "hash/maphash", Caller: "Bytes", Args: []int{1}, AltCaller: "String", Generate: &checker.Generate{ Pattern: `Bytes(maphash.MakeSeed(), $0)`, Returns: []string{"uint64"}, }, }, { Targets: checker.Strings, Type: checker.Function, Package: "hash/maphash", Caller: "String", Args: []int{1}, AltCaller: "Bytes", Generate: &checker.Generate{ Pattern: `String(maphash.MakeSeed(), $0)`, Returns: []string{"uint64"}, }, }, } MaphashMethods = []checker.Violation{ { Targets: checker.Bytes, Type: checker.Method, Package: "hash/maphash", Struct: "Hash", Caller: "Write", Args: []int{0}, AltCaller: "WriteString", Generate: &checker.Generate{ PreCondition: `h := maphash.Hash{}`, Pattern: `Write($0)`, Returns: []string{"int", "error"}, }, }, { Targets: checker.Strings, Type: checker.Method, Package: "hash/maphash", Struct: "Hash", Caller: "WriteString", Args: []int{0}, AltCaller: "Write", Generate: &checker.Generate{ PreCondition: `h := maphash.Hash{}`, Pattern: `WriteString($0)`, Returns: []string{"int", "error"}, }, }, } )
View Source
var ( RegexpFunctions = []checker.Violation{ { Targets: checker.Bytes, Type: checker.Function, Package: "regexp", Caller: "Match", Args: []int{1}, AltCaller: "MatchString", Generate: &checker.Generate{ Pattern: `Match("foo", $0)`, Returns: []string{"bool", "error"}, }, }, { Targets: checker.Strings, Type: checker.Function, Package: "regexp", Caller: "MatchString", Args: []int{1}, AltCaller: "Match", Generate: &checker.Generate{ Pattern: `MatchString("foo", $0)`, Returns: []string{"bool", "error"}, }, }, } RegexpRegexpMethods = []checker.Violation{ { Targets: checker.Bytes, Type: checker.Method, Package: "regexp", Struct: "Regexp", Caller: "Match", Args: []int{0}, AltCaller: "MatchString", Generate: &checker.Generate{ PreCondition: `re := regexp.MustCompile(".*")`, Pattern: `Match($0)`, Returns: []string{"bool"}, }, }, { Targets: checker.Strings, Type: checker.Method, Package: "regexp", Struct: "Regexp", Caller: "MatchString", Args: []int{0}, AltCaller: "Match", Generate: &checker.Generate{ PreCondition: `re := regexp.MustCompile(".*")`, Pattern: `MatchString($0)`, Returns: []string{"bool"}, }, }, { Targets: checker.Bytes, Type: checker.Method, Package: "regexp", Struct: "Regexp", Caller: "FindAllIndex", Args: []int{0}, AltCaller: "FindAllStringIndex", Generate: &checker.Generate{ PreCondition: `re := regexp.MustCompile(".*")`, Pattern: `FindAllIndex($0, 1)`, Returns: []string{"[][]int"}, }, }, { Targets: checker.Strings, Type: checker.Method, Package: "regexp", Struct: "Regexp", Caller: "FindAllStringIndex", Args: []int{0}, AltCaller: "FindAllIndex", Generate: &checker.Generate{ PreCondition: `re := regexp.MustCompile(".*")`, Pattern: `FindAllStringIndex($0, 1)`, Returns: []string{"[][]int"}, }, }, { Targets: checker.Bytes, Type: checker.Method, Package: "regexp", Struct: "Regexp", Caller: "FindAllSubmatchIndex", Args: []int{0}, AltCaller: "FindAllStringSubmatchIndex", Generate: &checker.Generate{ PreCondition: `re := regexp.MustCompile(".*")`, Pattern: `FindAllSubmatchIndex($0, 1)`, Returns: []string{"[][]int"}, }, }, { Targets: checker.Strings, Type: checker.Method, Package: "regexp", Struct: "Regexp", Caller: "FindAllStringSubmatchIndex", Args: []int{0}, AltCaller: "FindAllSubmatchIndex", Generate: &checker.Generate{ PreCondition: `re := regexp.MustCompile(".*")`, Pattern: `FindAllStringSubmatchIndex($0, 1)`, Returns: []string{"[][]int"}, }, }, { Targets: checker.Bytes, Type: checker.Method, Package: "regexp", Struct: "Regexp", Caller: "FindIndex", Args: []int{0}, AltCaller: "FindStringIndex", Generate: &checker.Generate{ PreCondition: `re := regexp.MustCompile(".*")`, Pattern: `FindIndex($0)`, Returns: []string{"[]int"}, }, }, { Targets: checker.Strings, Type: checker.Method, Package: "regexp", Struct: "Regexp", Caller: "FindStringIndex", Args: []int{0}, AltCaller: "FindIndex", Generate: &checker.Generate{ PreCondition: `re := regexp.MustCompile(".*")`, Pattern: `FindStringIndex($0)`, Returns: []string{"[]int"}, }, }, { Targets: checker.Bytes, Type: checker.Method, Package: "regexp", Struct: "Regexp", Caller: "FindSubmatchIndex", Args: []int{0}, AltCaller: "FindStringSubmatchIndex", Generate: &checker.Generate{ PreCondition: `re := regexp.MustCompile(".*")`, Pattern: `FindSubmatchIndex($0)`, Returns: []string{"[]int"}, }, }, { Targets: checker.Strings, Type: checker.Method, Package: "regexp", Struct: "Regexp", Caller: "FindStringSubmatchIndex", Args: []int{0}, AltCaller: "FindSubmatchIndex", Generate: &checker.Generate{ PreCondition: `re := regexp.MustCompile(".*")`, Pattern: `FindStringSubmatchIndex($0)`, Returns: []string{"[]int"}, }, }, } )
View Source
var ( StringFunctions = []checker.Violation{ { Targets: checker.Strings, Type: checker.Function, Package: "strings", Caller: "Compare", Args: []int{0, 1}, AltPackage: "bytes", AltCaller: "Compare", Generate: &checker.Generate{ Pattern: `Compare($0,$1)`, Returns: []string{"int"}, }, }, { Targets: checker.Strings, Type: checker.Function, Package: "strings", Caller: "Contains", Args: []int{0, 1}, AltPackage: "bytes", AltCaller: "Contains", Generate: &checker.Generate{ Pattern: `Contains($0,$1)`, Returns: []string{"bool"}, }, }, { Targets: checker.Strings, Type: checker.Function, Package: "strings", Caller: "ContainsAny", Args: []int{0}, AltPackage: "bytes", AltCaller: "ContainsAny", Generate: &checker.Generate{ Pattern: `ContainsAny($0,"foobar")`, Returns: []string{"bool"}, }, }, { Targets: checker.Strings, Type: checker.Function, Package: "strings", Caller: "ContainsRune", Args: []int{0}, AltPackage: "bytes", AltCaller: "ContainsRune", Generate: &checker.Generate{ Pattern: `ContainsRune($0,'ф')`, Returns: []string{"bool"}, }, }, { Targets: checker.Strings, Type: checker.Function, Package: "strings", Caller: "Count", Args: []int{0, 1}, AltPackage: "bytes", AltCaller: "Count", Generate: &checker.Generate{ Pattern: `Count($0, $1)`, Returns: []string{"int"}, }, }, { Targets: checker.Strings, Type: checker.Function, Package: "strings", Caller: "EqualFold", Args: []int{0, 1}, AltPackage: "bytes", AltCaller: "EqualFold", Generate: &checker.Generate{ Pattern: `EqualFold($0,$1)`, Returns: []string{"bool"}, }, }, { Targets: checker.Strings, Type: checker.Function, Package: "strings", Caller: "HasPrefix", Args: []int{0, 1}, AltPackage: "bytes", AltCaller: "HasPrefix", Generate: &checker.Generate{ Pattern: `HasPrefix($0,$1)`, Returns: []string{"bool"}, }, }, { Targets: checker.Strings, Type: checker.Function, Package: "strings", Caller: "HasSuffix", Args: []int{0, 1}, AltPackage: "bytes", AltCaller: "HasSuffix", Generate: &checker.Generate{ Pattern: `HasSuffix($0,$1)`, Returns: []string{"bool"}, }, }, { Targets: checker.Strings, Type: checker.Function, Package: "strings", Caller: "Index", Args: []int{0, 1}, AltPackage: "bytes", AltCaller: "Index", Generate: &checker.Generate{ Pattern: `Index($0,$1)`, Returns: []string{"int"}, }, }, { Targets: checker.Strings, Type: checker.Function, Package: "strings", Caller: "IndexAny", Args: []int{0}, AltPackage: "bytes", AltCaller: "IndexAny", Generate: &checker.Generate{ Pattern: `IndexAny($0, "f")`, Returns: []string{"int"}, }, }, { Targets: checker.Strings, Type: checker.Function, Package: "strings", Caller: "IndexByte", Args: []int{0}, AltPackage: "bytes", AltCaller: "IndexByte", Generate: &checker.Generate{ Pattern: `IndexByte($0, 'f')`, Returns: []string{"int"}, }, }, { Targets: checker.Strings, Type: checker.Function, Package: "strings", Caller: "IndexFunc", Args: []int{0}, AltPackage: "bytes", AltCaller: "IndexFunc", Generate: &checker.Generate{ Pattern: `IndexFunc($0, func(r rune) bool { return true })`, Returns: []string{"int"}, }, }, { Targets: checker.Strings, Type: checker.Function, Package: "strings", Caller: "IndexRune", Args: []int{0}, AltPackage: "bytes", AltCaller: "IndexRune", Generate: &checker.Generate{ Pattern: `IndexRune($0, rune('ф'))`, Returns: []string{"int"}, }, }, { Targets: checker.Strings, Type: checker.Function, Package: "strings", Caller: "LastIndex", Args: []int{0, 1}, AltPackage: "bytes", AltCaller: "LastIndex", Generate: &checker.Generate{ Pattern: `LastIndex($0,$1)`, Returns: []string{"int"}, }, }, { Targets: checker.Strings, Type: checker.Function, Package: "strings", Caller: "LastIndexAny", Args: []int{0}, AltPackage: "bytes", AltCaller: "LastIndexAny", Generate: &checker.Generate{ Pattern: `LastIndexAny($0,"f")`, Returns: []string{"int"}, }, }, { Targets: checker.Strings, Type: checker.Function, Package: "strings", Caller: "LastIndexByte", Args: []int{0}, AltPackage: "bytes", AltCaller: "LastIndexByte", Generate: &checker.Generate{ Pattern: `LastIndexByte($0, 'f')`, Returns: []string{"int"}, }, }, { Targets: checker.Strings, Type: checker.Function, Package: "strings", Caller: "LastIndexFunc", Args: []int{0}, AltPackage: "bytes", AltCaller: "LastIndexFunc", Generate: &checker.Generate{ Pattern: `LastIndexFunc($0, func(r rune) bool { return true })`, Returns: []string{"int"}, }, }, } StringsBuilderMethods = []checker.Violation{ { Targets: checker.Bytes, Type: checker.Method, Package: "strings", Struct: "Builder", Caller: "Write", Args: []int{0}, AltCaller: "WriteString", Generate: &checker.Generate{ PreCondition: `builder := strings.Builder{}`, Pattern: `Write($0)`, Returns: []string{"int", "error"}, }, }, { Targets: checker.Strings, Type: checker.Method, Package: "strings", Struct: "Builder", Caller: "WriteString", Args: []int{0}, AltCaller: "Write", Generate: &checker.Generate{ PreCondition: `builder := strings.Builder{}`, Pattern: `WriteString($0)`, Returns: []string{"int", "error"}, }, }, { Targets: checker.Strings, Type: checker.Method, Package: "strings", Struct: "Builder", Caller: "WriteString", Args: []int{0}, ArgsType: checker.Rune, AltCaller: "WriteRune", Generate: &checker.Generate{ SkipGenerate: true, Pattern: `WriteString($0)`, Returns: []string{"int", "error"}, }, }, } )
View Source
var BufioMethods = []checker.Violation{ { Targets: checker.Bytes, Type: checker.Method, Package: "bufio", Struct: "Writer", Caller: "Write", Args: []int{0}, AltCaller: "WriteString", Generate: &checker.Generate{ PreCondition: `b := bufio.Writer{}`, Pattern: `Write($0)`, Returns: []string{"int", "error"}, }, }, { Type: checker.Method, Targets: checker.Strings, Package: "bufio", Struct: "Writer", Caller: "WriteString", Args: []int{0}, AltCaller: "Write", Generate: &checker.Generate{ PreCondition: `b := bufio.Writer{}`, Pattern: `WriteString($0)`, Returns: []string{"int", "error"}, }, }, { Targets: checker.Strings, Type: checker.Method, Package: "bufio", Struct: "Writer", Caller: "WriteString", Args: []int{0}, ArgsType: checker.Rune, AltCaller: "WriteRune", Generate: &checker.Generate{ SkipGenerate: true, Pattern: `WriteString($0)`, Returns: []string{"int", "error"}, }, }, }
View Source
var HTTPTestMethods = []checker.Violation{ { Targets: checker.Bytes, Type: checker.Method, Package: "net/http/httptest", Struct: "ResponseRecorder", Caller: "Write", Args: []int{0}, AltCaller: "WriteString", Generate: &checker.Generate{ PreCondition: `h := httptest.ResponseRecorder{}`, Pattern: `Write($0)`, Returns: []string{"int", "error"}, }, }, { Targets: checker.Strings, Type: checker.Method, Package: "net/http/httptest", Struct: "ResponseRecorder", Caller: "WriteString", Args: []int{0}, AltCaller: "Write", Generate: &checker.Generate{ PreCondition: `h := httptest.ResponseRecorder{}`, Pattern: `WriteString($0)`, Returns: []string{"int", "error"}, }, }, }
View Source
var OsFileMethods = []checker.Violation{ { Targets: checker.Bytes, Type: checker.Method, Package: "os", Struct: "File", Caller: "Write", Args: []int{0}, AltCaller: "WriteString", Generate: &checker.Generate{ PreCondition: `f := &os.File{}`, Pattern: `Write($0)`, Returns: []string{"int", "error"}, }, }, { Targets: checker.Strings, Type: checker.Method, Package: "os", Struct: "File", Caller: "WriteString", Args: []int{0}, AltCaller: "Write", Generate: &checker.Generate{ PreCondition: `f := &os.File{}`, Pattern: `WriteString($0)`, Returns: []string{"int", "error"}, }, }, }
View Source
var UTF8Functions = []checker.Violation{ { Type: checker.Function, Targets: checker.Bytes, Package: "unicode/utf8", Caller: "Valid", Args: []int{0}, AltCaller: "ValidString", Generate: &checker.Generate{ Pattern: `Valid($0)`, Returns: []string{"bool"}, }, }, { Targets: checker.Strings, Type: checker.Function, Package: "unicode/utf8", Caller: "ValidString", Args: []int{0}, AltCaller: "Valid", Generate: &checker.Generate{ Pattern: `ValidString($0)`, Returns: []string{"bool"}, }, }, { Targets: checker.Bytes, Type: checker.Function, Package: "unicode/utf8", Caller: "FullRune", Args: []int{0}, AltCaller: "FullRuneInString", Generate: &checker.Generate{ Pattern: `FullRune($0)`, Returns: []string{"bool"}, }, }, { Targets: checker.Strings, Type: checker.Function, Package: "unicode/utf8", Caller: "FullRuneInString", Args: []int{0}, AltCaller: "FullRune", Generate: &checker.Generate{ Pattern: `FullRuneInString($0)`, Returns: []string{"bool"}, }, }, { Targets: checker.Bytes, Type: checker.Function, Package: "unicode/utf8", Caller: "RuneCount", Args: []int{0}, AltCaller: "RuneCountInString", Generate: &checker.Generate{ Pattern: `RuneCount($0)`, Returns: []string{"int"}, }, }, { Targets: checker.Strings, Type: checker.Function, Package: "unicode/utf8", Caller: "RuneCountInString", Args: []int{0}, AltCaller: "RuneCount", Generate: &checker.Generate{ Pattern: `RuneCountInString($0)`, Returns: []string{"int"}, }, }, { Targets: checker.Bytes, Type: checker.Function, Package: "unicode/utf8", Caller: "DecodeLastRune", Args: []int{0}, AltCaller: "DecodeLastRuneInString", Generate: &checker.Generate{ Pattern: `DecodeLastRune($0)`, Returns: []string{"rune", "int"}, }, }, { Targets: checker.Strings, Type: checker.Function, Package: "unicode/utf8", Caller: "DecodeLastRuneInString", Args: []int{0}, AltCaller: "DecodeLastRune", Generate: &checker.Generate{ Pattern: `DecodeLastRuneInString($0)`, Returns: []string{"rune", "int"}, }, }, { Targets: checker.Bytes, Type: checker.Function, Package: "unicode/utf8", Caller: "DecodeRune", Args: []int{0}, AltCaller: "DecodeRuneInString", Generate: &checker.Generate{ Pattern: `DecodeRune($0)`, Returns: []string{"rune", "int"}, }, }, { Targets: checker.Strings, Type: checker.Function, Package: "unicode/utf8", Args: []int{0}, Caller: "DecodeRuneInString", AltCaller: "DecodeRune", Generate: &checker.Generate{ Pattern: `DecodeRuneInString($0)`, Returns: []string{"rune", "int"}, }, }, }
Functions ¶
func NewAnalyzer ¶
Types ¶
This section is empty.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
internal/mirror-table
This generates MIRROR_FUNCS.md
|
This generates MIRROR_FUNCS.md |
internal
|
|
Click to show internal directories.
Click to hide internal directories.