protolint icon indicating copy to clipboard operation
protolint copied to clipboard

Rule for first value of enum should have numeric value zero?

Open jordanbbaker opened this issue 1 year ago • 3 comments

Did I miss this ? Did not see it in the list of rules but I came away from the protobuf.dev best practices guides thinking that is is important.

Do I need to create a custom rule for this?

jordanbbaker avatar Jul 11 '24 18:07 jordanbbaker

@jordanbbaker protolint doesn't have the rule for first value of enum should have numeric value zero.

I understand that proto enums require the first value to be zero, and so the following file cannot be compiled.

syntax = "proto3";
package examplePb;

enum enumAllowingAlias {
    UNKNOWN = 1;
    STARTED = 2;
    RUNNING = 3;
}
$ protoc -I=./ --go_out=./ ./_example/proto/simple.proto
_example/proto/simple.proto:7:15: The first enum value must be zero for open enums.

protolint does not have support for the checks that protoc does.

yoheimuta avatar Jul 13 '24 08:07 yoheimuta

Thanks very much for the detailed response.

It makes sense in the context of the scope of protolint.

The context in my case is in establishing some automated pre-commit hook for protobufs. It sounds like it would be best to use both protolint and protoc to verify the sanity of the committed files.

jordanbbaker avatar Jul 15 '24 14:07 jordanbbaker

I see your point, so I'm willing to accept this feature when someone can prepare for it.

yoheimuta avatar Jul 16 '24 01:07 yoheimuta