Revision 8c62eaa99c5e8233c3d0e0489126faf25d8cafc0 authored by Dmitri Naumov on 15 March 2021, 21:14:42 UTC, committed by Dmitri Naumov on 15 March 2021, 21:18:15 UTC
1 parent dd9b10a
Raw File
cppcheck_gen_hashes.py
# Inserts hashes of description + file path as GitLab code quality fingerprint
import hashlib
import json
import sys

data = None
with open(sys.argv[1]) as json_file:
    data = json.load(json_file)

for entry in data:
    desc = entry["description"]
    path = entry["location"]["path"]
    hash = hashlib.sha256((desc + path).encode("utf-8")).hexdigest()
    entry["fingerprint"] = hash

with open(sys.argv[1], "w") as outfile:
    json.dump(data, outfile)

print("Added cppcheck fingerprints to {}.".format(sys.argv[1]))
back to top