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

Side by Side Diff: cpplint.py

Issue 495413002: depot_tools: update cpplint.py to r137 (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools@master
Patch Set: Fixed the file attributes Created 6 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
« 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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright (c) 2009 Google Inc. All rights reserved. 3 # Copyright (c) 2009 Google Inc. All rights reserved.
4 # 4 #
5 # Redistribution and use in source and binary forms, with or without 5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are 6 # modification, are permitted provided that the following conditions are
7 # met: 7 # met:
8 # 8 #
9 # * Redistributions of source code must retain the above copyright 9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer. 10 # notice, this list of conditions and the following disclaimer.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 Examples: 134 Examples:
135 --extensions=hpp,cpp 135 --extensions=hpp,cpp
136 136
137 cpplint.py supports per-directory configurations specified in CPPLINT.cfg 137 cpplint.py supports per-directory configurations specified in CPPLINT.cfg
138 files. CPPLINT.cfg file can contain a number of key=value pairs. 138 files. CPPLINT.cfg file can contain a number of key=value pairs.
139 Currently the following options are supported: 139 Currently the following options are supported:
140 140
141 set noparent 141 set noparent
142 filter=+filter1,-filter2,... 142 filter=+filter1,-filter2,...
143 exclude_files=regex 143 exclude_files=regex
144 linelength=80
144 145
145 "set noparent" option prevents cpplint from traversing directory tree 146 "set noparent" option prevents cpplint from traversing directory tree
146 upwards looking for more .cfg files in parent directories. This option 147 upwards looking for more .cfg files in parent directories. This option
147 is usually placed in the top-level project directory. 148 is usually placed in the top-level project directory.
148 149
149 The "filter" option is similar in function to --filter flag. It specifies 150 The "filter" option is similar in function to --filter flag. It specifies
150 message filters in addition to the |_DEFAULT_FILTERS| and those specified 151 message filters in addition to the |_DEFAULT_FILTERS| and those specified
151 through --filter command-line flag. 152 through --filter command-line flag.
152 153
153 "exclude_files" allows to specify a regular expression to be matched against 154 "exclude_files" allows to specify a regular expression to be matched against
154 a file name. If the expression matches, the file is skipped and not run 155 a file name. If the expression matches, the file is skipped and not run
155 through liner. 156 through liner.
156 157
158 "linelength" allows to specify the allowed line length for the project.
159
157 CPPLINT.cfg has an effect on files in the same directory and all 160 CPPLINT.cfg has an effect on files in the same directory and all
158 sub-directories, unless overridden by a nested configuration file. 161 sub-directories, unless overridden by a nested configuration file.
159 162
160 Example file: 163 Example file:
161 filter=-build/include_order,+build/include_alpha 164 filter=-build/include_order,+build/include_alpha
162 exclude_files=.*\.cc 165 exclude_files=.*\.cc
163 166
164 The above example disables build/include_order warning and enables 167 The above example disables build/include_order warning and enables
165 build/include_alpha as well as excludes all .cc from being 168 build/include_alpha as well as excludes all .cc from being
166 processed by linter, in the current directory (where the .cfg 169 processed by linter, in the current directory (where the .cfg
(...skipping 5741 matching lines...) Expand 10 before | Expand all | Expand 10 after
5908 # file's "exclude_files" filter is meant to be checked against "bar" 5911 # file's "exclude_files" filter is meant to be checked against "bar"
5909 # and not "baz" nor "bar/baz.cc". 5912 # and not "baz" nor "bar/baz.cc".
5910 if base_name: 5913 if base_name:
5911 pattern = re.compile(val) 5914 pattern = re.compile(val)
5912 if pattern.match(base_name): 5915 if pattern.match(base_name):
5913 sys.stderr.write('Ignoring "%s": file excluded by "%s". ' 5916 sys.stderr.write('Ignoring "%s": file excluded by "%s". '
5914 'File path component "%s" matches ' 5917 'File path component "%s" matches '
5915 'pattern "%s"\n' % 5918 'pattern "%s"\n' %
5916 (filename, cfg_file, base_name, val)) 5919 (filename, cfg_file, base_name, val))
5917 return False 5920 return False
5921 elif name == 'linelength':
5922 global _line_length
5923 try:
5924 _line_length = int(val)
5925 except ValueError:
5926 sys.stderr.write('Line length must be numeric.')
5918 else: 5927 else:
5919 sys.stderr.write( 5928 sys.stderr.write(
5920 'Invalid configuration option (%s) in file %s\n' % 5929 'Invalid configuration option (%s) in file %s\n' %
5921 (name, cfg_file)) 5930 (name, cfg_file))
5922 5931
5923 except IOError: 5932 except IOError:
5924 sys.stderr.write( 5933 sys.stderr.write(
5925 "Skipping config file '%s': Can't open for reading\n" % cfg_file) 5934 "Skipping config file '%s': Can't open for reading\n" % cfg_file)
5926 keep_looking = False 5935 keep_looking = False
5927 5936
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
6126 _cpplint_state.ResetErrorCounts() 6135 _cpplint_state.ResetErrorCounts()
6127 for filename in filenames: 6136 for filename in filenames:
6128 ProcessFile(filename, _cpplint_state.verbose_level) 6137 ProcessFile(filename, _cpplint_state.verbose_level)
6129 _cpplint_state.PrintErrorCounts() 6138 _cpplint_state.PrintErrorCounts()
6130 6139
6131 sys.exit(_cpplint_state.error_count > 0) 6140 sys.exit(_cpplint_state.error_count > 0)
6132 6141
6133 6142
6134 if __name__ == '__main__': 6143 if __name__ == '__main__':
6135 main() 6144 main()
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