Commit 7f237b2
abacus_fixer
fix(code_quality): exclude arrow member access from uppercase constant rule
UPPERCASE_CONST_RE used a (?<![.:]) lookbehind that only excluded the
'.' and ':' member-access prefixes. The '->' (arrow) form of member
access was missing: 'ptr->UPPER_MEMBER' still matched UPPER_MEMBER even
though the semantically equivalent 'obj.MEMBER' and 'Type::MEMBER' were
already excluded. This produced different scores for equivalent code
depending on whether a pointer or a value/member-access was used.
Add '>' to the lookbehind character class so that the character
immediately preceding the identifier is now '.' | ':' | '>'. '>' is a
literal inside a Python regex character class and requires no escaping.
The lookahead (?![.:]) is intentionally left unchanged: the token that
follows an arrow member access is usually ';', '(', '=', or whitespace,
never '.' or ':', so mirroring the '>' there would be dead weight. This
keeps the rule symmetric with how '.' and ':' were already handled
(prefix-only exclusion).
Reproducer fixed:
value = ptr->UPPER_MEMBER;
used to match UPPER_MEMBER (1 deduction); now excluded, matching the
existing behaviour for obj.MEMBER and Type::MEMBER. Real constants
declared on their own line (MY_CONSTANT, GLOBAL_MAX, RED/GREEN/BLUE
enum values, #define FOO macros, function-argument constants such as
func(MAX_VAL)) are still detected.1 parent d1fd9fb commit 7f237b2
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
187 | | - | |
| 187 | + | |
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| |||
0 commit comments