@@ -29,7 +29,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
29
29
callExpr := node .(* ast.CallExpr )
30
30
if p , f , ok := getCallExprFunction (callExpr ); ok && p == "fmt" && f == "Sprintf" {
31
31
if err := checkForHostPortConstruction (callExpr ); err != nil {
32
- pass .Reportf (node .Pos (), err .Error ())
32
+ pass .Reportf (node .Pos (), "%s" , err .Error ())
33
33
}
34
34
}
35
35
})
@@ -52,7 +52,7 @@ func getCallExprFunction(callExpr *ast.CallExpr) (pkg string, fn string, result
52
52
53
53
// getStringLiteral returns the value at a position if it's a string literal.
54
54
func getStringLiteral (args []ast.Expr , pos int ) (string , bool ) {
55
- if len (args ) < pos + 1 {
55
+ if len (args ) < pos + 1 {
56
56
return "" , false
57
57
}
58
58
@@ -72,9 +72,9 @@ func getStringLiteral(args []ast.Expr, pos int) (string, bool) {
72
72
// essentially scheme://%s:<something else>, or scheme://user:pass@%s:<something else>.
73
73
//
74
74
// Matching requirements:
75
- // - Scheme as per RFC3986 is ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
76
- // - A format string substitution in the host portion, preceded by an optional username/password@
77
- // - A colon indicating a port will be specified
75
+ // - Scheme as per RFC3986 is ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
76
+ // - A format string substitution in the host portion, preceded by an optional username/password@
77
+ // - A colon indicating a port will be specified
78
78
func checkForHostPortConstruction (sprintf * ast.CallExpr ) error {
79
79
fs , ok := getStringLiteral (sprintf .Args , 0 )
80
80
if ! ok {
@@ -93,4 +93,4 @@ func checkForHostPortConstruction(sprintf *ast.CallExpr) error {
93
93
}
94
94
95
95
return nil
96
- }
96
+ }
0 commit comments