Skip to content

Commit fe6b26a

Browse files
committed
Group internal cppcheck errors to extract them from the bounty list
1 parent efe7ee7 commit fe6b26a

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

tools/Cppcheck/generate_cppcheck_suppressions_list.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ def generate_suppressions(xml_tree: ET.ElementTree, old_source_root: str) -> Lis
8787

8888
# Build list of suppression objects
8989
suppressions = []
90+
# Create a separate list of internal cppcheck errors
91+
internal_errors = []
9092
for error in errors:
9193
error_type = error.get("id")
9294
# checkersReport has no location
@@ -98,19 +100,29 @@ def generate_suppressions(xml_tree: ET.ElementTree, old_source_root: str) -> Lis
98100
file_path = location.get("file")
99101
file_path = file_path.replace(old_source_root, NEW_SOURCE_ROOT)
100102
line_number = int(location.get("line"))
101-
102-
suppressions.append(CppcheckSuppression(error_type=error_type, file_path=file_path, line_number=line_number))
103+
if error_type == "internalError":
104+
internal_errors.append(CppcheckSuppression(error_type=error_type, file_path=file_path, line_number=line_number))
105+
else:
106+
suppressions.append(CppcheckSuppression(error_type=error_type, file_path=file_path, line_number=line_number))
103107

104108
# Sort the suppressions by file name and line number.
105109
suppressions.sort()
110+
internal_errors.sort()
106111

107112
# Convert to strings and remove any duplicates.
108113
suppression_strings = []
114+
109115
for suppression in suppressions:
110116
suppression_string = suppression.suppression_string()
111117
if suppression_string not in suppression_strings:
112118
suppression_strings.append(suppression_string)
113119

120+
# Group the internal errors together so they can be moved out of the suppressions list easily.
121+
for internal_error in internal_errors:
122+
suppression_string = internal_error.suppression_string()
123+
if suppression_string not in suppression_strings:
124+
suppression_strings.append(suppression_string)
125+
114126
return suppression_strings
115127

116128

0 commit comments

Comments
 (0)