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

Unified Diff: presubmit_canned_checks.py

Issue 118527: Add CheckChangeHasNoStrayWhitespace(). (Closed)
Patch Set: Created 11 years, 6 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 | tests/presubmit_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: presubmit_canned_checks.py
diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py
index aad8b08691027b76e2a2afef824dc9b3d5322f28..dd3313196c137438f98d45859ee891f148ac1e7d 100755
--- a/presubmit_canned_checks.py
+++ b/presubmit_canned_checks.py
@@ -144,6 +144,20 @@ def CheckChangeHasNoTabs(input_api, output_api, source_file_filter=None):
return []
+def CheckChangeHasNoStrayWhitespace(input_api, output_api,
+ source_file_filter=None):
+ """Checks that there is no stray whitespace at source lines end."""
+ errors = []
+ for f, line_num, line in input_api.RightHandSideLines(source_file_filter):
+ if line.rstrip() != line:
+ errors.append("%s, line %s" % (f.LocalPath(), line_num))
+ if errors:
+ return [output_api.PresubmitPromptWarning(
+ "Found line ending with white spaces in:",
+ long_text="\n".join(errors))]
+ return []
+
+
def CheckLongLines(input_api, output_api, maxlen=80, source_file_filter=None):
"""Checks that there aren't any lines longer than maxlen characters in any of
the text files to be submitted.
« 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