Skip to content

Commit 670c0c0

Browse files
authored
Calculate the fingerprint for an unused function parameter more statically (#568)
Co-authored-by: Felix Wehnert <[email protected]>
1 parent 2124ce5 commit 670c0c0

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Sources/Frontend/Formatters/CodeClimateFormatter.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,20 @@ final class CodeClimateFormatter: OutputFormatter {
2020
.map { $0.1 }
2121
.joined(separator: ", ")
2222

23+
let fingerprint: String
24+
if result.declaration.kind == .varParameter,
25+
let parentFingerprint = result.declaration.parent?.usrs.joined(separator: "."),
26+
let argumentName = result.declaration.name {
27+
// As function parameters do not have a mangled name that can be used for the fingerprint
28+
// we take the mangled name of the function and append the position
29+
fingerprint = "\(parentFingerprint)-\(argumentName)"
30+
} else {
31+
fingerprint = result.declaration.usrs.joined(separator: ".")
32+
}
33+
2334
let object: [AnyHashable: Any] = [
2435
"description": description,
25-
"fingerprint": result.declaration.usrs.joined(separator: "."),
36+
"fingerprint": fingerprint,
2637
"severity": "major",
2738
"location": location
2839
]

0 commit comments

Comments
 (0)