diff options
author | Juan Gu <juan.gu@mongodb.com> | 2023-01-27 17:06:29 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-01-27 19:20:33 +0000 |
commit | 25639888e57caae19d152e89c4d68aa935618142 (patch) | |
tree | 1320aa9fa55663db1f7f467f79ef201197c9781a /buildscripts/clang_tidy.py | |
parent | c6969df9ebd72a89fbf23af9e14fef22d0dafd00 (diff) | |
download | mongo-25639888e57caae19d152e89c4d68aa935618142.tar.gz |
SERVER-73352 Modify how de-duplicate the clang tidy errors
Diffstat (limited to 'buildscripts/clang_tidy.py')
-rwxr-xr-x | buildscripts/clang_tidy.py | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/buildscripts/clang_tidy.py b/buildscripts/clang_tidy.py index 6725ab19cea..93fddeb02b6 100755 --- a/buildscripts/clang_tidy.py +++ b/buildscripts/clang_tidy.py @@ -5,6 +5,7 @@ import argparse import datetime import json import os +import re import subprocess import sys import locale @@ -95,13 +96,28 @@ def _combine_errors(fixes_filename: str, files_to_parse: List[str]) -> int: def __dedup_errors(clang_tidy_errors_threads: List[str]) -> str: - #use dict as an 'ordered set'(in python 3.6+), set value to dummy value(true here) - error_to_dummy_value = dict() + unique_single_errors = set() for errs in clang_tidy_errors_threads: if errs: - for val in errs.splitlines(): - error_to_dummy_value[val] = True - return os.linesep.join(error_to_dummy_value.keys()) + lines = errs.splitlines() + single_error_start_line = 0 + for i, line in enumerate(lines): + if line: + # the first line of one single error message like: + # ......./d_concurrency.h:175:13: error: ......... + # trying to match :lineNumber:colomnNumber: + matched_regex = re.match("(.+:[0-9]+:[0-9]+:)", line) + + # Collect a full single error message + # when we find another match or reach the last line of the text + if matched_regex and i != single_error_start_line: + unique_single_errors.add(tuple(lines[single_error_start_line:i])) + single_error_start_line = i + elif i == len(lines) - 1: + unique_single_errors.add(tuple(lines[single_error_start_line:i + 1])) + + unique_single_error_flatten = [item for sublist in unique_single_errors for item in sublist] + return os.linesep.join(unique_single_error_flatten) def main(): |