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

Unified Diff: PRESUBMIT.py

Issue 1213113004: Improve the diagnostics for include order presubmit checks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 | 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 885055b9ab70b2acc2888c623046c076d2e34489..2effa508e5e95c4b2b530f7a84522960376c8fe4 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -63,7 +63,7 @@ _TEST_ONLY_WARNING = (
_INCLUDE_ORDER_WARNING = (
'Your #include order seems to be broken. Remember to use the right '
- 'collation (LC_COLLATE=C) and check https://google-styleguide.googlecode'
+ 'collation (LC_COLLATE=C) and check\nhttps://google-styleguide.googlecode'
'.com/svn/trunk/cppguide.html#Names_and_Order_of_Includes')
_BANNED_OBJC_FUNCTIONS = (
@@ -702,33 +702,38 @@ def _CheckIncludeOrderForScope(scope, input_api, file_path, changed_linenums):
previous_line = ''
previous_line_num = 0
problem_linenums = []
+ out_of_order = " - line belongs before previous line"
for line_num, line in scope:
if c_system_include_pattern.match(line):
if state != C_SYSTEM_INCLUDES:
- problem_linenums.append((line_num, previous_line_num))
+ problem_linenums.append((line_num, previous_line_num,
+ " - C system include file in wrong block"))
elif previous_line and previous_line > line:
- problem_linenums.append((line_num, previous_line_num))
+ problem_linenums.append((line_num, previous_line_num,
+ out_of_order))
elif cpp_system_include_pattern.match(line):
if state == C_SYSTEM_INCLUDES:
state = CPP_SYSTEM_INCLUDES
elif state == CUSTOM_INCLUDES:
- problem_linenums.append((line_num, previous_line_num))
+ problem_linenums.append((line_num, previous_line_num,
+ " - c++ system include file in wrong block"))
elif previous_line and previous_line > line:
- problem_linenums.append((line_num, previous_line_num))
+ problem_linenums.append((line_num, previous_line_num, out_of_order))
elif custom_include_pattern.match(line):
if state != CUSTOM_INCLUDES:
state = CUSTOM_INCLUDES
elif previous_line and previous_line > line:
- problem_linenums.append((line_num, previous_line_num))
+ problem_linenums.append((line_num, previous_line_num, out_of_order))
else:
- problem_linenums.append(line_num)
+ problem_linenums.append((line_num, previous_line_num,
+ "Unknown include type"))
previous_line = line
previous_line_num = line_num
warnings = []
- for (line_num, previous_line_num) in problem_linenums:
+ for (line_num, previous_line_num, failure_type) in problem_linenums:
if line_num in changed_linenums or previous_line_num in changed_linenums:
- warnings.append(' %s:%d' % (file_path, line_num))
+ warnings.append(' %s:%d:%s' % (file_path, line_num, failure_type))
return warnings
« 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