Skip to content

AEP-0141 Linter Rules

Count suffix

Count suffix

This rule tries to enforce that discrete quantities have consistent field names ending in _count, as mandated in AEP-141.

Details

This rule scans all fields and complains if it sees a num_ prefix, and suggests a _count suffix instead.

Examples

Incorrect code for this rule:

// Incorrect.
message Book {
string path = 1;
int32 num_pages = 2; // Should be `page_count`.
}

Correct code for this rule:

// Correct.
message Book {
string path = 1;
int32 page_count = 2;
}

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.

// (-- api-linter: core::0141::count-suffix=disabled
// aep.dev/not-precedent: We need to do this because reasons. --)
message Book {
string path = 1;
int32 num_pages = 2;
}

If you need to violate this rule for an entire file, place the comment at the top of the file.

Forbidden types

Forbidden types

This rule enforces that fields do not use unsigned integer types (because many programming languages and systems do not support them well), as mandated in AEP-141.

Details

This rule scans all fields and complains if it sees any of the following types:

  • fixed32
  • fixed64
  • uint32
  • uint64

It suggests use of int32 or int64 instead.

Examples

Incorrect code for this rule:

// Incorrect.
message Book {
string path = 1;
uint32 page_count = 2; // Should be `int32`.
}

Correct code for this rule:

// Correct.
message Book {
string path = 1;
int32 page_count = 2;
}

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.

message Book {
string path = 1;
// (-- api-linter: core::0141::forbidden-types=disabled
// aep.dev/not-precedent: We need to do this because reasons. --)
uint32 page_count = 2;
}

If you need to violate this rule for an entire file, place the comment at the top of the file.