INNER CODE UNIT · Python
compute_fingerprint
f-droid/fdroidclient · tools/checkstyle-to-codeclimate.py:84
def compute_fingerprint(
path: str, line: str, message: str, severity_raw: str, source: Optional[str]
) -> str:
"""Compute a stable fingerprint for an issue.
Combining multiple attributes reduces collision risk across similar messages.
"""
base = f"{path}:{line}:{severity_raw}:{message}:{source or ''}".encode("utf-8")
return hashlib.sha256(base).hexdigest()
def _relativize(path: str, base_dir: Optional[str]) -> str:
if not base_dir:
return path
try:
p = pathlib.Path(path)
base = pathlib.Path(base_dir)
return str(p.relative_to(base))