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 <gavinmak@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
changes/54/5735954/2
Peter Kasting 1 year ago committed by LUCI CQ
parent babe2e0119
commit cefaeea592

10
cpplint.py vendored

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

Loading…
Cancel
Save