Changeset 49078 in webkit


Ignore:
Timestamp:
Oct 4, 2009 2:12:25 PM (15 years ago)
Author:
eric@webkit.org
Message:

2009-10-04 Carol Szabo <carol.szabo@nokia.com>

Reviewed by David Levin.

check-webkit-style misses whitespace errors for operators:

<<, >>, <<=, >>=, &=, |=, +=, -=, *=, /=, /, |, &&,
.

https://bugs.webkit.org/show_bug.cgi?id=30021

  • Scripts/modules/cpp_style.py: Added the operators mentioned above to the same list as == and !=.
Location:
trunk/WebKitTools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r49058 r49078  
     12009-10-04  Carol Szabo  <carol.szabo@nokia.com>
     2
     3        Reviewed by David Levin.
     4
     5        check-webkit-style misses whitespace errors for operators:
     6        <<, >>, <<=, >>=, &=, |=, +=, -=, *=, /=, /, |, &&, ||.
     7        https://bugs.webkit.org/show_bug.cgi?id=30021
     8
     9        * Scripts/modules/cpp_style.py:
     10        Added the operators mentioned above to the same list as == and !=.
     11
    1122009-10-02  Julie Parent  <jparent@chromium.org>
    213
  • trunk/WebKitTools/Scripts/modules/cpp_style.py

    r48187 r49078  
    15491549    # (a->b, vector<int> a).  The only time we can tell is a < with no >, and
    15501550    # only if it's not template params list spilling into the next line.
    1551     matched = search(r'[^<>=!\s](==|!=|<=|>=)[^<>=!\s]', line)
     1551    matched = search(r'[^<>=!\s](==|!=|\+=|-=|\*=|/=|/|\|=|&=|<<=|>>=|<=|>=|\|\||\||&&|>>|<<)[^<>=!\s]', line)
    15521552    if not matched:
    15531553        # Note that while it seems that the '<[^<]*' term in the following
     
    15621562    # We allow no-spaces around << and >> when used like this: 10<<20, but
    15631563    # not otherwise (particularly, not when used as streams)
    1564     matched = search(r'[^0-9\s](<<|>>)[^0-9\s]', line)
     1564    matched = search(r'[^0-9\s](<<|>>)[^0-9\s=]', line)
    15651565    if matched:
    15661566        error(filename, line_number, 'whitespace/operators', 3,
  • trunk/WebKitTools/Scripts/modules/cpp_style_unittest.py

    r47385 r49078  
    952952        self.assert_lint('int a[128 - sizeof(const bar)];', '')
    953953        self.assert_lint('int a[(sizeof(foo) * 4)];', '')
    954         self.assert_lint('int a[(arraysize(fixed_size_array)/2) << 1];', '')
     954        self.assert_lint('int a[(arraysize(fixed_size_array)/2) << 1];', 'Missing spaces around /  [whitespace/operators] [3]')
    955955        self.assert_lint('delete a[some_var];', '')
    956956        self.assert_lint('return a[some_var];', '')
     
    12101210                         '  [whitespace/operators] [3]')
    12111211        self.assert_lint('typedef hash_map<FoooooType, BaaaaarType,', '')
     1212        self.assert_lint('a<Foo> t+=b;', 'Missing spaces around +='
     1213                         '  [whitespace/operators] [3]')
     1214        self.assert_lint('a<Foo> t-=b;', 'Missing spaces around -='
     1215                         '  [whitespace/operators] [3]')
     1216        self.assert_lint('a<Foo*> t*=b;', 'Missing spaces around *='
     1217                         '  [whitespace/operators] [3]')
     1218        self.assert_lint('a<Foo*> t/=b;', 'Missing spaces around /='
     1219                         '  [whitespace/operators] [3]')
     1220        self.assert_lint('a<Foo*> t|=b;', 'Missing spaces around |='
     1221                         '  [whitespace/operators] [3]')
     1222        self.assert_lint('a<Foo*> t&=b;', 'Missing spaces around &='
     1223                         '  [whitespace/operators] [3]')
     1224        self.assert_lint('a<Foo*> t<<=b;', 'Missing spaces around <<='
     1225                         '  [whitespace/operators] [3]')
     1226        self.assert_lint('a<Foo*> t>>=b;', 'Missing spaces around >>='
     1227                         '  [whitespace/operators] [3]')
     1228        self.assert_lint('a<Foo*> t>>=&b|c;', 'Missing spaces around >>='
     1229                         '  [whitespace/operators] [3]')
     1230        self.assert_lint('a<Foo*> t<<=*b/c;', 'Missing spaces around <<='
     1231                         '  [whitespace/operators] [3]')
     1232        self.assert_lint('a<Foo> t -= b;', '')
     1233        self.assert_lint('a<Foo> t += b;', '')
     1234        self.assert_lint('a<Foo*> t *= b;', '')
     1235        self.assert_lint('a<Foo*> t /= b;', '')
     1236        self.assert_lint('a<Foo*> t |= b;', '')
     1237        self.assert_lint('a<Foo*> t &= b;', '')
     1238        self.assert_lint('a<Foo*> t <<= b;', '')
     1239        self.assert_lint('a<Foo*> t >>= b;', '')
     1240        self.assert_lint('a<Foo*> t >>= &b|c;', 'Missing spaces around |'
     1241                         '  [whitespace/operators] [3]')
     1242        self.assert_lint('a<Foo*> t <<= *b/c;', 'Missing spaces around /'
     1243                         '  [whitespace/operators] [3]')
     1244        self.assert_lint('a<Foo*> t <<= b/c; //Test', ['At least two spaces'
     1245                         ' is best between code and comments  [whitespace/'
     1246                         'comments] [2]', 'Should have a space between // '
     1247                         'and comment  [whitespace/comments] [4]', 'Missing'
     1248                         ' spaces around /  [whitespace/operators] [3]'])
     1249        self.assert_lint('a<Foo*> t <<= b||c;  //Test', ['Should have a space'
     1250                         ' between // and comment  [whitespace/comments] [4]',
     1251                         'Missing spaces around ||  [whitespace/operators] [3]'])
     1252        self.assert_lint('a<Foo*> t <<= b&&c;  // Test', 'Missing spaces around'
     1253                         ' &&  [whitespace/operators] [3]')
     1254        self.assert_lint('a<Foo*> t <<= b&&&c;  // Test', 'Missing spaces around'
     1255                         ' &&  [whitespace/operators] [3]')
     1256        self.assert_lint('a<Foo*> t <<= b&&*c;  // Test', 'Missing spaces around'
     1257                         ' &&  [whitespace/operators] [3]')
     1258        self.assert_lint('a<Foo*> t <<= b && *c;  // Test', '')
     1259        self.assert_lint('a<Foo*> t <<= b && &c;  // Test', '')
     1260        self.assert_lint('a<Foo*> t <<= b || &c;  /*Test', 'Complex multi-line '
     1261                         '/*...*/-style comment found. Lint may give bogus '
     1262                         'warnings.  Consider replacing these with //-style'
     1263                         ' comments, with #if 0...#endif, or with more clearly'
     1264                         ' structured multi-line comments.  [readability/multiline_comment] [5]')
     1265        self.assert_lint('a<Foo&> t <<= &b | &c;', '')
     1266        self.assert_lint('a<Foo*> t <<= &b & &c;  // Test', '')
     1267        self.assert_lint('a<Foo*> t <<= *b / &c;  // Test', '')
    12121268
    12131269    def test_spacing_before_last_semicolon(self):
     
    29613017        self.assert_multi_line_lint(
    29623018            'c = a|b;',
    2963             '')
     3019            'Missing spaces around |  [whitespace/operators] [3]')
    29643020        # FIXME: We cannot catch this lint error.
    29653021        # self.assert_multi_line_lint(
Note: See TracChangeset for help on using the changeset viewer.