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

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: Add a deprecation warning 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*<') 975 return [
976 files = [] 976 output_api.PresubmitNotifyResult(
977 for f in input_api.AffectedSourceFiles(source_file_filter): 977 'CheckSingletonInHeaders is deprecated, please remove it.')
978 if (f.LocalPath().endswith('.h') or f.LocalPath().endswith('.hxx') or 978 ]
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 []
994 979
995 980
996 def PanProjectChecks(input_api, output_api, 981 def PanProjectChecks(input_api, output_api,
997 excluded_paths=None, text_files=None, 982 excluded_paths=None, text_files=None,
998 license_header=None, project_name=None, 983 license_header=None, project_name=None,
999 owners_check=True, maxlen=80): 984 owners_check=True, maxlen=80):
1000 """Checks that ALL chromium orbit projects should use. 985 """Checks that ALL chromium orbit projects should use.
1001 986
1002 These are checks to be run on all Chromium orbit project, including: 987 These are checks to be run on all Chromium orbit project, including:
1003 Chromium 988 Chromium
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 input_api, output_api, maxlen, source_file_filter=sources)) 1056 input_api, output_api, maxlen, source_file_filter=sources))
1072 snapshot( "checking tabs") 1057 snapshot( "checking tabs")
1073 results.extend(input_api.canned_checks.CheckChangeHasNoTabs( 1058 results.extend(input_api.canned_checks.CheckChangeHasNoTabs(
1074 input_api, output_api, source_file_filter=sources)) 1059 input_api, output_api, source_file_filter=sources))
1075 snapshot( "checking stray whitespace") 1060 snapshot( "checking stray whitespace")
1076 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace( 1061 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace(
1077 input_api, output_api, source_file_filter=sources)) 1062 input_api, output_api, source_file_filter=sources))
1078 snapshot("checking nsobjects") 1063 snapshot("checking nsobjects")
1079 results.extend(_CheckConstNSObject( 1064 results.extend(_CheckConstNSObject(
1080 input_api, output_api, source_file_filter=sources)) 1065 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 1066
1085 # The following checks are only done on commit, since the commit bot will 1067 # The following checks are only done on commit, since the commit bot will
1086 # auto-fix most of these. 1068 # auto-fix most of these.
1087 if input_api.is_committing: 1069 if input_api.is_committing:
1088 snapshot("checking eol style") 1070 snapshot("checking eol style")
1089 results.extend(input_api.canned_checks.CheckChangeSvnEolStyle( 1071 results.extend(input_api.canned_checks.CheckChangeSvnEolStyle(
1090 input_api, output_api, source_file_filter=text_files)) 1072 input_api, output_api, source_file_filter=text_files))
1091 snapshot("checking svn mime types") 1073 snapshot("checking svn mime types")
1092 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( 1074 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes(
1093 input_api, output_api)) 1075 input_api, output_api))
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 for f in affected_files: 1116 for f in affected_files:
1135 cmd = ['gn', 'format', '--dry-run', f.AbsoluteLocalPath()] 1117 cmd = ['gn', 'format', '--dry-run', f.AbsoluteLocalPath()]
1136 rc = gn.main(cmd) 1118 rc = gn.main(cmd)
1137 if rc == 2: 1119 if rc == 2:
1138 warnings.append(output_api.PresubmitPromptWarning( 1120 warnings.append(output_api.PresubmitPromptWarning(
1139 '%s requires formatting. Please run `gn format --in-place %s`.' % ( 1121 '%s requires formatting. Please run `gn format --in-place %s`.' % (
1140 f.AbsoluteLocalPath(), f.LocalPath()))) 1122 f.AbsoluteLocalPath(), f.LocalPath())))
1141 # It's just a warning, so ignore other types of failures assuming they'll be 1123 # It's just a warning, so ignore other types of failures assuming they'll be
1142 # caught elsewhere. 1124 # caught elsewhere.
1143 return warnings 1125 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