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

Side by Side Diff: presubmit_canned_checks.py

Issue 924863002: Remove the Singleton<T> presubmit check from presubmit_canned_checks.py (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Restore CheckSingletonInHeaders() Created 5 years, 10 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 | tests/presubmit_unittest.py » ('j') | 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 """Generic presubmit checks that can be reused by other presubmit checks.""" 5 """Generic presubmit checks that can be reused by other presubmit checks."""
6 6
7 import os as _os 7 import os as _os
8 _HERE = _os.path.dirname(_os.path.abspath(__file__)) 8 _HERE = _os.path.dirname(_os.path.abspath(__file__))
9 9
10 # Justifications for each filter: 10 # Justifications for each filter:
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 res_type = output_api.PresubmitPromptWarning 964 res_type = output_api.PresubmitPromptWarning
965 else: 965 else:
966 res_type = output_api.PresubmitNotifyResult 966 res_type = output_api.PresubmitNotifyResult
967 return [ res_type('|const NSClass*| is wrong, see ' + 967 return [ res_type('|const NSClass*| is wrong, see ' +
968 'http://dev.chromium.org/developers/clang-mac', 968 'http://dev.chromium.org/developers/clang-mac',
969 files) ] 969 files) ]
970 return [] 970 return []
971 971
972 972
973 def CheckSingletonInHeaders(input_api, output_api, source_file_filter=None): 973 def CheckSingletonInHeaders(input_api, output_api, source_file_filter=None):
974 """Checks to make sure no header files have |Singleton<|.""" 974 """Deprecated, must be removed."""
975 pattern = input_api.re.compile(r'(?<!class\s)Singleton\s*<')
976 files = []
977 for f in input_api.AffectedSourceFiles(source_file_filter):
978 if (f.LocalPath().endswith('.h') or f.LocalPath().endswith('.hxx') or
979 f.LocalPath().endswith('.hpp') or f.LocalPath().endswith('.inl')):
980 contents = input_api.ReadFile(f)
981 for line in contents.splitlines(False):
982 if (not input_api.re.match(r'//', line) and # Strip C++ comment.
983 pattern.search(line)):
984 files.append(f)
985 break
986
987 if files:
988 return [ output_api.PresubmitError(
989 'Found Singleton<T> in the following header files.\n' +
990 'Please move them to an appropriate source file so that the ' +
991 'template gets instantiated in a single compilation unit.',
992 files) ]
993 return [] 975 return []
M-A Ruel 2015/02/19 16:12:03 return [ output_api.PresubmitNotifyResult( '
Alexander Potapenko 2015/02/19 16:27:20 Done.
994 976
995 977
996 def PanProjectChecks(input_api, output_api, 978 def PanProjectChecks(input_api, output_api,
997 excluded_paths=None, text_files=None, 979 excluded_paths=None, text_files=None,
998 license_header=None, project_name=None, 980 license_header=None, project_name=None,
999 owners_check=True, maxlen=80): 981 owners_check=True, maxlen=80):
1000 """Checks that ALL chromium orbit projects should use. 982 """Checks that ALL chromium orbit projects should use.
1001 983
1002 These are checks to be run on all Chromium orbit project, including: 984 These are checks to be run on all Chromium orbit project, including:
1003 Chromium 985 Chromium
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 input_api, output_api, maxlen, source_file_filter=sources)) 1053 input_api, output_api, maxlen, source_file_filter=sources))
1072 snapshot( "checking tabs") 1054 snapshot( "checking tabs")
1073 results.extend(input_api.canned_checks.CheckChangeHasNoTabs( 1055 results.extend(input_api.canned_checks.CheckChangeHasNoTabs(
1074 input_api, output_api, source_file_filter=sources)) 1056 input_api, output_api, source_file_filter=sources))
1075 snapshot( "checking stray whitespace") 1057 snapshot( "checking stray whitespace")
1076 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace( 1058 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace(
1077 input_api, output_api, source_file_filter=sources)) 1059 input_api, output_api, source_file_filter=sources))
1078 snapshot("checking nsobjects") 1060 snapshot("checking nsobjects")
1079 results.extend(_CheckConstNSObject( 1061 results.extend(_CheckConstNSObject(
1080 input_api, output_api, source_file_filter=sources)) 1062 input_api, output_api, source_file_filter=sources))
1081 snapshot("checking singletons")
1082 results.extend(CheckSingletonInHeaders(
1083 input_api, output_api, source_file_filter=sources))
1084 1063
1085 # The following checks are only done on commit, since the commit bot will 1064 # The following checks are only done on commit, since the commit bot will
1086 # auto-fix most of these. 1065 # auto-fix most of these.
1087 if input_api.is_committing: 1066 if input_api.is_committing:
1088 snapshot("checking eol style") 1067 snapshot("checking eol style")
1089 results.extend(input_api.canned_checks.CheckChangeSvnEolStyle( 1068 results.extend(input_api.canned_checks.CheckChangeSvnEolStyle(
1090 input_api, output_api, source_file_filter=text_files)) 1069 input_api, output_api, source_file_filter=text_files))
1091 snapshot("checking svn mime types") 1070 snapshot("checking svn mime types")
1092 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( 1071 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes(
1093 input_api, output_api)) 1072 input_api, output_api))
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 for f in affected_files: 1113 for f in affected_files:
1135 cmd = ['gn', 'format', '--dry-run', f.AbsoluteLocalPath()] 1114 cmd = ['gn', 'format', '--dry-run', f.AbsoluteLocalPath()]
1136 rc = gn.main(cmd) 1115 rc = gn.main(cmd)
1137 if rc == 2: 1116 if rc == 2:
1138 warnings.append(output_api.PresubmitPromptWarning( 1117 warnings.append(output_api.PresubmitPromptWarning(
1139 '%s requires formatting. Please run `gn format --in-place %s`.' % ( 1118 '%s requires formatting. Please run `gn format --in-place %s`.' % (
1140 f.AbsoluteLocalPath(), f.LocalPath()))) 1119 f.AbsoluteLocalPath(), f.LocalPath())))
1141 # It's just a warning, so ignore other types of failures assuming they'll be 1120 # It's just a warning, so ignore other types of failures assuming they'll be
1142 # caught elsewhere. 1121 # caught elsewhere.
1143 return warnings 1122 return warnings
OLDNEW
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698