OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Checks C++ and Objective-C files for illegal includes.""" | 5 """Checks C++ and Objective-C files for illegal includes.""" |
6 | 6 |
7 import codecs | 7 import codecs |
8 import os | 8 import os |
9 import re | 9 import re |
10 | 10 |
11 import results | 11 import results |
12 from rules import Rule, MessageRule | 12 from rules import Rule, MessageRule |
13 | 13 |
14 | 14 |
15 class CppChecker(object): | 15 class CppChecker(object): |
16 | 16 |
17 EXTENSIONS = [ | 17 EXTENSIONS = [ |
18 '.h', | 18 '.h', |
19 '.cc', | 19 '.cc', |
| 20 '.cpp', |
20 '.m', | 21 '.m', |
21 '.mm', | 22 '.mm', |
22 ] | 23 ] |
23 | 24 |
24 # The maximum number of non-include lines we can see before giving up. | 25 # The maximum number of non-include lines we can see before giving up. |
25 _MAX_UNINTERESTING_LINES = 50 | 26 _MAX_UNINTERESTING_LINES = 50 |
26 | 27 |
27 # The maximum line length, this is to be efficient in the case of very long | 28 # The maximum line length, this is to be efficient in the case of very long |
28 # lines (which can't be #includes). | 29 # lines (which can't be #includes). |
29 _MAX_LINE_LENGTH = 128 | 30 _MAX_LINE_LENGTH = 128 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 dependee_status.AddViolation(violation) | 104 dependee_status.AddViolation(violation) |
104 | 105 |
105 return dependee_status | 106 return dependee_status |
106 | 107 |
107 @staticmethod | 108 @staticmethod |
108 def IsCppFile(file_path): | 109 def IsCppFile(file_path): |
109 """Returns True iff the given path ends in one of the extensions | 110 """Returns True iff the given path ends in one of the extensions |
110 handled by this checker. | 111 handled by this checker. |
111 """ | 112 """ |
112 return os.path.splitext(file_path)[1] in CppChecker.EXTENSIONS | 113 return os.path.splitext(file_path)[1] in CppChecker.EXTENSIONS |
OLD | NEW |