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

Unified Diff: cc/PRESUBMIT.py

Issue 23591027: Allow NOLINT to skip the std::abs PRESUBMIT check. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | cc/output/shader.cc » ('j') | cc/output/shader.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/PRESUBMIT.py
diff --git a/cc/PRESUBMIT.py b/cc/PRESUBMIT.py
index bcf71ef0d52800f862be518a40f0bce2be1d7709..051a3eef28ec35bc3bba0392b24a302023ce1b4f 100644
--- a/cc/PRESUBMIT.py
+++ b/cc/PRESUBMIT.py
@@ -76,9 +76,16 @@ def CheckStdAbs(input_api, output_api,
found_fabs_files.append(f.LocalPath());
# The following regular expression in words says:
# "if there is no 'std::' behind an 'abs(' or 'absf(',
- # or if there is no 'std::' behind a 'fabs(' or 'fabsf(',
+ # OR if there is no 'std::' behind a 'fabs(' or 'fabsf(',
+ # AND if there's no '// NOLINT' on the same line of code,
# then it's a match."
- if re.search(r"((?<!std::)(\babsf?\()|(?<!std::)(\bfabsf?\())", contents):
+ # Note that \ characters have to be escaped since these
+ # are not explicitly defined as regexes.
+ no_abs = "((?<!std::)(\\babsf?\\()"
+ no_fabs = "(?<!std::)(\\bfabsf?\\())"
+ no_nolint = "(?![^\\n]*// NOLINT)"
enne (OOO) 2013/09/05 01:00:40 Maybe \s+ instead of the space in NOLINT?
+ expression = re.compile("%s|%s%s" % (no_abs, no_fabs, no_nolint))
enne (OOO) 2013/09/05 01:00:40 If you're going to put an | outside of the strings
+ if expression.search(contents):
missing_std_prefix_files.append(f.LocalPath())
result = []
« no previous file with comments | « no previous file | cc/output/shader.cc » ('j') | cc/output/shader.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698