Commit c833946a authored by Nico Weber's avatar Nico Weber Committed by Commit Bot

Remove const NSObject global presubmit.

I added this when we were moving from gcc to clang on OS X many years
ago.  Now that gcc has been deprecated on mac for many years, this
is safe to remove (clang errors on this pattern).

This check took 0.6s during `git cl presubmit` on a recent change of
mine, so it should speed presubmit up a bit.

Bug: none
Change-Id: Ia29b046807582e056115519fb5b34ee8a1b9ff91
Reviewed-on: https://chromium-review.googlesource.com/553238Reviewed-by: 's avatarDirk Pranke <dpranke@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
parent 29c2afdb
......@@ -976,33 +976,6 @@ def _GerritOwnerAndReviewers(input_api, email_regexp, approval_needed=False):
return owner_email, reviewers
def _CheckConstNSObject(input_api, output_api, source_file_filter):
"""Checks to make sure no objective-c files have |const NSSomeClass*|."""
pattern = input_api.re.compile(
r'(?<!reinterpret_cast<)'
r'const\s+NS(?!(Point|Range|Rect|Size)\s*\*)\w*\s*\*')
def objective_c_filter(f):
return (source_file_filter(f) and
input_api.os_path.splitext(f.LocalPath())[1] in ('.h', '.m', '.mm'))
files = []
for f in input_api.AffectedSourceFiles(objective_c_filter):
contents = input_api.ReadFile(f)
if pattern.search(contents):
files.append(f)
if files:
if input_api.is_committing:
res_type = output_api.PresubmitPromptWarning
else:
res_type = output_api.PresubmitNotifyResult
return [ res_type('|const NSClass*| is wrong, see ' +
'http://dev.chromium.org/developers/clang-mac',
files) ]
return []
def CheckSingletonInHeaders(input_api, output_api, source_file_filter=None):
"""Deprecated, must be removed."""
return [
......@@ -1093,9 +1066,6 @@ def PanProjectChecks(input_api, output_api,
snapshot( "checking stray whitespace")
results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace(
input_api, output_api, source_file_filter=sources))
snapshot("checking nsobjects")
results.extend(_CheckConstNSObject(
input_api, output_api, source_file_filter=sources))
snapshot("checking license")
results.extend(input_api.canned_checks.CheckLicense(
input_api, output_api, license_header, source_file_filter=sources))
......
......@@ -2694,16 +2694,17 @@ class CannedChecksUnittest(PresubmitTestsBase):
).AndReturn([affected_file])
affected_file.LocalPath()
affected_file.NewContents().AndReturn('Hey!\nHo!\nHey!\nHo!\n\n')
# CheckChangeHasNoTabs() calls _FindNewViolationsOfRule() which calls
# ChangedContents().
affected_file.ChangedContents().AndReturn([
(0, 'Hey!\n'),
(1, 'Ho!\n'),
(2, 'Hey!\n'),
(3, 'Ho!\n'),
(4, '\n')])
for _ in range(5):
for _ in range(5): # One for each ChangedContents().
affected_file.LocalPath().AndReturn('hello.py')
input_api.AffectedSourceFiles(mox.IgnoreArg()).AndReturn([affected_file])
input_api.ReadFile(affected_file).AndReturn('Hey!\nHo!\nHey!\nHo!\n\n')
# CheckingLicense() calls AffectedSourceFiles() instead of AffectedFiles().
input_api.AffectedSourceFiles(mox.IgnoreArg()).AndReturn([affected_file])
input_api.ReadFile(affected_file, 'rb').AndReturn(
'Hey!\nHo!\nHey!\nHo!\n\n')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment