Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

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

##### Bug Fixes

Expand Down
16 changes: 7 additions & 9 deletions Sources/PeripheryKit/Results/OutputFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,30 @@ extension OutputFormatter {
let kindDisplayName = declarationKindDisplayName(from: result.declaration)

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

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

if !inherited.isEmpty {
msg += ", replace with '\(inherited.sorted().joined(separator: ", "))'"
msg += " (replace with '\(inherited.sorted().joined(separator: ", "))')"
}

return ($0.location, msg)
}
case let .redundantPublicAccessibility(modules):
let modulesJoined = modules.sorted().joined(separator: ", ")
description += " is declared public, but not used outside of \(modulesJoined)"
description += "Redundant public accessibility for \(kindDisplayName) '\(name)' (not used outside of \(modulesJoined))"
}
} else {
description += "unused"
description += "Unused"
}

return [(location, description)] + secondaryResults
Expand Down