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

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

Issue 10806049: Add checkdeps presubmit check. Warns on new #includes of dependencies (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to parent. Created 8 years, 4 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 | « tools/checkdeps/checkdeps.py ('k') | 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 re 9 import re
9 10
10 from rules import Rule 11 from rules import Rule
11 12
12 13
13 class CppChecker(object): 14 class CppChecker(object):
14 15
15 EXTENSIONS = [ 16 EXTENSIONS = [
16 '.h', 17 '.h',
17 '.cc', 18 '.cc',
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 107
107 is_include, line_status, rule_type = self.CheckLine(rules, line) 108 is_include, line_status, rule_type = self.CheckLine(rules, line)
108 if is_include: 109 if is_include:
109 last_include = line_num 110 last_include = line_num
110 if line_status is not None: 111 if line_status is not None:
111 if len(line_status) > 0: # Add newline to separate messages. 112 if len(line_status) > 0: # Add newline to separate messages.
112 line_status += '\n' 113 line_status += '\n'
113 ret_val += line_status 114 ret_val += line_status
114 115
115 return ret_val 116 return ret_val
117
118 @staticmethod
119 def IsCppFile(file_path):
120 """Returns True iff the given path ends in one of the extensions
121 handled by this checker.
122 """
123 return os.path.splitext(file_path)[1] in CppChecker.EXTENSIONS
OLDNEW
« no previous file with comments | « tools/checkdeps/checkdeps.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698