AEP-0140 Linter Rules
Field names- Abbreviations
Field names: Abbreviations
This rule enforces that field names use common abbreviations, as mandated in AEP-140.
Details
This rule checks every descriptor in the proto and complains if the long form of any of the following words are used instead of the abbreviation:
- configuration
- identifier
- information
- specification
- statistics
Examples
Single word method
Incorrect code for this rule:
Correct code for this rule:
Disabling
If you need to violate this rule, use a leading comment above the method. Remember to also include an aep.dev/not-precedent comment explaining why.
If you need to violate this rule for an entire file, place the comment at the top of the file.
Base64 fields
Base64 fields
This rule tries to enforce that base64 fields use the bytes
type, as mandated
by AEP-140.
Details
This rule checks the comments over each field, and if “base64” is mentioned, and yet
the field is a string
, it suggests using bytes
instead.
Examples
Single word method
Incorrect code for this rule:
Correct code for this rule:
Disabling
If you need to violate this rule, use a leading comment above the method. Remember to also include an aep.dev/not-precedent comment explaining why.
If you need to violate this rule for an entire file, place the comment at the top of the file.
Field names- Lower Snake Case
Field names: Lower Snake Case
This rule enforces that field names use snake_case
, as mandated in
AEP-140.
Details
This rule checks every field in the proto and complains if the field name contains a capital letter.
Examples
Single word method
Incorrect code for this rule:
Correct code for this rule:
Disabling
If you need to violate this rule, use a leading comment above the method. Remember to also include an aep.dev/not-precedent comment explaining why.
If you need to violate this rule for an entire file, place the comment at the top of the file.
Field names- Numbers
Field names: Numbers
This rule enforces that field names do not begin any word in the field with a number, as mandated in AEP-140.
Details
This rule checks every field in the proto and complains if any individual word
begins with a number. It treats the underscore (_
) character as the only word
separator for this purpose.
Examples
Incorrect code for this rule:
Correct code for this rule:
The correct code here is likely to vary based on the situation. This may be fixed by spelling out the number:
Many cases we see involving numbers like this may be better designed with a map:
Disabling
If you need to violate this rule, use a leading comment above the method. Remember to also include an aep.dev/not-precedent comment explaining why.
If you need to violate this rule for an entire file, place the comment at the top of the file.
Field names- Prepositions
Field names: Prepositions
This rule enforces that field names do not include most prepositions, as mandated in AEP-140.
Details
This rule looks at each field and complains if it sees any of the following words in the method’s name:
{% include prepositions.md %}
Note: The standard fields order_by
and group_by
are permitted.
Examples
Incorrect code for this rule:
Correct code for this rule:
Disabling
If you need to violate this rule, use a leading comment above the field. Remember to also include an aep.dev/not-precedent comment explaining why.
If you need to violate this rule for an entire file, place the comment at the top of the file.
Field names- Reserved words
Field names: Reserved words
This rule enforces that field names are not reserved words, as mandated in AEP-140.
Details
This rule looks at each field and complains if it the name is a reserved word in a common programming lanaguge.
Currently, the linter checks all the reserved words in Java, JavaScript, and Python 3. The exhaustive list of reserved words is found in the code.
Note: Reserved words in Golang are permitted because Golang’s variable casing rules avoids a conflict.
Examples
Incorrect code for this rule:
Correct code for this rule:
Disabling
If you need to violate this rule, use a leading comment above the field. Remember to also include an aep.dev/not-precedent comment explaining why.
If you need to violate this rule for an entire file, place the comment at the top of the file.
Field names- Underscores
Field names: Underscores
This rule enforces that field names do not use leading, trailing, or adjacent underscores, as mandated in AEP-140.
Details
This rule checks every field in the proto and complains if it sees leading or trailing underscores, or two or more underscores with nothing in between them.
Examples
Incorrect code for this rule:
Correct code for this rule:
Disabling
If you need to violate this rule, use a leading comment above the method. Remember to also include an aep.dev/not-precedent comment explaining why.
Warning: Violating this rule is likely to run into tooling failures.
If you need to violate this rule for an entire file, place the comment at the top of the file.
Field names- URIs
Field names: URIs
This rule enforces that field names use uri
rather than url
, as mandated in
AEP-140.
Details
This rule checks every field in the proto and complains if the field name
includes url
. (It splits on _
to avoid false positives.)
Examples
Incorrect code for this rule:
Correct code for this rule:
Disabling
If you need to violate this rule, use a leading comment above the method. Remember to also include an aep.dev/not-precedent comment explaining why.
If you need to violate this rule for an entire file, place the comment at the top of the file.