field-not-required
What it does
Section titled “What it does”Reports a proto2 required field.
Why it matters
Section titled “Why it matters”A required field can never be removed or made optional without breaking every reader and writer that was built before the change: an old reader rejects messages without it. Protobuf’s own advice is to avoid required.
To fix, make it optional and check for it in the code.
Example
Section titled “Example”...
message Old { required string name = 1;}Configuration
Section titled “Configuration”protobuf: lint: rules: field-not-required: warn # off (default), warn, errorEnabled by the presets: protobuf/buf-standard.
Suppress one line with sudsy-disable-next-line field-not-required in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| buf | FIELD_NOT_REQUIRED |
full |