Redundant return at the end of a method

ID

objectivec.maintainability.omit_redundant_control_flow

Severity

info

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Control Flow

Language

Objective-C

Description

Reports a bare return; written as the last statement of a method or of a C function, i.e. immediately above the closing brace in column zero. A return; used as a guard inside an if, and a return that carries a value, are not reported.

Rationale

Control already leaves the method at the closing brace, so the statement says nothing the brace below it does not. It reads as if something were being skipped — a reader has to look for the code it jumps over before concluding there is none — and when a statement is later appended to the method it lands after the return and never runs.

The following code illustrates the pattern detected by this rule:

static void xy_reset(int *counter) {
    *counter = 0;
    // FLAGGED: Redundant return at the end of a method
    return;
}

Remediation

Delete the statement. If it was marking the end of a long method, a shorter method or a comment says that without adding an unreachable jump.

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved