protolint
protolint copied to clipboard
OneOf fields aren't linted
While writing a custom rule FIELD_NAMES_CAMEL_CASE
I discovered that oneof
fields are not linted by the rule FIELD_NAMES_LOWER_SNAKE_CASE
or FIELDS_HAVE_COMMENT
.
For example, if you have;
syntax = "proto3";
message Foo {
oneof MyField {
string eggs = 1;
string sausage = 2;
}
}
This will pass linting even with the FIELD_NAMES_LOWER_SNAKE_CASE
and/or FIELDS_HAVE_COMMENT
enabled - when I'd expect it to complain about the MyField
not being lower snake case and/or containing a comment.
Am I correct in thinking this is how it should behave or is that not the intended behaviour? It looks as if that's how it should behave.
@alexhayes Thank you for reaching out.
I discovered that oneof fields are not linted by the rule
Oneof fields are string eggs = 1;
and string sausage = 2;,
not oneof MyField { }.
Style Guide mentions oneof field,
but not oneof (name).
Regardless of that, your suggestion might be appropriate as Language Guide uses underscore_separated_names for oneof name. And it makes sense that protolint needs to provide a way to complain about the MyField
not containing a comment at least.
Meanwhile, I'm not sure oneof (not oneof fields)
should be dealt with as fields.
What do you think?
- See oneof test_oneof