[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75
levin at chromium.org
levin at chromium.org
Thu Oct 29 20:46:11 UTC 2009
The following commit has been merged in the webkit-1.1 branch:
commit b45f12375caddc1da552f0c7a3db9c820d1457b8
Author: levin at chromium.org <levin at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Oct 16 18:46:41 2009 +0000
check-webkit-style is wrong about indent checking in namespaces
in header files and a few other things
https://bugs.webkit.org/show_bug.cgi?id=30362
Patch by Carol Szabo <carol.szabo at nokia.com> on 2009-10-16
Reviewed by David Levin.
The few other things include:
+ check-webkit-style does not require spaces around the equal sign
inside 'if' statements and around binary operators that take
numeric literals.
+ check-webkit-style reports false errors for the / operator
when part of a filename in the #include directive.
* Scripts/modules/cpp_style.py:
Improved indentation checking and space checking around
binary operators. While the checks are still not perfect,
they are clearly better than before.
* Scripts/modules/cpp_style_unittest.py:
Added test cases for the newly supported checks and modified old
test cases to match the new guidelines
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49690 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index fa99992..1c92de8 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,26 @@
+2009-10-16 Carol Szabo <carol.szabo at nokia.com>
+
+ Reviewed by David Levin.
+
+ check-webkit-style is wrong about indent checking in namespaces
+ in header files and a few other things
+ https://bugs.webkit.org/show_bug.cgi?id=30362
+
+ The few other things include:
+ + check-webkit-style does not require spaces around the equal sign
+ inside 'if' statements and around binary operators that take
+ numeric literals.
+ + check-webkit-style reports false errors for the / operator
+ when part of a filename in the #include directive.
+
+ * Scripts/modules/cpp_style.py:
+ Improved indentation checking and space checking around
+ binary operators. While the checks are still not perfect,
+ they are clearly better than before.
+ * Scripts/modules/cpp_style_unittest.py:
+ Added test cases for the newly supported checks and modified old
+ test cases to match the new guidelines
+
2009-10-16 Kevin Ollivier <kevino at theolliviers.com>
wxMSW build fix. Link to MSW library needed by PluginPackageWin.cpp.
diff --git a/WebKitTools/Scripts/modules/cpp_style.py b/WebKitTools/Scripts/modules/cpp_style.py
index 43e1866..485b07c 100644
--- a/WebKitTools/Scripts/modules/cpp_style.py
+++ b/WebKitTools/Scripts/modules/cpp_style.py
@@ -1533,16 +1533,15 @@ def check_spacing(filename, clean_lines, line_number, error):
# Don't try to do spacing checks for operator methods
line = re.sub(r'operator(==|!=|<|<<|<=|>=|>>|>)\(', 'operator\(', line)
-
- # We allow no-spaces around = within an if: "if ( (a=Foo()) == 0 )".
- # Otherwise not. Note we only check for non-spaces on *both* sides;
- # sometimes people put non-spaces on one side when aligning ='s among
- # many lines (not that this is behavior that I approve of...)
- if search(r'[\w.]=[\w.]', line) and not search(r'\b(if|while) ', line):
+ # Don't try to do spacing checks for #include statements at minimum it
+ # messes up checks for spacing around /
+ if match(r'\s*#\s*include', line):
+ return
+ if search(r'[\w.]=[\w.]', line):
error(filename, line_number, 'whitespace/operators', 4,
'Missing spaces around =')
- # FIXME: It's not ok to have spaces around binary operators like + - * / .
+ # FIXME: It's not ok to have spaces around binary operators like .
# You should always have whitespace around binary operators.
# Alas, we can't test < or > because they're legitimately used sans spaces
@@ -1559,12 +1558,6 @@ def check_spacing(filename, clean_lines, line_number, error):
if matched:
error(filename, line_number, 'whitespace/operators', 3,
'Missing spaces around %s' % matched.group(1))
- # We allow no-spaces around << and >> when used like this: 10<<20, but
- # not otherwise (particularly, not when used as streams)
- matched = search(r'[^0-9\s](<<|>>)[^0-9\s=]', line)
- if matched:
- error(filename, line_number, 'whitespace/operators', 3,
- 'Missing spaces around %s' % matched.group(1))
# There shouldn't be space around unary operators
matched = search(r'(!\s|~\s|[\s]--[\s;]|[\s]\+\+[\s;])', line)
@@ -1699,29 +1692,32 @@ def check_namespace_indentation(filename, clean_lines, line_number, file_extensi
if not namespace_match:
return
- namespace_indentation = namespace_match.group('namespace_indentation')
-
+ current_indentation_level = len(namespace_match.group('namespace_indentation'))
+ if current_indentation_level > 0:
+ error(filename, line_number, 'whitespace/indent', 4,
+ 'namespace should never be indented.')
+ return
+ looking_for_semicolon = False;
line_offset = 0
-
- for current_line in clean_lines.raw_lines[line_number + 1:]:
+ in_preprocessor_directive = False;
+ for current_line in clean_lines.elided[line_number + 1:]:
line_offset += 1
-
- # Skip not only empty lines but also those with (goto) labels.
- # The goto label regexp accepts spaces or the beginning of a
- # comment (if anything) after the initial colon.
- if current_line.strip() == '' or match(r'\w+\s*:([\s\/].*)?$', current_line):
+ if not current_line.strip():
continue
-
- remaining_line = current_line[len(namespace_indentation):]
- if not match(r'\S', remaining_line):
- error(filename, line_number + line_offset, 'whitespace/indent', 4,
- 'Code inside a namespace should not be indented.')
-
- # Just check the first non-empty line in any case, because
- # otherwise we would need to count opened and closed braces,
- # which is obviously a lot more complicated.
- break
-
+ if not current_indentation_level:
+ if not (in_preprocessor_directive or looking_for_semicolon):
+ if not match(r'\S', current_line):
+ error(filename, line_number + line_offset, 'whitespace/indent', 4,
+ 'Code inside a namespace should not be indented.')
+ if in_preprocessor_directive or (current_line.strip()[0] == '#'): # This takes care of preprocessor directive syntax.
+ in_preprocessor_directive = current_line[-1] == '\\'
+ else:
+ looking_for_semicolon = ((current_line.find(';') == -1) and (current_line.strip()[-1] != '}')) or (current_line[-1] == '\\')
+ else:
+ looking_for_semicolon = False; # If we have a brace we may not need a semicolon.
+ current_indentation_level += current_line.count('{') - current_line.count('}')
+ if current_indentation_level < 0:
+ break;
def check_using_std(filename, clean_lines, line_number, error):
"""Looks for 'using std::foo;' statements which should be replaced with 'using namespace std;'.
diff --git a/WebKitTools/Scripts/modules/cpp_style_unittest.py b/WebKitTools/Scripts/modules/cpp_style_unittest.py
index 0ad8e05..5603d51 100644
--- a/WebKitTools/Scripts/modules/cpp_style_unittest.py
+++ b/WebKitTools/Scripts/modules/cpp_style_unittest.py
@@ -1265,6 +1265,12 @@ class CppStyleTest(CppStyleTestBase):
self.assert_lint('a<Foo&> t <<= &b | &c;', '')
self.assert_lint('a<Foo*> t <<= &b & &c; // Test', '')
self.assert_lint('a<Foo*> t <<= *b / &c; // Test', '')
+ self.assert_lint('if (a=b == 1)', 'Missing spaces around = [whitespace/operators] [4]')
+ self.assert_lint('a = 1<<20', 'Missing spaces around << [whitespace/operators] [3]')
+ self.assert_lint('if (a = b == 1)', '')
+ self.assert_lint('a = 1 << 20', '')
+ self.assert_multi_line_lint('#include "config.h"\n#include <sys/io.h>\n',
+ '')
def test_spacing_before_last_semicolon(self):
self.assert_lint('call_function() ;',
@@ -2813,7 +2819,7 @@ class WebKitStyleTest(CppStyleTestBase):
' int myVariable;\n'
'};\n'
'}',
- '',
+ 'Code inside a namespace should not be indented. [whitespace/indent] [4]',
'foo.h')
self.assert_multi_line_lint(
'namespace OuterNamespace {\n'
@@ -2822,7 +2828,7 @@ class WebKitStyleTest(CppStyleTestBase):
'};\n'
'};\n'
'}',
- '',
+ ['Code inside a namespace should not be indented. [whitespace/indent] [4]', 'namespace should never be indented. [whitespace/indent] [4]'],
'foo.h')
self.assert_multi_line_lint(
'namespace WebCore {\n'
@@ -2831,7 +2837,7 @@ class WebKitStyleTest(CppStyleTestBase):
'};\n'
'#endif\n'
'}',
- '',
+ 'Code inside a namespace should not be indented. [whitespace/indent] [4]',
'foo.h')
self.assert_multi_line_lint(
'namespace WebCore {\n'
@@ -2857,14 +2863,52 @@ class WebKitStyleTest(CppStyleTestBase):
'namespace OuterNamespace {\n'
'namespace InnerNamespace {\n'
'Document::Foo() { }\n'
- '}',
- '',
+ ' void* p;\n'
+ '}\n'
+ '}\n',
+ 'Code inside a namespace should not be indented. [whitespace/indent] [4]',
'foo.cpp')
self.assert_multi_line_lint(
- ' namespace WebCore {\n\n'
- 'start: // Pointless code, but tests the label regexp.\n'
- ' goto start;\n'
- ' }',
+ 'namespace OuterNamespace {\n'
+ 'namespace InnerNamespace {\n'
+ 'Document::Foo() { }\n'
+ '}\n'
+ ' void* p;\n'
+ '}\n',
+ 'Code inside a namespace should not be indented. [whitespace/indent] [4]',
+ 'foo.cpp')
+ self.assert_multi_line_lint(
+ 'namespace WebCore {\n\n'
+ ' const char* foo = "start:;"\n'
+ ' "dfsfsfs";\n'
+ '}\n',
+ 'Code inside a namespace should not be indented. [whitespace/indent] [4]',
+ 'foo.cpp')
+ self.assert_multi_line_lint(
+ 'namespace WebCore {\n\n'
+ 'const char* foo(void* a = ";", // ;\n'
+ ' void* b);\n'
+ ' void* p;\n'
+ '}\n',
+ 'Code inside a namespace should not be indented. [whitespace/indent] [4]',
+ 'foo.cpp')
+ self.assert_multi_line_lint(
+ 'namespace WebCore {\n\n'
+ 'const char* foo[] = {\n'
+ ' "void* b);", // ;\n'
+ ' "asfdf",\n'
+ ' }\n'
+ ' void* p;\n'
+ '}\n',
+ 'Code inside a namespace should not be indented. [whitespace/indent] [4]',
+ 'foo.cpp')
+ self.assert_multi_line_lint(
+ 'namespace WebCore {\n\n'
+ 'const char* foo[] = {\n'
+ ' "void* b);", // }\n'
+ ' "asfdf",\n'
+ ' }\n'
+ '}\n',
'',
'foo.cpp')
self.assert_multi_line_lint(
@@ -2874,7 +2918,7 @@ class WebKitStyleTest(CppStyleTestBase):
'start: // infinite loops are fun!\n'
' goto start;\n'
' }',
- '',
+ 'namespace should never be indented. [whitespace/indent] [4]',
'foo.cpp')
self.assert_multi_line_lint(
'namespace WebCore {\n'
@@ -2883,6 +2927,21 @@ class WebKitStyleTest(CppStyleTestBase):
'Code inside a namespace should not be indented.'
' [whitespace/indent] [4]',
'foo.cpp')
+ self.assert_multi_line_lint(
+ 'namespace WebCore {\n'
+ '#define abc(x) x; \\\n'
+ ' x\n'
+ '}',
+ '',
+ 'foo.cpp')
+ self.assert_multi_line_lint(
+ 'namespace WebCore {\n'
+ '#define abc(x) x; \\\n'
+ ' x\n'
+ ' void* x;'
+ '}',
+ 'Code inside a namespace should not be indented. [whitespace/indent] [4]',
+ 'foo.cpp')
# 5. A case label should line up with its switch statement. The
# case statement is indented.
@@ -3247,7 +3306,7 @@ class WebKitStyleTest(CppStyleTestBase):
'namespace WebCore {\n'
'int foo;\n'
'};\n',
- '')
+ 'Code inside a namespace should not be indented. [whitespace/indent] [4]')
self.assert_multi_line_lint(
'for (int i = 0; i < 10; i++) {\n'
' DoSomething();\n'
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list