codecompliance: check spaces around compound/comparison operators#1805
Open
nicolassanchez02 wants to merge 1 commit into
Open
codecompliance: check spaces around compound/comparison operators#1805nicolassanchez02 wants to merge 1 commit into
nicolassanchez02 wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merge Checklist
make checkmergecppstyle.pyflags 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"andbool 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 <=dand leaves>>=,<=>,operator==, comments and strings alone.Closes #837.