Skip to content

Commit a763909

Browse files
author
thk123
committed
Commented out some false positive tests
These were causing a bunch of false positives that were making it hard to find real errors. Until there is time to fix them, just disable them. Issues associated area: https://github.com/diffblue/cbmc-testgen/issues/76 Multi line template types are compaining about spaces around < https://github.com/diffblue/cbmc-testgen/issues/75 Open parentheses inside strings were reporting errors about parameters being spread across multiple lines https://github.com/diffblue/cbmc-testgen/issues/49 Errors related to final bracket needs to be on the same line as the final are being wrongly reported.
1 parent 2ff33ef commit a763909

File tree

1 file changed

+84
-84
lines changed

1 file changed

+84
-84
lines changed

scripts/cpplint.py

+84-84
Original file line numberDiff line numberDiff line change
@@ -3556,30 +3556,30 @@ def CheckOperatorSpacing(filename, clean_lines, linenum, error):
35563556
operator_pos, op_end = left_hand_space_match.span(1) if left_hand_space_match else (-1, -1)
35573557
operator_pos2, op_end2 = right_hand_space_match.span(1) if right_hand_space_match else (-1, -1)
35583558

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)):
35653565
# and not Search(r'\b(if|while|for) ', line)
35663566
# # Operators taken from [lex.operators] in C++11 standard.
35673567
# and not Search(r'(>=|<=|==|!=|&=|\^=|\|=|\+=|\*=|\/=|\%=)', line)
35683568
# and not Search(r'operator=', line)):
3569-
error(filename, linenum, 'whitespace/operators', 4,
3569+
# error(filename, linenum, 'whitespace/operators', 4,
35703570
# '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))
35773577

35783578
# 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))
35833583

35843584
# check any inherited classes don't have a space between the type and the :
35853585
if Search(r'(struct|class)\s[\w_]*\s+:', line):
@@ -4078,9 +4078,9 @@ def CheckBraces(filename, clean_lines, linenum, error):
40784078
if Search(r'else if\(.*\)\s*{?\s*.+;', line):
40794079
error(filename, linenum, 'readability/braces', 5,
40804080
'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')
40844084

40854085
# In the same way, a do/while should never be on one line
40864086
if Match(r'\s*do [^\s{]', line):
@@ -4697,72 +4697,72 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state,
46974697
# - ignore the line if it is a for/if etc since rules are different
46984698

46994699
# 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.')
47614761

47624762

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')
47664766

47674767
# Check if the line is a header guard.
47684768
is_header_guard = False

0 commit comments

Comments
 (0)