Field names: Prepositions

This rule enforces that field names do not include most prepositions, as mandated in [AIP-140][].

Details

This rule looks at each field and complains if it sees any of the following words in the method’s name:

  • after
  • at
  • before
  • between
  • but
  • by
  • except
  • for
  • from
  • in
  • including
  • into
  • of
  • over
  • since
  • to
  • toward
  • under
  • upon
  • with
  • within
  • without

Note: The standard fields order_by and group_by are permitted.

Examples

Incorrect code for this rule:

// Incorrect.
message Book {
  string name = 1;
  string written_by = 2;  // Should be `author`.
}

Correct code for this rule:

// Correct.
message Book {
  string name = 1;
  string author = 2;
}

Disabling

If you need to violate this rule, use a leading comment above the field. Remember to also include an aip.dev/not-precedent comment explaining why.

// (-- api-linter: core::0140::prepositions=disabled
//     aip.dev/not-precedent: We need to do this because reasons. --)
message Book {
  string name = 1;
  string written_by = 2;
}

If you need to violate this rule for an entire file, place the comment at the top of the file.