Skip to content

Commit

Permalink
Revert "Remove duplicates while merging fixes"
Browse files Browse the repository at this point in the history
This reverts commit f72373e.
  • Loading branch information
rhaschke committed Nov 3, 2022
1 parent 41ee805 commit 32e8dc1
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions industrial_ci/src/tests/merge_fixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,20 @@
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
# the top level key 'Diagnostics' in the output yaml 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(unique(content.get(mergekey, [])))
merged.extend(content.get(mergekey, []))
except FileNotFoundError:
pass

Expand Down

0 comments on commit 32e8dc1

Please sign in to comment.