- a/Tools/ChangeLog +11 lines
Lines 1-3 a/Tools/ChangeLog_sec1
1
2011-04-27  David Levin  <levin@chromium.org>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        check-webkit-style should flags spacing errors for braces on the same line.
6
        https://bugs.webkit.org/show_bug.cgi?id=59665
7
8
        * Scripts/webkitpy/style/checkers/cpp.py: Added the check.
9
        * Scripts/webkitpy/style/checkers/cpp_unittest.py: Added some tests for the check
10
          and fixed some test cases to not trigger this error since it isn't what they are verifying.
11
1
2011-04-27  Ojan Vafai  <ojan@chromium.org>
12
2011-04-27  Ojan Vafai  <ojan@chromium.org>
2
13
3
        remove assertion now that platform/mac-tiger no longer exists
14
        remove assertion now that platform/mac-tiger no longer exists
- a/Tools/Scripts/webkitpy/style/checkers/cpp.py +6 lines
Lines 1878-1883 def check_spacing(file_extension, clean_lines, line_number, error): a/Tools/Scripts/webkitpy/style/checkers/cpp.py_sec1
1878
        error(line_number, 'whitespace/braces', 5,
1878
        error(line_number, 'whitespace/braces', 5,
1879
              'Extra space before [')
1879
              'Extra space before [')
1880
1880
1881
    # There should always be a single space in between braces on the same line.
1882
    if search(r'\{\}', line):
1883
        error(line_number, 'whitespace/braces', 5, 'Missing space inside { }.')
1884
    if search(r'\{\s\s+\}', line):
1885
        error(line_number, 'whitespace/braces', 5, 'Too many spaces inside { }.')
1886
1881
    # You shouldn't have a space before a semicolon at the end of the line.
1887
    # You shouldn't have a space before a semicolon at the end of the line.
1882
    # There's a special case for "for" since the style guide allows space before
1888
    # There's a special case for "for" since the style guide allows space before
1883
    # the semicolon there.
1889
    # the semicolon there.
- a/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py -2 / +7 lines
Lines 789-795 class CppStyleTest(CppStyleTestBase): a/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py_sec1
789
            'int a = int(); // Constructor, o.k.',
789
            'int a = int(); // Constructor, o.k.',
790
            '')
790
            '')
791
        self.assert_lint(
791
        self.assert_lint(
792
            'X::X() : a(int()) {} // default Constructor, o.k.',
792
            'X::X() : a(int()) { } // default Constructor, o.k.',
793
            '')
793
            '')
794
        self.assert_lint(
794
        self.assert_lint(
795
            'operator bool(); // Conversion operator, o.k.',
795
            'operator bool(); // Conversion operator, o.k.',
Lines 1601-1606 class CppStyleTest(CppStyleTestBase): a/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py_sec2
1601
        self.assert_lint('for {', '')
1601
        self.assert_lint('for {', '')
1602
        self.assert_lint('EXPECT_DEBUG_DEATH({', '')
1602
        self.assert_lint('EXPECT_DEBUG_DEATH({', '')
1603
1603
1604
    def test_spacing_between_braces(self):
1605
        self.assert_lint('    { }', '')
1606
        self.assert_lint('    {}', 'Missing space inside { }.  [whitespace/braces] [5]')
1607
        self.assert_lint('    {   }', 'Too many spaces inside { }.  [whitespace/braces] [5]')
1608
1604
    def test_spacing_around_else(self):
1609
    def test_spacing_around_else(self):
1605
        self.assert_lint('}else {', 'Missing space before else'
1610
        self.assert_lint('}else {', 'Missing space before else'
1606
                         '  [whitespace/braces] [5]')
1611
                         '  [whitespace/braces] [5]')
Lines 1749-1755 class CppStyleTest(CppStyleTestBase): a/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py_sec3
1749
        self.assert_lint('string EmptyString() { return ""; }', '')
1754
        self.assert_lint('string EmptyString() { return ""; }', '')
1750
        self.assert_lint('string EmptyString () { return ""; }', '')
1755
        self.assert_lint('string EmptyString () { return ""; }', '')
1751
        self.assert_lint('string VeryLongNameFunctionSometimesEndsWith(\n'
1756
        self.assert_lint('string VeryLongNameFunctionSometimesEndsWith(\n'
1752
                         '    VeryLongNameType veryLongNameVariable) {}', '')
1757
                         '    VeryLongNameType veryLongNameVariable) { }', '')
1753
        self.assert_lint('template<>\n'
1758
        self.assert_lint('template<>\n'
1754
                         'string FunctionTemplateSpecialization<SomeType>(\n'
1759
                         'string FunctionTemplateSpecialization<SomeType>(\n'
1755
                         '      int x) { return ""; }', '')
1760
                         '      int x) { return ""; }', '')

Return to Bug 59665