@@ -3556,30 +3556,30 @@ def CheckOperatorSpacing(filename, clean_lines, linenum, error):
3556
3556
operator_pos , op_end = left_hand_space_match .span (1 ) if left_hand_space_match else (- 1 , - 1 )
3557
3557
operator_pos2 , op_end2 = right_hand_space_match .span (1 ) if right_hand_space_match else (- 1 , - 1 )
3558
3558
3559
- if (left_hand_space_match and
3560
- not Search (r'<<' , line ) and # We ignore the left shift operator since might be a stream and then formatting rules go out of the window
3561
- not Search (r'char \*' , line ) and # I don't know why this exception exists?
3562
- not Search (r'\#include' , line ) and # I suppose file names could contains operators??
3563
- #not Search(r'<.*[^\s]>', line)): # This checks for template declarations (providing they don't run onto next line)
3564
- not IsTemplateArgumentList_DB (clean_lines , linenum , operator_pos )):
3559
+ # if (left_hand_space_match and
3560
+ # not Search(r'<<', line) and # We ignore the left shift operator since might be a stream and then formatting rules go out of the window
3561
+ # not Search(r'char \*', line) and # I don't know why this exception exists?
3562
+ # not Search(r'\#include', line) and # I suppose file names could contains operators??
3563
+ # #not Search(r'<.*[^\s]>', line)): # This checks for template declarations (providing they don't run onto next line)
3564
+ # not IsTemplateArgumentList_DB(clean_lines, linenum, operator_pos)):
3565
3565
# and not Search(r'\b(if|while|for) ', line)
3566
3566
# # Operators taken from [lex.operators] in C++11 standard.
3567
3567
# and not Search(r'(>=|<=|==|!=|&=|\^=|\|=|\+=|\*=|\/=|\%=)', line)
3568
3568
# and not Search(r'operator=', line)):
3569
- error (filename , linenum , 'whitespace/operators' , 4 ,
3569
+ # error(filename, linenum, 'whitespace/operators', 4,
3570
3570
# 'Missing spaces around =')
3571
- 'Remove spaces around %s' % left_hand_space_match .group (1 ))
3572
- elif (right_hand_space_match and
3573
- not Search (r'<<' , line ) and
3574
- not IsTemplateArgumentList_DB (clean_lines , linenum , operator_pos2 )):
3575
- error (filename , linenum , 'whitespace/operators' , 4 ,
3576
- 'Remove spaces around %s' % right_hand_space_match .group (0 ))
3571
+ # 'Remove spaces around %s' % left_hand_space_match.group(1))
3572
+ # elif (right_hand_space_match and
3573
+ # not Search(r'<<', line) and
3574
+ # not IsTemplateArgumentList_DB(clean_lines, linenum, operator_pos2)):
3575
+ # error(filename, linenum, 'whitespace/operators', 4,
3576
+ # 'Remove spaces around %s' % right_hand_space_match.group(0))
3577
3577
3578
3578
# these would cause too many false alarms if we checked for one-sided spaces only
3579
- match = Search (r'\s(-|\*)(\s|$)' , line )
3580
- if match :
3581
- error (filename , linenum , 'readability/identifiers' , 4 ,
3582
- 'Remove spaces around %s' % match .group (0 ))
3579
+ # match = Search(r'\s(-|\*)(\s|$)', line)
3580
+ # if match:
3581
+ # error(filename, linenum, 'readability/identifiers', 4,
3582
+ # 'Remove spaces around %s' % match.group(0))
3583
3583
3584
3584
# check any inherited classes don't have a space between the type and the :
3585
3585
if Search (r'(struct|class)\s[\w_]*\s+:' , line ):
@@ -4078,9 +4078,9 @@ def CheckBraces(filename, clean_lines, linenum, error):
4078
4078
if Search (r'else if\(.*\)\s*{?\s*.+;' , line ):
4079
4079
error (filename , linenum , 'readability/braces' , 5 ,
4080
4080
'Statement after else if should be on a new line' )
4081
- elif Search (r'else\s*{?\s*.+;' , line ):
4082
- error (filename , linenum , 'readability/braces' , 5 ,
4083
- 'Statement after else should be on a new line' )
4081
+ # elif Search(r'else\s*{?\s*.+;', line):
4082
+ # error(filename, linenum, 'readability/braces', 5,
4083
+ # 'Statement after else should be on a new line')
4084
4084
4085
4085
# In the same way, a do/while should never be on one line
4086
4086
if Match (r'\s*do [^\s{]' , line ):
@@ -4697,72 +4697,72 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state,
4697
4697
# - ignore the line if it is a for/if etc since rules are different
4698
4698
4699
4699
# Look for an opening bracket that doesn't have a semi-colon on the same line
4700
- bracket_search = Search (r'[\w_]+\s*(?P<bracket>\()[^;]*$' , elided_line )
4701
-
4702
- # Exclude the check if any of these keywords are present
4703
- # They could trip us up as they have different formatting rules to functions
4704
- keyword_search = Search (r'\b(if|for|while|catch|switch)\b' , elided_line )
4705
-
4706
- if bracket_search and not keyword_search :
4707
- open_bracket_pos = bracket_search .start ('bracket' )
4708
- close_line , close_linenum , close_pos = CloseExpression (clean_lines , linenum , open_bracket_pos )
4709
- if close_pos != - 1 :
4710
- # If the closing line is different from the opening line we need to
4711
- # verify that each of the parameters are on separate lines
4712
- if close_linenum != linenum :
4713
- # The first line needs to have no parameters on it
4714
- if (Search (r'\(+[^\(]+' , elided_line )):
4715
- error (filename , linenum , 'whitespace/indent' , 4 ,
4716
- 'If parameters or arguments require a line break, each parameter should be put on its own line.' )
4717
-
4718
- # For each line afer we need to verify it consists of exactly one parameter
4719
- # Except if we find an opening bracket - in this case we ignore everything until the closing
4720
- # bracket (any errors within these brackets will be picked up when we check this line)
4721
- start_linenum = linenum + 1
4722
- while (start_linenum < close_linenum ):
4723
- arg_line = clean_lines .elided [start_linenum ]
4724
- nested_bracket_search = Search ('\(' , arg_line )
4725
- if nested_bracket_search :
4726
- nested_open_bracket_pos = nested_bracket_search .start ()
4727
- # Just because we are calling a nested function doesn't mean
4728
- # we allow multiple parameters on the line
4729
- if (Search (',' , arg_line [:nested_open_bracket_pos ])):
4730
- error (filename , start_linenum , 'whitespace/indent' , 4 ,
4731
- 'If parameters or arguments require a line break, each parameter should be put on its own line.' )
4732
-
4733
- nested_close_line , nested_close_linenum , _ = CloseExpression (clean_lines , start_linenum , nested_open_bracket_pos )
4734
-
4735
- # If anything other closing statements or commas appear there is another parameter after the nested call
4736
- if not Search (r'\)(,|\)|;)*' , nested_close_line ):
4737
- error (filename , start_linenum , 'whitespace/indent' , 4 ,
4738
- 'If parameters or arguments require a line break, each parameter should be put on its own line.' )
4739
- # Skip to the end of the bracket
4740
- start_linenum = nested_close_linenum
4741
- else :
4742
- if (not Match ('^\s*[^,]+,$' , arg_line )):
4743
- error (filename , start_linenum , 'whitespace/indent' , 4 ,
4744
- 'If parameters or arguments require a line break, each parameter should be put on its own line.' )
4745
-
4746
- start_linenum += 1
4747
- # For the final line we also need to check one parameter on it
4748
- # e.g. we require bracket on same line as last parameter
4749
- # foo(
4750
- # x);
4751
- if not Search (r'^\s*[^,]+\)' , close_line ):
4752
- # If this is true, the we failed because we just had the close bracket
4753
- if Search (r'[^,]*\)' , close_line ):
4754
- error (filename , close_linenum , 'whitespace/indent' , 4 ,
4755
- 'If parameters or arguments require a line break, the closing bracket should be on the same line as the final parameter' )
4756
- else :
4757
- # In this case the problem is we had a bracket
4758
- # i.e. more than one parameter on the last line
4759
- error (filename , close_linenum , 'whitespace/indent' , 4 ,
4760
- 'If parameters or arguments require a line break, each parameter should be put on its own line.' )
4700
+ # bracket_search = Search(r'[\w_]+\s*(?P<bracket>\()[^;]*$', elided_line)
4701
+ #
4702
+ # # Exclude the check if any of these keywords are present
4703
+ # # They could trip us up as they have different formatting rules to functions
4704
+ # keyword_search = Search(r'\b(if|for|while|catch|switch)\b', elided_line)
4705
+ #
4706
+ # if bracket_search and not keyword_search:
4707
+ # open_bracket_pos = bracket_search.start('bracket')
4708
+ # close_line, close_linenum, close_pos = CloseExpression(clean_lines, linenum, open_bracket_pos)
4709
+ # if close_pos != -1:
4710
+ # # If the closing line is different from the opening line we need to
4711
+ # # verify that each of the parameters are on separate lines
4712
+ # if close_linenum != linenum:
4713
+ # # The first line needs to have no parameters on it
4714
+ # if(Search(r'\(+[^\(]+', elided_line)):
4715
+ # error(filename, linenum, 'whitespace/indent', 4,
4716
+ # 'If parameters or arguments require a line break, each parameter should be put on its own line.')
4717
+ #
4718
+ # # For each line afer we need to verify it consists of exactly one parameter
4719
+ # # Except if we find an opening bracket - in this case we ignore everything until the closing
4720
+ # # bracket (any errors within these brackets will be picked up when we check this line)
4721
+ # start_linenum = linenum + 1
4722
+ # while(start_linenum < close_linenum):
4723
+ # arg_line = clean_lines.elided[start_linenum]
4724
+ # nested_bracket_search = Search('\(', arg_line)
4725
+ # if nested_bracket_search:
4726
+ # nested_open_bracket_pos = nested_bracket_search.start()
4727
+ # # Just because we are calling a nested function doesn't mean
4728
+ # # we allow multiple parameters on the line
4729
+ # if(Search(',', arg_line[:nested_open_bracket_pos])):
4730
+ # error(filename, start_linenum, 'whitespace/indent', 4,
4731
+ # 'If parameters or arguments require a line break, each parameter should be put on its own line.')
4732
+ #
4733
+ # nested_close_line, nested_close_linenum, _ = CloseExpression(clean_lines, start_linenum, nested_open_bracket_pos)
4734
+ #
4735
+ # # If anything other closing statements or commas appear there is another parameter after the nested call
4736
+ # if not Search(r'\)(,|\)|;)*', nested_close_line):
4737
+ # error(filename, start_linenum, 'whitespace/indent', 4,
4738
+ # 'If parameters or arguments require a line break, each parameter should be put on its own line.')
4739
+ # # Skip to the end of the bracket
4740
+ # start_linenum = nested_close_linenum
4741
+ # else:
4742
+ # if(not Match('^\s*[^,]+,$', arg_line)):
4743
+ # error(filename, start_linenum, 'whitespace/indent', 4,
4744
+ # 'If parameters or arguments require a line break, each parameter should be put on its own line.')
4745
+ #
4746
+ # start_linenum+=1
4747
+ # # For the final line we also need to check one parameter on it
4748
+ # # e.g. we require bracket on same line as last parameter
4749
+ # # foo(
4750
+ # # x);
4751
+ # if not Search(r'^\s*[^,]+\)', close_line):
4752
+ # # If this is true, the we failed because we just had the close bracket
4753
+ # if Search(r'[^,]*\)', close_line):
4754
+ # error(filename, close_linenum, 'whitespace/indent', 4,
4755
+ # 'If parameters or arguments require a line break, the closing bracket should be on the same line as the final parameter')
4756
+ # else:
4757
+ # # In this case the problem is we had a bracket
4758
+ # # i.e. more than one parameter on the last line
4759
+ # error(filename, close_linenum, 'whitespace/indent', 4,
4760
+ # 'If parameters or arguments require a line break, each parameter should be put on its own line.')
4761
4761
4762
4762
4763
- if (Search (r'\([^\)]*$' , elided_prev ) and initial_spaces - 2 != prev_initial_spaces ) and not Search (r'for|while|if|;' , elided_prev ):
4764
- error (filename , linenum , 'whitespace/indent' , 4 ,
4765
- 'Indent of wrapped parenthesized expression or parameter or argument list should be 2' )
4763
+ # if (Search(r'\([^\)]*$', elided_prev) and initial_spaces-2 != prev_initial_spaces) and not Search(r'for|while|if|;', elided_prev):
4764
+ # error(filename, linenum, 'whitespace/indent', 4,
4765
+ # 'Indent of wrapped parenthesized expression or parameter or argument list should be 2')
4766
4766
4767
4767
# Check if the line is a header guard.
4768
4768
is_header_guard = False
0 commit comments