mirror of
https://github.com/valitydev/thriftlint.git
synced 2024-11-06 00:05:20 +00:00
Clean up annotations checker.
This commit is contained in:
parent
8f1bd315f6
commit
5b02983300
@ -10,29 +10,6 @@ import (
|
||||
"github.com/UrbanCompass/thriftlint"
|
||||
)
|
||||
|
||||
// Accepts urls in the form /(<component>|:<var>)+[/]
|
||||
const urlRegex = "(?:/(?:(?:[a-z0-9_]+)|(:[a-zA-Z_][a-zA-Z0-9_]+)))+/?"
|
||||
|
||||
// var (
|
||||
// annotationRegistry = map[reflect.Type]map[string]string{
|
||||
// thriftlint.ServiceType: {
|
||||
// "api.url": urlRegex,
|
||||
// "api.proxy": urlRegex,
|
||||
// "api.test": "^$",
|
||||
// },
|
||||
// thriftlint.MethodType: {
|
||||
// "api.url": urlRegex,
|
||||
// "api.method": "GET|POST|DELETE|PUT",
|
||||
// "api.roles": ".*",
|
||||
// },
|
||||
// // TODO(cameron): Generate the pattern here from api.InjectorMap once it's submitted.
|
||||
// thriftlint.FieldType: {
|
||||
// "api.inject": "^$",
|
||||
// "api.path": "^$",
|
||||
// },
|
||||
// }
|
||||
// )
|
||||
|
||||
type AnnotationPattern struct {
|
||||
//AST nodes this annotation pattern should apply to.
|
||||
Nodes []reflect.Type
|
||||
@ -110,7 +87,7 @@ func (c *annotationsCheck) checker(self interface{}) (messages thriftlint.Messag
|
||||
// Validate `nolint` annotation contains only valid checks to be disabled.
|
||||
for _, annotation := range annotations {
|
||||
if annotation.Name == "nolint" && annotation.Value != "" {
|
||||
lints := strings.Split(annotation.Value, ",")
|
||||
lints := strings.Fields(annotation.Value)
|
||||
for _, l := range lints {
|
||||
if !c.checks.Has(l) {
|
||||
messages.Warning(annotation, "%q is not a known linter check", l)
|
||||
|
@ -23,7 +23,7 @@ func CheckStructFieldOrder() thriftlint.Check {
|
||||
a := fields[i]
|
||||
b := fields[i+1]
|
||||
if a.Pos.Line > b.Pos.Line {
|
||||
messages.Warning(fields[i], "field %d and %d are out of order", a.ID, b.ID)
|
||||
messages.Warning(fields[i], "field %d and %d of %s are out of order", a.ID, b.ID, s.Name)
|
||||
}
|
||||
}
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user