in bot/code_review_bot/tasks/clang_format.py [0:0]
def __init__(self, analyzer, path, lines, revision):
assert isinstance(lines, list)
assert len(lines) > 0, "No lines describing patch"
# Find position of first different line
try:
first_diff = [old != new for old, new, _ in lines].index(True)
except ValueError:
first_diff = 0
lines = lines[first_diff:]
# Get the lines impacted by the patch
old_nb, new_nb, _ = zip(*lines)
line = min(filter(None, old_nb))
nb_lines = max(filter(None, old_nb)) - line + 1
# Build the fix to display on reporters
fix = "\n".join([line.decode("utf-8") for _, nb, line in lines if nb])
super().__init__(
analyzer,
revision,
path,
line,
nb_lines,
check="invalid-styling",
fix=fix,
language="c++",
message="The change does not follow the C/C++ coding style, please reformat",
level=Level.Warning,
)