From 5e4d74983ecbfb404909c7243c23cd733db4565d Mon Sep 17 00:00:00 2001 From: Bruce Dawson Date: Thu, 15 Sep 2022 00:35:17 +0000 Subject: [PATCH] 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 Commit-Queue: Bruce Dawson --- presubmit_canned_checks.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index 7e01cb8900..95112505aa 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -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