|
|
@ -84,28 +84,6 @@ var ( |
|
|
|
allowBuiltin bool |
|
|
|
allowBuiltin bool |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// pkgFunc for all the functions of a given package
|
|
|
|
|
|
|
|
type pkgFunc struct { |
|
|
|
|
|
|
|
functions []string |
|
|
|
|
|
|
|
path string |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type funcImp struct { |
|
|
|
|
|
|
|
pkg, fun string |
|
|
|
|
|
|
|
pos token.Pos |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// All visitors
|
|
|
|
|
|
|
|
type callVisitor struct { |
|
|
|
|
|
|
|
Calls []string |
|
|
|
|
|
|
|
Fset *token.FileSet |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get the position of the node in the file
|
|
|
|
|
|
|
|
type locate interface { |
|
|
|
|
|
|
|
getPos(ast.Node) string |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type illegal struct { |
|
|
|
type illegal struct { |
|
|
|
T string |
|
|
|
T string |
|
|
|
Name string |
|
|
|
Name string |
|
|
@ -319,6 +297,10 @@ func (v *visitor) Visit(n ast.Node) ast.Visitor { |
|
|
|
case *ast.FuncDecl, *ast.GenDecl, *ast.AssignStmt: |
|
|
|
case *ast.FuncDecl, *ast.GenDecl, *ast.AssignStmt: |
|
|
|
//Avoids analysing a declaration inside a declaration
|
|
|
|
//Avoids analysing a declaration inside a declaration
|
|
|
|
//Since this is handle by the functions `isAllowed`
|
|
|
|
//Since this is handle by the functions `isAllowed`
|
|
|
|
|
|
|
|
fdef := funcInfo(t) |
|
|
|
|
|
|
|
if fdef == nil || fdef.obj == nil { |
|
|
|
|
|
|
|
return v |
|
|
|
|
|
|
|
} |
|
|
|
if v.oneTime { |
|
|
|
if v.oneTime { |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
@ -510,23 +492,6 @@ func analyseProgram(functions []*fDefInfo, path string, load loadedSource) *info |
|
|
|
return info |
|
|
|
return info |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//reformat from the data base
|
|
|
|
|
|
|
|
func splitArgs(args string) []string { |
|
|
|
|
|
|
|
result := strings.Split(args, " ") |
|
|
|
|
|
|
|
return result |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func rightFile(args string) string { |
|
|
|
|
|
|
|
expectedFiles := splitArgs(args) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for _, s := range expectedFiles { |
|
|
|
|
|
|
|
if strings.Contains(s, ".go") { |
|
|
|
|
|
|
|
return s |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return "" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type flags struct { |
|
|
|
type flags struct { |
|
|
|
l struct { // flag for char or string literal
|
|
|
|
l struct { // flag for char or string literal
|
|
|
|
noLit bool // true -> unallows
|
|
|
|
noLit bool // true -> unallows
|
|
|
@ -878,16 +843,6 @@ func (l *loadVisitor) Visit(n ast.Node) ast.Visitor { |
|
|
|
return l |
|
|
|
return l |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (f flags) isLitAllowed(s string) bool { |
|
|
|
|
|
|
|
matched, err := regexp.Match(f.l.pattern, []byte(s)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return !matched |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Returns true if the string matches the format of a relative import
|
|
|
|
// Returns true if the string matches the format of a relative import
|
|
|
|
func isRelativeImport(s string) bool { |
|
|
|
func isRelativeImport(s string) bool { |
|
|
|
reg := regexp.MustCompile(`^\.`) |
|
|
|
reg := regexp.MustCompile(`^\.`) |
|
|
|