Commit 5e4d7498 authored by Bruce Dawson's avatar Bruce Dawson Committed by LUCI CQ

Support a tag to ignore long lines

Long lines in source files are bad, but sometimes unavoidable. Since
ignoring warnings is even worse than long lines it is wise to have a way
to disable the warning. This change adds support for a multi-language
tag that can be put in unavoidably long lines.

Bug: 1309977
Change-Id: I205086050b5aa5b4a02a651c06615c82ec0e1a38
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3896084Reviewed-by: 's avatarDmitrii Kuragin <kuragin@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
parent 9ebcfa6b
......@@ -529,6 +529,7 @@ def CheckLongLines(input_api, output_api, maxlen, source_file_filter=None):
]
def no_long_lines(file_extension, line):
"""Returns True if the line length is okay."""
# Check for language specific exceptions.
if any(file_extension in exts and line.lstrip().startswith(exceptions)
for exts, exceptions in LANGUAGE_EXCEPTIONS):
......@@ -548,6 +549,9 @@ def CheckLongLines(input_api, output_api, maxlen, source_file_filter=None):
if any((url in line) for url in ('file://', 'http://', 'https://')):
return True
if 'presubmit: ignore-long-line' in line:
return True
if line_len > extra_maxlen:
return False
......
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