| 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 2810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2821 character_after_identifier = matched.group('character_after_identifier') | 2821 character_after_identifier = matched.group('character_after_identifier') |
| 2822 | 2822 |
| 2823 # If we removed a non-for-control statement, the character after | 2823 # If we removed a non-for-control statement, the character after |
| 2824 # the identifier should be '='. With this rule, we can avoid | 2824 # the identifier should be '='. With this rule, we can avoid |
| 2825 # warning for cases like "if (val & INT_MAX) {". | 2825 # warning for cases like "if (val & INT_MAX) {". |
| 2826 if control_statement and character_after_identifier != '=': | 2826 if control_statement and character_after_identifier != '=': |
| 2827 return | 2827 return |
| 2828 | 2828 |
| 2829 is_function_arguments = is_function_arguments or character_after_identif
ier == '(' | 2829 is_function_arguments = is_function_arguments or character_after_identif
ier == '(' |
| 2830 | 2830 |
| 2831 # Remove "m_" and "s_" to allow them. | |
| 2832 modified_identifier = sub(r'(^|(?<=::))[ms]_', '', identifier) | |
| 2833 if not file_state.is_objective_c() and modified_identifier.find('_') >=
0: | |
| 2834 # Various exceptions to the rule: JavaScript op codes functions, con
st_iterator. | |
| 2835 if (not (filename.find('JavaScriptCore') >= 0 and modified_identifie
r.find('op_') >= 0) | |
| 2836 and not (filename.find('gtk') >= 0 and modified_identifier.s
tartswith('webkit_') >= 0) | |
| 2837 and not (filename.find('StructTraits.h') >= 0) | |
| 2838 and not modified_identifier.startswith('tst_') | |
| 2839 and not modified_identifier.startswith('webkit_dom_object_') | |
| 2840 and not modified_identifier.startswith('webkit_soup') | |
| 2841 and not modified_identifier.startswith('NPN_') | |
| 2842 and not modified_identifier.startswith('NPP_') | |
| 2843 and not modified_identifier.startswith('NP_') | |
| 2844 and not modified_identifier.startswith('qt_') | |
| 2845 and not modified_identifier.startswith('_q_') | |
| 2846 and not modified_identifier.startswith('cairo_') | |
| 2847 and not modified_identifier.startswith('Ecore_') | |
| 2848 and not modified_identifier.startswith('Eina_') | |
| 2849 and not modified_identifier.startswith('Evas_') | |
| 2850 and not modified_identifier.startswith('Ewk_') | |
| 2851 and not modified_identifier.startswith('cti_') | |
| 2852 and not modified_identifier.find('::qt_') >= 0 | |
| 2853 and not modified_identifier.find('::_q_') >= 0 | |
| 2854 and not modified_identifier == 'const_iterator' | |
| 2855 and not modified_identifier == 'vm_throw' | |
| 2856 and not modified_identifier == 'DFG_OPERATION'): | |
| 2857 error(line_number, 'readability/naming/underscores', 4, identifi
er + | |
| 2858 " is incorrectly named. Don't use underscores in your iden
tifier names.") | |
| 2859 | |
| 2860 # Check for variables named 'l', these are too easy to confuse with '1'
in some fonts | 2831 # Check for variables named 'l', these are too easy to confuse with '1'
in some fonts |
| 2861 if modified_identifier == 'l': | 2832 if identifier == 'l': |
| 2862 error(line_number, 'readability/naming', 4, identifier + | 2833 error(line_number, 'readability/naming', 4, identifier + |
| 2863 " is incorrectly named. Don't use the single letter 'l' as an
identifier name.") | 2834 " is incorrectly named. Don't use the single letter 'l' as an
identifier name.") |
| 2864 | 2835 |
| 2865 # There can be only one declaration in non-for-control statements. | 2836 # There can be only one declaration in non-for-control statements. |
| 2866 if control_statement: | 2837 if control_statement: |
| 2867 return | 2838 return |
| 2868 # We should continue checking if this is a function | 2839 # We should continue checking if this is a function |
| 2869 # declaration because we need to check its arguments. | 2840 # declaration because we need to check its arguments. |
| 2870 # Also, we need to check multiple declarations. | 2841 # Also, we need to check multiple declarations. |
| 2871 if character_after_identifier != '(' and character_after_identifier != '
,': | 2842 if character_after_identifier != '(' and character_after_identifier != '
,': |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3495 | 3466 |
| 3496 def check(self, lines): | 3467 def check(self, lines): |
| 3497 _process_lines(self.file_path, self.file_extension, lines, | 3468 _process_lines(self.file_path, self.file_extension, lines, |
| 3498 self.handle_style_error, self.min_confidence) | 3469 self.handle_style_error, self.min_confidence) |
| 3499 | 3470 |
| 3500 | 3471 |
| 3501 # FIXME: Remove this function (requires refactoring unit tests). | 3472 # FIXME: Remove this function (requires refactoring unit tests). |
| 3502 def process_file_data(filename, file_extension, lines, error, min_confidence, fs
=None): | 3473 def process_file_data(filename, file_extension, lines, error, min_confidence, fs
=None): |
| 3503 checker = CppChecker(filename, file_extension, error, min_confidence, fs) | 3474 checker = CppChecker(filename, file_extension, error, min_confidence, fs) |
| 3504 checker.check(lines) | 3475 checker.check(lines) |
| OLD | NEW |