@InvocableMethod without label and description

ID

apex.maintainability.invocablemethod_label_description

Severity

info

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Api Design

Language

Apex

Description

Reports an @InvocableMethod annotation that carries neither a label nor a description, or only one of the two.

Rationale

The label and description are the whole interface Flow Builder shows: without a label the action appears under its raw method name, and without a description the admin choosing it has nothing to tell it apart from the other actions the org exposes. That admin usually cannot read the Apex, so the annotation is the only documentation that reaches them - and a mislabelled action wired into a live flow is a defect nobody sees in a code review.

The following code illustrates the pattern detected by this rule:

public class RenewalActions {

    // FLAGGED: @InvocableMethod without label and description
    @InvocableMethod
    public static void createRenewal(List<Id> accountIds) {
        System.debug(accountIds);
    }

    // FLAGGED: @InvocableMethod without label and description
    @InvocableMethod(label='Create Renewal')
    public static void createRenewalLabelled(List<Id> accountIds) {
        System.debug(accountIds);
    }

    @InvocableMethod(label='Create Renewal' description='Creates a renewal opportunity for each account.')
    public static void createRenewalDocumented(List<Id> accountIds) {
        System.debug(accountIds);
    }
}

Remediation

Give the annotation both attributes, e.g. @InvocableMethod(label='Create Renewal Opportunity' description='Creates a renewal opportunity for each account passed in.'). Write them for the admin, not for the developer.

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved