OLD | NEW |
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 # | 2 # |
3 # Copyright (C) 2009, 2010, 2012 Google Inc. All rights reserved. | 3 # Copyright (C) 2009, 2010, 2012 Google Inc. All rights reserved. |
4 # Copyright (C) 2009 Torch Mobile Inc. | 4 # Copyright (C) 2009 Torch Mobile Inc. |
5 # Copyright (C) 2009 Apple Inc. All rights reserved. | 5 # Copyright (C) 2009 Apple Inc. All rights reserved. |
6 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) | 6 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) |
7 # | 7 # |
8 # Redistribution and use in source and binary forms, with or without | 8 # Redistribution and use in source and binary forms, with or without |
9 # modification, are permitted provided that the following conditions are | 9 # modification, are permitted provided that the following conditions are |
10 # met: | 10 # met: |
(...skipping 1352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1363 'Uncommented text after #endif is non-standard. Use a comment.') | 1363 'Uncommented text after #endif is non-standard. Use a comment.') |
1364 | 1364 |
1365 if match(r'\s*class\s+(\w+\s*::\s*)+\w+\s*;', line): | 1365 if match(r'\s*class\s+(\w+\s*::\s*)+\w+\s*;', line): |
1366 error(line_number, 'build/forward_decl', 5, | 1366 error(line_number, 'build/forward_decl', 5, |
1367 'Inner-style forward declarations are invalid. Remove this line.'
) | 1367 'Inner-style forward declarations are invalid. Remove this line.'
) |
1368 | 1368 |
1369 if search(r'(\w+|[+-]?\d+(\.\d*)?)\s*(<|>)\?=?\s*(\w+|[+-]?\d+)(\.\d*)?', li
ne): | 1369 if search(r'(\w+|[+-]?\d+(\.\d*)?)\s*(<|>)\?=?\s*(\w+|[+-]?\d+)(\.\d*)?', li
ne): |
1370 error(line_number, 'build/deprecated', 3, | 1370 error(line_number, 'build/deprecated', 3, |
1371 '>? and <? (max and min) operators are non-standard and deprecated
.') | 1371 '>? and <? (max and min) operators are non-standard and deprecated
.') |
1372 | 1372 |
| 1373 if search(r'\w+<.*<.*>\s+>', line): |
| 1374 error(line_number, 'readability/templatebrackets', 3, |
| 1375 'Use >> for ending template instead of > >.') |
| 1376 |
| 1377 if search(r'\w+<\s+::\w+>', line): |
| 1378 error(line_number, 'readability/templatebrackets', 3, |
| 1379 'Use <:: for template start instead of < ::.') |
| 1380 |
1373 # Track class entry and exit, and attempt to find cases within the | 1381 # Track class entry and exit, and attempt to find cases within the |
1374 # class declaration that don't meet the C++ style | 1382 # class declaration that don't meet the C++ style |
1375 # guidelines. Tracking is very dependent on the code matching Google | 1383 # guidelines. Tracking is very dependent on the code matching Google |
1376 # style guidelines, but it seems to perform well enough in testing | 1384 # style guidelines, but it seems to perform well enough in testing |
1377 # to be a worthwhile addition to the checks. | 1385 # to be a worthwhile addition to the checks. |
1378 classinfo_stack = class_state.classinfo_stack | 1386 classinfo_stack = class_state.classinfo_stack |
1379 # Look for a class declaration | 1387 # Look for a class declaration |
1380 class_decl_match = match( | 1388 class_decl_match = match( |
1381 r'\s*(template\s*<[\w\s<>,:]*>\s*)?(class|struct)\s+(\w+(::\w+)*)', line
) | 1389 r'\s*(template\s*<[\w\s<>,:]*>\s*)?(class|struct)\s+(\w+(::\w+)*)', line
) |
1382 if class_decl_match: | 1390 if class_decl_match: |
(...skipping 2609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3992 'readability/fn_size', | 4000 'readability/fn_size', |
3993 'readability/function', | 4001 'readability/function', |
3994 'readability/multiline_comment', | 4002 'readability/multiline_comment', |
3995 'readability/multiline_string', | 4003 'readability/multiline_string', |
3996 'readability/parameter_name', | 4004 'readability/parameter_name', |
3997 'readability/naming', | 4005 'readability/naming', |
3998 'readability/naming/underscores', | 4006 'readability/naming/underscores', |
3999 'readability/null', | 4007 'readability/null', |
4000 'readability/pass_ptr', | 4008 'readability/pass_ptr', |
4001 'readability/streams', | 4009 'readability/streams', |
| 4010 'readability/templatebrackets', |
4002 'readability/todo', | 4011 'readability/todo', |
4003 'readability/utf8', | 4012 'readability/utf8', |
4004 'readability/webkit_export', | 4013 'readability/webkit_export', |
4005 'runtime/arrays', | 4014 'runtime/arrays', |
4006 'runtime/bitfields', | 4015 'runtime/bitfields', |
4007 'runtime/casting', | 4016 'runtime/casting', |
4008 'runtime/ctype_function', | 4017 'runtime/ctype_function', |
4009 'runtime/explicit', | 4018 'runtime/explicit', |
4010 'runtime/init', | 4019 'runtime/init', |
4011 'runtime/int', | 4020 'runtime/int', |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4077 | 4086 |
4078 def check(self, lines): | 4087 def check(self, lines): |
4079 _process_lines(self.file_path, self.file_extension, lines, | 4088 _process_lines(self.file_path, self.file_extension, lines, |
4080 self.handle_style_error, self.min_confidence) | 4089 self.handle_style_error, self.min_confidence) |
4081 | 4090 |
4082 | 4091 |
4083 # FIXME: Remove this function (requires refactoring unit tests). | 4092 # FIXME: Remove this function (requires refactoring unit tests). |
4084 def process_file_data(filename, file_extension, lines, error, min_confidence, fs
=None): | 4093 def process_file_data(filename, file_extension, lines, error, min_confidence, fs
=None): |
4085 checker = CppChecker(filename, file_extension, error, min_confidence, fs) | 4094 checker = CppChecker(filename, file_extension, error, min_confidence, fs) |
4086 checker.check(lines) | 4095 checker.check(lines) |
OLD | NEW |