Skip to content

Commit

Permalink
preserve current behavior: extensions defined inside messages can 'in…
Browse files Browse the repository at this point in the history
…herit' message-wide ignores for the two field-specific rules
  • Loading branch information
jhump committed Apr 26, 2024
1 parent fe0e460 commit 3947adc
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,18 +268,19 @@ func checkEnumZeroValueSuffix(add addFunc, enumValue bufprotosource.EnumValue, s
var CheckFieldLowerSnakeCase = newFieldCheckFunc(checkFieldLowerSnakeCase)

func checkFieldLowerSnakeCase(add addFunc, field bufprotosource.Field) error {
if message := field.ParentMessage(); message != nil && message.IsMapEntry() {
message := field.ParentMessage()
if message != nil && message.IsMapEntry() {
// this check should always pass anyways but just in case
return nil
}
name := field.Name()
expectedName := fieldToLowerSnakeCase(name)
if name != expectedName {
var otherLocs []bufprotosource.Location
if field.Extendee() == "" {
if message != nil {
// also check the message for this comment ignore
// this allows users to set this "globally" for a message
otherLocs = []bufprotosource.Location{field.ParentMessage().Location()}
otherLocs = []bufprotosource.Location{message.Location()}
}
add(
field,
Expand All @@ -300,10 +301,10 @@ func checkFieldNoDescriptor(add addFunc, field bufprotosource.Field) error {
name := field.Name()
if strings.ToLower(strings.Trim(name, "_")) == "descriptor" {
var otherLocs []bufprotosource.Location
if field.Extendee() == "" {
if message := field.ParentMessage(); message != nil {
// also check the message for this comment ignore
// this allows users to set this "globally" for a message
otherLocs = []bufprotosource.Location{field.ParentMessage().Location()}
otherLocs = []bufprotosource.Location{message.Location()}
}
add(
field,
Expand Down

0 comments on commit 3947adc

Please sign in to comment.