protolint icon indicating copy to clipboard operation
protolint copied to clipboard

ENUM_FIELD_NAMES_ZERO_VALUE_END_WITH failing even with `allow_alias = true`

Open bjoernmayer opened this issue 1 year ago • 1 comments

ENUM_FIELD_NAMES_ZERO_VALUE_END_WITH does not recognise that an enum already contains an alias for the "ZERO VALUE" that has the required suffix.

It shouldn't fail in that case

enum ProtoSentiment {
        option allow_alias = true;
        PROTO_SENTIMENT_UNSPECIFIED = 0;
        PROTO_SENTIMENT_NEUTRAL = 0;    
        PROTO_SENTIMENT_NEGATIVE = 11;
        PROTO_SENTIMENT_POSITIVE = 1;
}

bjoernmayer avatar Apr 04 '24 09:04 bjoernmayer

When linting the snippet, I got EnumField name "PROTO_SENTIMENT_NEUTRAL" with zero value should have the suffix "UNSPECIFIED". This is valid.

Verifies that the zero value enum should have the suffix (e.g. "UNSPECIFIED", "INVALID"). https://github.com/yoheimuta/protolint?tab=readme-ov-file#rules

The following enum definition is no problem.

enum ProtoSentiment {
        option allow_alias = true;
        PROTO_SENTIMENT_UNSPECIFIED = 0;
        PROTO_SENTIMENT_NEUTRAL = 1;    
        PROTO_SENTIMENT_NEGATIVE = 2;
        PROTO_SENTIMENT_POSITIVE = 3;
}

yoheimuta avatar Apr 06 '24 01:04 yoheimuta