From cefaeea59243840f011d3ccb4ff3f0beb62e9a87 Mon Sep 17 00:00:00 2001 From: Peter Kasting Date: Tue, 23 Jul 2024 18:44:25 +0000 Subject: [PATCH] Avoid bogus lint complaints from `[[(un)likely]]` attributes. Bug: 40256217 Change-Id: Ia892985d03fc7b8c2316462d1dfe9a1d38c08cfd Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5735954 Reviewed-by: Gavin Mak Commit-Queue: Gavin Mak Auto-Submit: Peter Kasting Commit-Queue: Peter Kasting --- cpplint.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cpplint.py b/cpplint.py index a01ffa2bf3..087b0e849c 100755 --- a/cpplint.py +++ b/cpplint.py @@ -4106,10 +4106,12 @@ def CheckBraces(filename, clean_lines, linenum, error): endpos) = CloseExpression(clean_lines, linenum, pos) # Check for an opening brace, either directly after the if or on the # next line. If found, this isn't a single-statement conditional. - if (not Match(r'\s*{', endline[endpos:]) - and not (Match(r'\s*$', endline[endpos:]) and endlinenum < - (len(clean_lines.elided) - 1) and Match( - r'\s*{', clean_lines.elided[endlinenum + 1]))): + if (not Match(r'\s*(?:\[\[(?:un)?likely\]\]\s*)?{', endline[endpos:]) + and not (Match(r'\s*(?:\[\[(?:un)?likely\]\]\s*)?$', + endline[endpos:]) + and endlinenum < (len(clean_lines.elided) - 1) + and Match(r'\s*(?:\[\[(?:un)?likely\]\]\s*)?{', + clean_lines.elided[endlinenum + 1]))): while (endlinenum < len(clean_lines.elided) and ';' not in clean_lines.elided[endlinenum][endpos:]): endlinenum += 1