 Chromium Code Reviews
 Chromium Code Reviews Issue 7834045:
  Add lint check against "Foo *bar" and "Foo &bar" declarations.   (Closed) 
  Base URL: http://src.chromium.org/svn/trunk/tools/depot_tools/
    
  
    Issue 7834045:
  Add lint check against "Foo *bar" and "Foo &bar" declarations.   (Closed) 
  Base URL: http://src.chromium.org/svn/trunk/tools/depot_tools/| OLD | NEW | 
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python | 
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be | 
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. | 
| 5 | 5 | 
| 6 """\ | 6 """\ | 
| 7 Wrapper script around Rietveld's upload.py that simplifies working with groups | 7 Wrapper script around Rietveld's upload.py that simplifies working with groups | 
| 8 of files. | 8 of files. | 
| 9 """ | 9 """ | 
| 10 | 10 | 
| (...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1166 print change_info.name + " changelist saved." | 1166 print change_info.name + " changelist saved." | 
| 1167 if change_info.MissingTests(): | 1167 if change_info.MissingTests(): | 
| 1168 Warn("WARNING: " + MISSING_TEST_MSG) | 1168 Warn("WARNING: " + MISSING_TEST_MSG) | 
| 1169 | 1169 | 
| 1170 # Update the Rietveld issue. | 1170 # Update the Rietveld issue. | 
| 1171 if change_info.issue and change_info.NeedsUpload(): | 1171 if change_info.issue and change_info.NeedsUpload(): | 
| 1172 change_info.UpdateRietveldDescription() | 1172 change_info.UpdateRietveldDescription() | 
| 1173 change_info.needs_upload = False | 1173 change_info.needs_upload = False | 
| 1174 change_info.Save() | 1174 change_info.Save() | 
| 1175 return 0 | 1175 return 0 | 
| 1176 | 1176 | 
| 
M-A Ruel
2011/09/07 19:18:29
keep 2 lines between file level symbols as per sty
 
Alexei Svitkine (slow)
2011/09/07 20:27:57
Done.
 | |
| 1177 | |
| 1178 @need_change_and_args | 1177 @need_change_and_args | 
| 1179 def CMDlint(change_info, args): | 1178 def CMDlint(change_info, args): | 
| 1180 """Runs cpplint.py on all the files in the change list. | 1179 """Runs cpplint.py on all the files in the change list. | 
| 1181 | 1180 | 
| 1182 Checks all the files in the changelist for possible style violations. | 1181 Checks all the files in the changelist for possible style violations. | 
| 1183 """ | 1182 """ | 
| 1184 try: | 1183 try: | 
| 1185 import cpplint | 1184 import cpplint | 
| 1185 import cpplint_chromium | |
| 1186 except ImportError: | 1186 except ImportError: | 
| 1187 ErrorExit("You need to install cpplint.py to lint C++ files.") | 1187 ErrorExit("You need to install cpplint.py to lint C++ files.") | 
| 1188 # Change the current working directory before calling lint so that it | 1188 # Change the current working directory before calling lint so that it | 
| 1189 # shows the correct base. | 1189 # shows the correct base. | 
| 1190 previous_cwd = os.getcwd() | 1190 previous_cwd = os.getcwd() | 
| 1191 os.chdir(change_info.GetLocalRoot()) | 1191 os.chdir(change_info.GetLocalRoot()) | 
| 1192 # Process cpplints arguments if any. | 1192 # Process cpplints arguments if any. | 
| 1193 filenames = cpplint.ParseArguments(args + change_info.GetFileNames()) | 1193 filenames = cpplint.ParseArguments(args + change_info.GetFileNames()) | 
| 1194 | 1194 | 
| 1195 white_list = GetCodeReviewSetting("LINT_REGEX") | 1195 white_list = GetCodeReviewSetting("LINT_REGEX") | 
| 1196 if not white_list: | 1196 if not white_list: | 
| 1197 white_list = DEFAULT_LINT_REGEX | 1197 white_list = DEFAULT_LINT_REGEX | 
| 1198 white_regex = re.compile(white_list) | 1198 white_regex = re.compile(white_list) | 
| 1199 black_list = GetCodeReviewSetting("LINT_IGNORE_REGEX") | 1199 black_list = GetCodeReviewSetting("LINT_IGNORE_REGEX") | 
| 1200 if not black_list: | 1200 if not black_list: | 
| 1201 black_list = DEFAULT_LINT_IGNORE_REGEX | 1201 black_list = DEFAULT_LINT_IGNORE_REGEX | 
| 1202 black_regex = re.compile(black_list) | 1202 black_regex = re.compile(black_list) | 
| 1203 extra_check_functions = [cpplint_chromium.CheckPointerDeclarationWhitespace] | |
| 1203 # Access to a protected member _XX of a client class | 1204 # Access to a protected member _XX of a client class | 
| 1204 # pylint: disable=W0212 | 1205 # pylint: disable=W0212 | 
| 1205 for filename in filenames: | 1206 for filename in filenames: | 
| 1206 if white_regex.match(filename): | 1207 if white_regex.match(filename): | 
| 1207 if black_regex.match(filename): | 1208 if black_regex.match(filename): | 
| 1208 print "Ignoring file %s" % filename | 1209 print "Ignoring file %s" % filename | 
| 1209 else: | 1210 else: | 
| 1210 cpplint.ProcessFile(filename, cpplint._cpplint_state.verbose_level) | 1211 cpplint.ProcessFile(filename, cpplint._cpplint_state.verbose_level, | 
| 1212 extra_check_functions) | |
| 1211 else: | 1213 else: | 
| 1212 print "Skipping file %s" % filename | 1214 print "Skipping file %s" % filename | 
| 1213 | 1215 | 
| 1214 print "Total errors found: %d\n" % cpplint._cpplint_state.error_count | 1216 print "Total errors found: %d\n" % cpplint._cpplint_state.error_count | 
| 1215 os.chdir(previous_cwd) | 1217 os.chdir(previous_cwd) | 
| 1216 return 1 | 1218 return 1 | 
| 1217 | 1219 | 
| 1218 | 1220 | 
| 1219 def DoPresubmitChecks(change_info, committing, may_prompt): | 1221 def DoPresubmitChecks(change_info, committing, may_prompt): | 
| 1220 """Imports presubmit, then calls presubmit.DoPresubmitChecks.""" | 1222 """Imports presubmit, then calls presubmit.DoPresubmitChecks.""" | 
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1460 raise | 1462 raise | 
| 1461 print >> sys.stderr, ( | 1463 print >> sys.stderr, ( | 
| 1462 'AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 1464 'AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 
| 1463 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)) | 1465 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)) | 
| 1464 return 1 | 1466 return 1 | 
| 1465 | 1467 | 
| 1466 | 1468 | 
| 1467 if __name__ == "__main__": | 1469 if __name__ == "__main__": | 
| 1468 fix_encoding.fix_encoding() | 1470 fix_encoding.fix_encoding() | 
| 1469 sys.exit(main(sys.argv[1:])) | 1471 sys.exit(main(sys.argv[1:])) | 
| OLD | NEW |