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

Unified Diff: PRESUBMIT.py

Issue 3082016: Add a presubmit check that catches |const NSString*| and friends. (Closed)
Patch Set: search instead of find Created 10 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT.py
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 4fd988da9c78c5433fa2d6eae43951d6d136968f..4c0aff1fbbdeef2a5443041f53c99210d0d15866 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -30,6 +30,27 @@ _LICENSE_HEADER = (
)
+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'const\s+NS\w*\s*\*')
+ files = []
+ for f in input_api.AffectedSourceFiles(source_file_filter):
+ if f.LocalPath().endswith('.h') or f.LocalPath().endswith('.mm'):
+ contents = input_api.ReadFile(f)
+ if pattern.search(contents):
+ files.append(f)
+
+ if len(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 _CommonChecks(input_api, output_api):
results = []
# What does this code do?
@@ -58,6 +79,8 @@ def _CommonChecks(input_api, output_api):
input_api, output_api))
results.extend(input_api.canned_checks.CheckLicense(
input_api, output_api, _LICENSE_HEADER, source_file_filter=sources))
+ results.extend(_CheckConstNSObject(
+ input_api, output_api, source_file_filter=sources))
return results
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698