This commit is contained in:
@@ -2,9 +2,11 @@
|
||||
package httpstatus
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go/ast"
|
||||
"go/constant"
|
||||
"go/types"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/tools/go/analysis"
|
||||
@@ -62,7 +64,19 @@ func NewAnalyzer(settings Settings) *analysis.Analyzer {
|
||||
return
|
||||
}
|
||||
|
||||
pass.Reportf(node.Pos(), "HTTP status code %d should use its integer literal", code)
|
||||
pass.Report(analysis.Diagnostic{
|
||||
Pos: node.Pos(),
|
||||
End: node.End(),
|
||||
Message: fmt.Sprintf("HTTP status code %d should use its integer literal", code),
|
||||
SuggestedFixes: []analysis.SuggestedFix{{
|
||||
Message: "Use the integer literal",
|
||||
TextEdits: []analysis.TextEdit{{
|
||||
Pos: node.Pos(),
|
||||
End: node.End(),
|
||||
NewText: []byte(strconv.Itoa(code)),
|
||||
}},
|
||||
}},
|
||||
})
|
||||
}
|
||||
|
||||
// Disallows sending non-typical response statuses
|
||||
|
||||
Reference in New Issue
Block a user