diff --git a/industrial_ci/src/tests/merge_fixes.py b/industrial_ci/src/tests/merge_fixes.py index 73ad4ad94..afba1cda6 100755 --- a/industrial_ci/src/tests/merge_fixes.py +++ b/industrial_ci/src/tests/merge_fixes.py @@ -20,6 +20,13 @@ import sys +def key(item): + name = item.get("DiagnosticName") + msg = item.get("DiagnosticMessage") + file = msg.get("FilePath") + offset = msg.get("FileOffset") + return name, file, offset + def merge_fixes(files): """Merge all fixes files into mergefile""" # The fixes suggested by clang-tidy >= 4.0.0 are given under @@ -27,13 +34,22 @@ def merge_fixes(files): mergefile = files[0] mergekey = "Diagnostics" merged = [] + seen = set() # efficiently remember fixes already inserted + + def have(x): + k = key(x) + return k in seen or seen.add(k) + + def unique(seq): + return [x for x in seq if not have(x)] + for file in files: try: with open(file, 'r') as inp: content = yaml.safe_load(inp) if not content: continue # Skip empty files. - merged.extend(content.get(mergekey, [])) + merged.extend(unique(content.get(mergekey, []))) except FileNotFoundError: pass