Skip to content

codecompliance: check spaces around compound/comparison operators#1805

Open
nickk02 wants to merge 1 commit into
SFTtech:masterfrom
nickk02:fix/cppstyle-spaced-operators
Open

codecompliance: check spaces around compound/comparison operators#1805
nickk02 wants to merge 1 commit into
SFTtech:masterfrom
nickk02:fix/cppstyle-spaced-operators

Conversation

@nickk02
Copy link
Copy Markdown
Contributor

@nickk02 nickk02 commented May 30, 2026

Merge Checklist

cppstyle.py flags a handful of C++ spacing slips but not missing spaces around the compound-assignment and comparison operators (+=, ==, <=, and friends), which is what #837 asks for. This adds that check.

The operators overlap, so a naive scan false-matches: >= sits inside >>=, <= inside <<= and the C++20 <=> spaceship. The regex uses lookbehind/lookahead to only catch the standalone forms. Comments and string literals are blanked before checking, and operator-overload declarations are skipped, so // a==b, "x==y" and bool operator==(...) don't trip it.

Ran it across libopenage and it's zero hits, the tree already complies, so this is purely additive. Spot-checked that it does flag a==b, y+=2, c <=d and leaves >>=, <=>, operator==, comments and strings alone.

Closes #837.

cppstyle.py already flags a few C++ spacing slips but not missing spaces
around the compound-assignment and comparison operators (+=, ==, <=, and
friends), which SFTtech#837 asks for. Add a check for them.

The operators overlap, so a naive scan false-matches: >= sits inside
>>=, <= inside <<= and the C++20 <=> spaceship. The regex uses
lookbehind/lookahead to only match the standalone forms. Comments and
string literals are blanked before checking, and operator-overload
declarations (operator==, etc.) are skipped, so things like `// a==b`,
`"x==y"` and `bool operator==(...)` don't trip it.

The existing tree already passes the new check (zero hits across
libopenage), so this is purely additive.

Closes SFTtech#837.
@nickk02 nickk02 force-pushed the fix/cppstyle-spaced-operators branch from 6f0ad9f to e742b9e Compare June 6, 2026 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ensure spaces around operators

1 participant