+2014-03-11 László Langó <llango.u-szeged@partner.samsung.com>
+
+ Remove Qt cruft from style checker.
+ https://bugs.webkit.org/show_bug.cgi?id=130085
+
+ Reviewed by Csaba Osztrogonác.
+
+ There is no 'foreach' keyword in c++. That was a Qt feature
+ added in: http://trac.webkit.org/changeset/46113
+ Qt was removed from WebKit, so we should remove the checks
+ of this keyword from check-webkit-style scripts.
+
+ * Scripts/webkitpy/style/checkers/cpp.py:
+ (check_spacing_for_function_call):
+ (check_spacing):
+ (check_braces):
+ * Scripts/webkitpy/style/checkers/cpp_unittest.py:
+ (CppStyleTest.test_mismatching_spaces_in_parens):
+ (CppStyleTest.test_spacing_for_fncall):
+ (WebKitStyleTest.test_braces):
+
2014-03-11 Martin Hodovan <mhodovan@inf.u-szeged.hu>
[GTK] update-webkitgtk-libs needs itstool
error: The function to call with any errors found.
"""
- # Since function calls often occur inside if/for/foreach/while/switch
+ # Since function calls often occur inside if/for/while/switch
# expressions - which have their own, more liberal conventions - we
# first see if we should be looking inside such an expression for a
# function call, to which we can apply more strict standards.
function_call = line # if there's no control flow construct, look at whole line
for pattern in (r'\bif\s*\((.*)\)\s*{',
r'\bfor\s*\((.*)\)\s*{',
- r'\bforeach\s*\((.*)\)\s*{',
r'\bwhile\s*\((.*)\)\s*[{;]',
r'\bswitch\s*\((.*)\)\s*{'):
matched = search(pattern, line)
function_call = matched.group(1) # look inside the parens for function calls
break
- # Except in if/for/foreach/while/switch, there should never be space
+ # Except in if/for/while/switch, there should never be space
# immediately inside parens (eg "f( 3, 4 )"). We make an exception
# for nested parens ( (a+b) + c ). Likewise, there should never be
# a space before a ( when it's a function argument. I assume it's a
# Note that we assume the contents of [] to be short enough that
# they'll never need to wrap.
if ( # Ignore control structures.
- not search(r'\b(if|for|foreach|while|switch|return|new|delete)\b', function_call)
+ not search(r'\b(if|for|while|switch|return|new|delete)\b', function_call)
# Ignore pointers/references to functions.
and not search(r' \([^)]+\)\([^)]*(\)|,$)', function_call)
# Ignore pointers/references to arrays.
'Extra space for operator %s' % matched.group(1))
# A pet peeve of mine: no spaces after an if, while, switch, or for
- matched = search(r' (if\(|for\(|foreach\(|while\(|switch\()', line)
+ matched = search(r' (if\(|for\(|while\(|switch\()', line)
if matched:
error(line_number, 'whitespace/parens', 5,
'Missing space before ( in %s' % matched.group(1))
- # For if/for/foreach/while/switch, the left and right parens should be
+ # For if/for/while/switch, the left and right parens should be
# consistent about how many spaces are inside the parens, and
# there should either be zero or one spaces inside the parens.
# We don't want: "if ( foo)" or "if ( foo )".
# Exception: "for ( ; foo; bar)" and "for (foo; bar; )" are allowed.
- matched = search(r'\b(?P<statement>if|for|foreach|while|switch)\s*\((?P<remainder>.*)$', line)
+ matched = search(r'\b(?P<statement>if|for|while|switch)\s*\((?P<remainder>.*)$', line)
if matched:
statement = matched.group('statement')
condition, rest = up_to_unmatched_closing_paren(matched.group('remainder'))
# We also allow '#' for #endif and '=' for array initialization.
previous_line = get_previous_non_blank_line(clean_lines, line_number)[0]
if ((not search(r'[;:}{)=]\s*$|\)\s*((const|override)\s*)?(->\s*\S+)?\s*$', previous_line)
- or search(r'\b(if|for|foreach|while|switch|else|NS_ENUM)\b', previous_line))
+ or search(r'\b(if|for|while|switch|else|NS_ENUM)\b', previous_line))
and previous_line.find('#') < 0):
error(line_number, 'whitespace/braces', 4,
'This { should be at the end of the previous line')
elif (search(r'\)\s*(((const|override)\s*)*\s*)?{\s*$', line)
and line.count('(') == line.count(')')
- and not search(r'\b(if|for|foreach|while|switch|NS_ENUM)\b', line)
+ and not search(r'\b(if|for|while|switch|NS_ENUM)\b', line)
and not match(r'\s+[A-Z_][A-Z_0-9]+\b', line)):
error(line_number, 'whitespace/braces', 4,
'Place brace on its own line for function definitions.')
previous_line = clean_lines.elided[line_number - 2]
last_open_brace = previous_line.rfind('{')
if (last_open_brace != -1 and previous_line.find('}', last_open_brace) == -1
- and search(r'\b(if|for|foreach|while|else)\b', previous_line)):
+ and search(r'\b(if|for|while|else)\b', previous_line)):
error(line_number, 'whitespace/braces', 4,
'One line control clauses should not use braces.')
' [whitespace/parens] [5]')
self.assert_lint('for (foo; bar; ) {', '')
self.assert_lint('for ((foo); (bar); ) {', '')
- self.assert_lint('foreach (foo, foos ) {', 'Extra space before ) in foreach'
- ' [whitespace/parens] [5]')
- self.assert_lint('foreach ( foo, foos) {', 'Extra space after ( in foreach'
- ' [whitespace/parens] [5]')
self.assert_lint('while ( foo) {', 'Extra space after ( in while'
' [whitespace/parens] [5]')
def test_spacing_for_fncall(self):
self.assert_lint('if (foo) {', '')
self.assert_lint('for (foo;bar;baz) {', '')
- self.assert_lint('foreach (foo, foos) {', '')
self.assert_lint('while (foo) {', '')
self.assert_lint('switch (foo) {', '')
self.assert_lint('new (RenderArena()) RenderInline(document())', '')
'}\n',
'This { should be at the end of the previous line [whitespace/braces] [4]')
self.assert_multi_line_lint(
- 'foreach (Foo* foo, foos)\n'
- '{\n'
- ' int bar;\n'
- '}\n',
- 'This { should be at the end of the previous line [whitespace/braces] [4]')
- self.assert_multi_line_lint(
'switch (type)\n'
'{\n'
'case foo: return;\n'
'One line control clauses should not use braces. [whitespace/braces] [4]')
self.assert_multi_line_lint(
- 'foreach (foo, foos) {\n'
- ' int bar;\n'
- '}\n',
- 'One line control clauses should not use braces. [whitespace/braces] [4]')
-
- self.assert_multi_line_lint(
'while (true) {\n'
' int foo;\n'
'}\n',