Skip to content

Commit 1aacac7

Browse files
authored
Fix incorrect linting for constexpr if (#190)
cpplint.py didn't know about constexpr if, so the brace linting reports false positives for them. ``` /home/runner/work/allwpilib/allwpilib/wpilibc/src/main/native/cpp/DriverStation.cpp:49: If an else has a brace on one side, it should have it on both [readability/braces] [5] ``` Adding an optional group for "constexpr" fixes the linting.
1 parent b392ae5 commit 1aacac7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

wpiformat/wpiformat/cpplint.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,8 +2248,8 @@ def CheckBraces(filename, clean_lines, linenum, error):
22482248

22492249
# If braces come on one side of an else, they should be on both.
22502250
# However, we have to worry about "else if" that spans multiple lines!
2251-
if Search(r'else if\s*\(', line): # could be multi-line if
2252-
brace_on_left = bool(Search(r'}\s*else if\s*\(', line))
2251+
if Search(r'else if(\s+constexpr)?\s*\(', line): # could be multi-line if
2252+
brace_on_left = bool(Search(r'}\s*else if(\s+constexpr)?\s*\(', line))
22532253
# find the ( after the if
22542254
pos = line.find('else if')
22552255
pos = line.find('(', pos)

0 commit comments

Comments
 (0)