Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: tools/checkdeps/cpp_checker.py

Issue 14767015: Also check .cpp files for include rules violations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698