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

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: Removed the presubmit test 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') | tests/presubmit_unittest.py » ('J')
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 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 if input_api.is_committing: 963 if input_api.is_committing:
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):
974 """Checks to make sure no header files have |Singleton<|."""
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 []
994
995
996 def PanProjectChecks(input_api, output_api, 973 def PanProjectChecks(input_api, output_api,
997 excluded_paths=None, text_files=None, 974 excluded_paths=None, text_files=None,
998 license_header=None, project_name=None, 975 license_header=None, project_name=None,
999 owners_check=True, maxlen=80): 976 owners_check=True, maxlen=80):
1000 """Checks that ALL chromium orbit projects should use. 977 """Checks that ALL chromium orbit projects should use.
1001 978
1002 These are checks to be run on all Chromium orbit project, including: 979 These are checks to be run on all Chromium orbit project, including:
1003 Chromium 980 Chromium
1004 Native Client 981 Native Client
1005 V8 982 V8
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 input_api, output_api, maxlen, source_file_filter=sources)) 1048 input_api, output_api, maxlen, source_file_filter=sources))
1072 snapshot( "checking tabs") 1049 snapshot( "checking tabs")
1073 results.extend(input_api.canned_checks.CheckChangeHasNoTabs( 1050 results.extend(input_api.canned_checks.CheckChangeHasNoTabs(
1074 input_api, output_api, source_file_filter=sources)) 1051 input_api, output_api, source_file_filter=sources))
1075 snapshot( "checking stray whitespace") 1052 snapshot( "checking stray whitespace")
1076 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace( 1053 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace(
1077 input_api, output_api, source_file_filter=sources)) 1054 input_api, output_api, source_file_filter=sources))
1078 snapshot("checking nsobjects") 1055 snapshot("checking nsobjects")
1079 results.extend(_CheckConstNSObject( 1056 results.extend(_CheckConstNSObject(
1080 input_api, output_api, source_file_filter=sources)) 1057 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 1058
1085 # The following checks are only done on commit, since the commit bot will 1059 # The following checks are only done on commit, since the commit bot will
1086 # auto-fix most of these. 1060 # auto-fix most of these.
1087 if input_api.is_committing: 1061 if input_api.is_committing:
1088 snapshot("checking eol style") 1062 snapshot("checking eol style")
1089 results.extend(input_api.canned_checks.CheckChangeSvnEolStyle( 1063 results.extend(input_api.canned_checks.CheckChangeSvnEolStyle(
1090 input_api, output_api, source_file_filter=text_files)) 1064 input_api, output_api, source_file_filter=text_files))
1091 snapshot("checking svn mime types") 1065 snapshot("checking svn mime types")
1092 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( 1066 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes(
1093 input_api, output_api)) 1067 input_api, output_api))
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 for f in affected_files: 1108 for f in affected_files:
1135 cmd = ['gn', 'format', '--dry-run', f.AbsoluteLocalPath()] 1109 cmd = ['gn', 'format', '--dry-run', f.AbsoluteLocalPath()]
1136 rc = gn.main(cmd) 1110 rc = gn.main(cmd)
1137 if rc == 2: 1111 if rc == 2:
1138 warnings.append(output_api.PresubmitPromptWarning( 1112 warnings.append(output_api.PresubmitPromptWarning(
1139 '%s requires formatting. Please run `gn format --in-place %s`.' % ( 1113 '%s requires formatting. Please run `gn format --in-place %s`.' % (
1140 f.AbsoluteLocalPath(), f.LocalPath()))) 1114 f.AbsoluteLocalPath(), f.LocalPath())))
1141 # It's just a warning, so ignore other types of failures assuming they'll be 1115 # It's just a warning, so ignore other types of failures assuming they'll be
1142 # caught elsewhere. 1116 # caught elsewhere.
1143 return warnings 1117 return warnings
OLDNEW
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | tests/presubmit_unittest.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698