Declaration specifier repeated on the same declaration

ID

objectivec.correctness.redundant_declaration_specifier

Severity

info

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Declaration

Language

Objective-C

Description

Reports a declaration specifier written twice in a row - static static, const const, volatile volatile and the like. The legitimate repeated type keywords long long and short short are not reported.

Rationale

A repeated specifier says nothing the single one did not. It is a duplicate rather than an error, so the compiler accepts it in C and only warns under the stricter language modes, and the redundancy survives every review that reads past it. Almost always it is the residue of a bad merge or a half-finished edit, and what makes it worth reporting is that the intended second specifier - the const in static const, the volatile in static volatile - was quietly lost in the same edit, leaving a declaration that compiles but no longer means what the author wrote.

The following code illustrates the pattern detected by this rule:

// FLAGGED: Declaration specifier repeated on the same declaration
static static NSInteger gCallCount = 0;

Remediation

Delete the duplicate. Then check the surrounding history for what the second specifier was meant to be: a declaration that reads static static was very likely static const or static volatile before the edit that duplicated it.

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved