Skip to content

Commit 4722cad

Browse files
authored
Improve readability of result messages (#1016)
Fixes #956
1 parent a3d41ec commit 4722cad

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
- Added the `--no-color`/`--color` option to disable/enable colored output.
1010
- Exclude wrapped properties from assign-only analysis, as Periphery cannot observe the behavior of the property wrapper.
11+
- Improved the readability of result messages.
1112

1213
##### Bug Fixes
1314

Sources/PeripheryKit/Results/OutputFormatter.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,32 +42,30 @@ extension OutputFormatter {
4242
let kindDisplayName = declarationKindDisplayName(from: result.declaration)
4343

4444
if var name = result.declaration.name {
45-
description += "\(kindDisplayName.first?.uppercased() ?? "")\(kindDisplayName.dropFirst()) "
4645
name = colored ? Logger.colorize(name, .lightBlue) : name
47-
description += "'\(name)'"
4846

4947
switch result.annotation {
5048
case .unused:
51-
description += " is unused"
49+
description += "Unused \(kindDisplayName) '\(name)'"
5250
case .assignOnlyProperty:
53-
description += " is assigned, but never used"
51+
description += "Assign-only \(kindDisplayName) '\(name)' is assigned, but never used"
5452
case let .redundantProtocol(references, inherited):
55-
description += " is redundant as it's never used as an existential type"
53+
description += "Redundant protocol '\(name)' (never used as an existential type)"
5654
secondaryResults = references.map {
57-
var msg = "Protocol '\(name)' conformance is redundant"
55+
var msg = "Redundant protocol conformance '\(name)'"
5856

5957
if !inherited.isEmpty {
60-
msg += ", replace with '\(inherited.sorted().joined(separator: ", "))'"
58+
msg += " (replace with '\(inherited.sorted().joined(separator: ", "))')"
6159
}
6260

6361
return ($0.location, msg)
6462
}
6563
case let .redundantPublicAccessibility(modules):
6664
let modulesJoined = modules.sorted().joined(separator: ", ")
67-
description += " is declared public, but not used outside of \(modulesJoined)"
65+
description += "Redundant public accessibility for \(kindDisplayName) '\(name)' (not used outside of \(modulesJoined))"
6866
}
6967
} else {
70-
description += "unused"
68+
description += "Unused"
7169
}
7270

7371
return [(location, description)] + secondaryResults

0 commit comments

Comments
 (0)