Skip to content

codecompliance: check spaces around compound/comparison operators#1805

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

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

Conversation

@nicolassanchez02
Copy link
Copy Markdown
Contributor

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.
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