Changeset 165451 in webkit
- Timestamp:
- Mar 11, 2014 7:56:48 AM (10 years ago)
- Location:
- trunk/Tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r165450 r165451 1 2014-03-11 László Langó <llango.u-szeged@partner.samsung.com> 2 3 check-webkit-style failed to complain about missing braces 4 https://bugs.webkit.org/show_bug.cgi?id=34189 5 6 Reviewed by Ryosuke Niwa. 7 8 * Scripts/webkitpy/style/checkers/cpp.py: 9 (check_braces): 10 * Scripts/webkitpy/style/checkers/cpp_unittest.py: 11 (WebKitStyleTest.test_braces): 12 1 13 2014-03-11 László Langó <llango.u-szeged@partner.samsung.com> 2 14 -
trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py
r165450 r165451 2401 2401 error(line_number, 'whitespace/newline', 4, 2402 2402 'do/while clauses should not be on a single line') 2403 2404 # Multi line control clauses should use braces. We check the 2405 # indentation level of the statements. 2406 if (match(r'^\s*\b(if|for|while|else)\b\s', line) 2407 and match(r'.*[^{]$', line) 2408 and len(clean_lines.elided) > line_number + 2): 2409 has_braces = False 2410 begin_line = line 2411 begin_line_number = line_number 2412 while (clean_lines.elided[begin_line_number + 1].strip().startswith("&&") 2413 or clean_lines.elided[begin_line_number + 1].strip().startswith("||") 2414 or search(r'^#\S*', clean_lines.elided[begin_line_number + 1])): 2415 begin_line_number = begin_line_number + 1 2416 begin_line = clean_lines.elided[begin_line_number] 2417 if search(r'.*{$', begin_line): 2418 has_braces = True 2419 2420 next_line = clean_lines.elided[begin_line_number + 1] 2421 after_next_line = clean_lines.elided[begin_line_number + 2] 2422 control_indent = search(r'^(?P<indentation>\s*).*', line).group('indentation') 2423 next_line_indent = search(r'^(?P<indentation>\s*).*', next_line).group('indentation') 2424 after_next_line_indent = search(r'^(?P<indentation>\s*).*', after_next_line).group('indentation') 2425 if (after_next_line != '' 2426 and not has_braces 2427 and control_indent < next_line_indent 2428 and control_indent < after_next_line_indent): 2429 error(line_number, 'whitespace/braces', 4, 'Multi line control clauses should use braces.') 2403 2430 2404 2431 # Braces shouldn't be followed by a ; unless they're defining a struct -
trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
r165450 r165451 4387 4387 '} while (true);\n', 4388 4388 '') 4389 # 5. Multi line control clauses should use braces. 4390 self.assert_multi_line_lint( 4391 'for ( ; c1 && c2 ; )\n' 4392 ' if (condition1 && condition2)\n' 4393 ' i = 1;\n', 4394 'Multi line control clauses should use braces. [whitespace/braces] [4]') 4395 self.assert_multi_line_lint( 4396 ' if (condition)\n' 4397 ' i = 1;\n' 4398 ' j = 1;\n', 4399 'Multi line control clauses should use braces. [whitespace/braces] [4]') 4400 self.assert_multi_line_lint( 4401 ' if (condition1\n' 4402 ' || condition2\n' 4403 ' && condition3)\n' 4404 ' i = 1;\n' 4405 ' j = 1;\n', 4406 'Multi line control clauses should use braces. [whitespace/braces] [4]') 4407 self.assert_multi_line_lint( 4408 ' if (condition1\n' 4409 ' || condition2\n' 4410 ' && condition3) {\n' 4411 ' i = 1;\n' 4412 ' j = 1;\n' 4413 ' }\n', 4414 '') 4415 self.assert_multi_line_lint( 4416 'if (condition)\n' 4417 '#ifdef SOMETHING\n' 4418 ' i = 1;\n' 4419 '#endif\n', 4420 '') 4421 self.assert_multi_line_lint( 4422 '#ifdef SOMETHING\n' 4423 'if (condition)\n' 4424 '#endif\n' 4425 ' // Some comment\n' 4426 ' i = 1;\n', 4427 'Multi line control clauses should use braces. [whitespace/braces] [4]') 4428 self.assert_multi_line_lint( 4429 'if (condition)\n' 4430 ' myFunction(reallyLongParam1, reallyLongParam2, ...\n' 4431 ' reallyLongParam5);\n', 4432 'Multi line control clauses should use braces. [whitespace/braces] [4]') 4433 self.assert_multi_line_lint( 4434 'if (condition) {\n' 4435 ' myFunction(reallyLongParam1, reallyLongParam2, ...\n' 4436 ' reallyLongParam5);\n' 4437 ' }\n', 4438 '') 4389 4439 4390 4440 def test_null_false_zero(self):
Note: See TracChangeset
for help on using the changeset viewer.