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/+/3896084
Reviewed-by: Dmitrii Kuragin <kuragin@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
changes/84/3896084/2
Bruce Dawson 3 years ago committed by LUCI CQ
parent 9ebcfa6be1
commit 5e4d74983e

@ -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

Loading…
Cancel
Save