Skip to content

[apex] New Rule: AnnotationsNamingConventions #5650

@mitchspano

Description

@mitchspano

Proposed Rule Name: AnnotationsNamingConventions

Proposed Category: Code Style

Description: This rule enforces that Apex annotations should be written in PascalCase. Apex, while case-insensitive, benefits from a consistent code style to improve readability and maintainability. Enforcing PascalCase for annotations aligns with the established convention for classes and methods, reducing ambiguity and promoting a unified coding standard. Furthermore, Apex currently does not support custom annotations; therefore, the set of allowable annotations is fixed and known at compile time, ensuring that this rule can always be reliably checked.

The current set of permitted annotations is published here.

Code Sample:

// Incorrect:
@istest
private static void fooShouldBar() {
  //...
}

// Correct:
@IsTest
private static void fooShouldBar() {
  //...
}

//Incorrect:
@testvisible
private boolean doSomething = false;


//Correct:
@TestVisible
private boolean doSomething = false;

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:new-ruleProposal to add a new built-in rule

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions