Skip to content

Commit 648116c

Browse files
author
thk123
committed
Require a word character immediately before space
Modified the inital regex to require a word character immediately (except spaces) before the bracket. This ensures we are not just a order of operations bracket but in fact a function call. Added a regression test that checks the case that this is required for
1 parent 3c48404 commit 648116c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

regression/cpp-linter/multi-line-function-call3/main.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,12 @@ static void fun()
4444
{
4545
do_something();
4646
}
47+
48+
// Correct since if statement
49+
if(condition_a&&
50+
(condition_b||
51+
condition_c))
52+
{
53+
do_something();
54+
}
4755
}

scripts/cpplint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4696,7 +4696,7 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state,
46964696
# - ignore the line if it is a for/if etc since rules are different
46974697

46984698
# Look for an opening bracket that doesn't have a semi-colon on the same line
4699-
bracket_search = Search(r'(?P<bracket>\()[^;]*$', elided_line)
4699+
bracket_search = Search(r'[\w_]+\s*(?P<bracket>\()[^;]*$', elided_line)
47004700

47014701
# Exclude the check if any of these keywords are present
47024702
# They could trip us up as they have different formatting rules to functions

0 commit comments

Comments
 (0)