| 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 2952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2963 character_after_identifier = matched.group('character_after_identifier') | 2963 character_after_identifier = matched.group('character_after_identifier') |
| 2964 | 2964 |
| 2965 # If we removed a non-for-control statement, the character after | 2965 # If we removed a non-for-control statement, the character after |
| 2966 # the identifier should be '='. With this rule, we can avoid | 2966 # the identifier should be '='. With this rule, we can avoid |
| 2967 # warning for cases like "if (val & INT_MAX) {". | 2967 # warning for cases like "if (val & INT_MAX) {". |
| 2968 if control_statement and character_after_identifier != '=': | 2968 if control_statement and character_after_identifier != '=': |
| 2969 return | 2969 return |
| 2970 | 2970 |
| 2971 is_function_arguments = is_function_arguments or character_after_identif
ier == '(' | 2971 is_function_arguments = is_function_arguments or character_after_identif
ier == '(' |
| 2972 | 2972 |
| 2973 # Remove "m_" and "s_" to allow them. | |
| 2974 modified_identifier = sub(r'(^|(?<=::))[ms]_', '', identifier) | |
| 2975 if not file_state.is_objective_c() and modified_identifier.find('_') >=
0: | |
| 2976 # Various exceptions to the rule: JavaScript op codes functions, con
st_iterator. | |
| 2977 if (not (filename.find('JavaScriptCore') >= 0 and modified_identifie
r.find('op_') >= 0) | |
| 2978 and not (filename.find('gtk') >= 0 and modified_identifier.s
tartswith('webkit_') >= 0) | |
| 2979 and not (filename.find('StructTraits.h') >= 0) | |
| 2980 and not modified_identifier.startswith('tst_') | |
| 2981 and not modified_identifier.startswith('webkit_dom_object_') | |
| 2982 and not modified_identifier.startswith('webkit_soup') | |
| 2983 and not modified_identifier.startswith('NPN_') | |
| 2984 and not modified_identifier.startswith('NPP_') | |
| 2985 and not modified_identifier.startswith('NP_') | |
| 2986 and not modified_identifier.startswith('qt_') | |
| 2987 and not modified_identifier.startswith('_q_') | |
| 2988 and not modified_identifier.startswith('cairo_') | |
| 2989 and not modified_identifier.startswith('Ecore_') | |
| 2990 and not modified_identifier.startswith('Eina_') | |
| 2991 and not modified_identifier.startswith('Evas_') | |
| 2992 and not modified_identifier.startswith('Ewk_') | |
| 2993 and not modified_identifier.startswith('cti_') | |
| 2994 and not modified_identifier.find('::qt_') >= 0 | |
| 2995 and not modified_identifier.find('::_q_') >= 0 | |
| 2996 and not modified_identifier == "const_iterator" | |
| 2997 and not modified_identifier == "vm_throw" | |
| 2998 and not modified_identifier == "DFG_OPERATION"): | |
| 2999 error(line_number, 'readability/naming/underscores', 4, identifi
er + | |
| 3000 " is incorrectly named. Don't use underscores in your iden
tifier names.") | |
| 3001 | |
| 3002 # Check for variables named 'l', these are too easy to confuse with '1'
in some fonts | 2973 # Check for variables named 'l', these are too easy to confuse with '1'
in some fonts |
| 3003 if modified_identifier == 'l': | 2974 if identifier == 'l': |
| 3004 error(line_number, 'readability/naming', 4, identifier + | 2975 error(line_number, 'readability/naming', 4, identifier + |
| 3005 " is incorrectly named. Don't use the single letter 'l' as an
identifier name.") | 2976 " is incorrectly named. Don't use the single letter 'l' as an
identifier name.") |
| 3006 | 2977 |
| 3007 # There can be only one declaration in non-for-control statements. | 2978 # There can be only one declaration in non-for-control statements. |
| 3008 if control_statement: | 2979 if control_statement: |
| 3009 return | 2980 return |
| 3010 # We should continue checking if this is a function | 2981 # We should continue checking if this is a function |
| 3011 # declaration because we need to check its arguments. | 2982 # declaration because we need to check its arguments. |
| 3012 # Also, we need to check multiple declarations. | 2983 # Also, we need to check multiple declarations. |
| 3013 if character_after_identifier != '(' and character_after_identifier != '
,': | 2984 if character_after_identifier != '(' and character_after_identifier != '
,': |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3637 | 3608 |
| 3638 def check(self, lines): | 3609 def check(self, lines): |
| 3639 _process_lines(self.file_path, self.file_extension, lines, | 3610 _process_lines(self.file_path, self.file_extension, lines, |
| 3640 self.handle_style_error, self.min_confidence) | 3611 self.handle_style_error, self.min_confidence) |
| 3641 | 3612 |
| 3642 | 3613 |
| 3643 # FIXME: Remove this function (requires refactoring unit tests). | 3614 # FIXME: Remove this function (requires refactoring unit tests). |
| 3644 def process_file_data(filename, file_extension, lines, error, min_confidence, fs
=None): | 3615 def process_file_data(filename, file_extension, lines, error, min_confidence, fs
=None): |
| 3645 checker = CppChecker(filename, file_extension, error, min_confidence, fs) | 3616 checker = CppChecker(filename, file_extension, error, min_confidence, fs) |
| 3646 checker.check(lines) | 3617 checker.check(lines) |
| OLD | NEW |