@@ -252,7 +252,7 @@ func visit(pass *analysis.Pass, opts *Options, node ast.Node, stack []ast.Node)
252
252
253
253
// NOTE: "With" functions have no message argument and must be skipped.
254
254
if opts .StaticMsg && msgPos >= 0 && ! isStaticMsg (call .Args [msgPos ]) {
255
- pass .Reportf (call .Pos (), "message should be a string literal or a constant" )
255
+ pass .Reportf (call .Args [ msgPos ]. Pos (), "message should be a string literal or a constant" )
256
256
}
257
257
258
258
if opts .MsgStyle != "" && msgPos >= 0 {
@@ -262,7 +262,7 @@ func visit(pass *analysis.Pass, opts *Options, node ast.Node, stack []ast.Node)
262
262
panic ("unreachable" ) // string literals are always quoted.
263
263
}
264
264
if ok := isValidMsgStyle (value , opts .MsgStyle ); ! ok {
265
- pass .Reportf (call .Pos (), "message should be %s" , opts .MsgStyle )
265
+ pass .Reportf (call .Args [ msgPos ]. Pos (), "message should be %s" , opts .MsgStyle )
266
266
}
267
267
}
268
268
}
@@ -315,7 +315,7 @@ func visit(pass *analysis.Pass, opts *Options, node ast.Node, stack []ast.Node)
315
315
}
316
316
}
317
317
if ! isConst {
318
- pass .Reportf (call .Pos (), "raw keys should not be used" )
318
+ pass .Reportf (key .Pos (), "raw keys should not be used" )
319
319
}
320
320
})
321
321
}
@@ -342,7 +342,7 @@ func visit(pass *analysis.Pass, opts *Options, node ast.Node, stack []ast.Node)
342
342
if len (opts .ForbiddenKeys ) > 0 {
343
343
forEachKey (pass .TypesInfo , keys , attrs , func (key ast.Expr ) {
344
344
if name , ok := getKeyName (key ); ok && slices .Contains (opts .ForbiddenKeys , name ) {
345
- pass .Reportf (call .Pos (), "%q key is forbidden and should not be used" , name )
345
+ pass .Reportf (key .Pos (), "%q key is forbidden and should not be used" , name )
346
346
}
347
347
})
348
348
}
0 commit comments