Skip to content

Commit

Permalink
fix: Use more specific locations for AIP-132, AIP-140, AIP-231, AIP-235
Browse files Browse the repository at this point in the history
… (#802)
  • Loading branch information
apasel422 authored Mar 22, 2021
1 parent 0d6dccb commit c18f315
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rules/aip0132/request_parent_valid_reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"strings"

"github.com/googleapis/api-linter/lint"
"github.com/googleapis/api-linter/locations"
"github.com/googleapis/api-linter/rules/internal/utils"
"github.com/jhump/protoreflect/desc"
)
Expand Down Expand Up @@ -49,6 +50,7 @@ var requestParentValidReference = &lint.FieldRule{
return []lint.Problem{{
Message: fmt.Sprintf("The `google.api.resource_reference` on `%s` field should reference the parent(s) of `%s`.", f.GetName(), res),
Descriptor: f,
Location: locations.FieldResourceReference(f),
}}
}
}
Expand Down
2 changes: 2 additions & 0 deletions rules/aip0140/lower_snake.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"fmt"

"github.com/googleapis/api-linter/lint"
"github.com/googleapis/api-linter/locations"
"github.com/jhump/protoreflect/desc"
)

Expand All @@ -30,6 +31,7 @@ var lowerSnake = &lint.FieldRule{
Message: fmt.Sprintf("Field `%s` must use lower_snake_case.", got),
Suggestion: want,
Descriptor: f,
Location: locations.DescriptorName(f),
}}
}
return nil
Expand Down
2 changes: 2 additions & 0 deletions rules/aip0140/reserved_words.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

"bitbucket.org/creachadair/stringset"
"github.com/googleapis/api-linter/lint"
"github.com/googleapis/api-linter/locations"
"github.com/jhump/protoreflect/desc"
)

Expand All @@ -29,6 +30,7 @@ var reservedWords = &lint.FieldRule{
return []lint.Problem{{
Message: fmt.Sprintf("%q is a reserved word in a common language and should not be used.", name),
Descriptor: f,
Location: locations.DescriptorName(f),
}}
}
return nil
Expand Down
2 changes: 2 additions & 0 deletions rules/aip0231/plural_method_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

"github.com/gertd/go-pluralize"
"github.com/googleapis/api-linter/lint"
"github.com/googleapis/api-linter/locations"
"github.com/jhump/protoreflect/desc"
)

Expand All @@ -40,6 +41,7 @@ var pluralMethodResourceName = &lint.MethodRule{
m.GetName(), pluralMethodResourceName, pluralize.Plural(pluralMethodResourceName),
),
Descriptor: m,
Location: locations.DescriptorName(m),
}}
}

Expand Down
1 change: 1 addition & 0 deletions rules/aip0231/request_names_field.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ var namesField = &lint.MessageRule{
problems = append(problems, lint.Problem{
Message: fmt.Sprintf(`The "requests" field on Batch Get Request should be a %q type`, rightTypeName),
Descriptor: getReqMsg,
Location: locations.FieldType(getReqMsg),
})
}
return
Expand Down
1 change: 1 addition & 0 deletions rules/aip0235/request_names_field.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ var requestNamesField = &lint.MessageRule{
problems = append(problems, lint.Problem{
Message: fmt.Sprintf(`The "requests" field on Batch Delete Request should be a %q type`, rightTypeName),
Descriptor: deleteReqMsg,
Location: locations.FieldType(deleteReqMsg),
})
}
return
Expand Down

0 comments on commit c18f315

Please sign in to comment.