Skip to content

Commit 0c1dbd6

Browse files
RISCfutureclaude
andcommitted
Remove dead code flagged by Periphery
Prune unused symbols the scan flagged and enforce `periphery scan --strict` in CI. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent fc91100 commit 0c1dbd6

13 files changed

Lines changed: 39 additions & 80 deletions

File tree

.github/workflows/periphery.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ jobs:
1717
- name: Install Periphery
1818
run: brew install periphery
1919
- name: Run Periphery
20-
run: periphery scan
20+
run: periphery scan --strict

.periphery.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,18 @@
11
retain_public: true
2+
3+
# The CIFPDataLinkable / ProcedureLinkable / AirwayLinkable protocols are a live
4+
# linking-architecture design: CIFPData calls injectLegResolvers/injectFixResolvers
5+
# and sets `data` on conformers. Periphery flags them as "redundant" only because they
6+
# are never used as existential types, so they carry targeted `// periphery:ignore`
7+
# comments. In Periphery 3.7.4 such an ignore (which correctly suppresses the
8+
# redundant-protocol finding) is itself reported as a superfluous ignore comment under
9+
# --strict, so superfluous-ignore reporting is disabled to retain the architecture.
10+
superfluous_ignore_comments: false
11+
12+
# ASCII.swift is a deliberately complete byte-constant table (full A-Z, 0-9,
13+
# punctuation) plus isUpperAlpha/isAlphanumeric helpers. Its currently unused
14+
# members are intentional, so retain the whole file. (Periphery 3.7.4 does not
15+
# propagate `// periphery:ignore:all` to an enum's static members, so file-level
16+
# retention is used instead of a comment directive.)
17+
retain_files:
18+
- "**/Parser/ASCII.swift"

Sources/SwiftCIFP/CIFPDataLinkable.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import Foundation
99
/// - Note: Conforming types should declare the `data` property as `weak`
1010
/// to avoid retain cycles with the parent `CIFPData` actor.
1111
protocol CIFPDataLinkable {
12+
// periphery:ignore - Live linking-architecture requirement; flagged only because the
13+
// protocol is never used as an existential type. Conforming models set this property.
1214
/// Reference to the parent CIFPData container.
1315
///
1416
/// This property is set by `CIFPData` when establishing model links.
@@ -42,6 +44,9 @@ typealias NavaidResolver =
4244
_ sectionCode: String?
4345
) async -> Navaid?
4446

47+
// periphery:ignore - Live linking-architecture protocol; injectLegResolvers is called in
48+
// CIFPData.swift. Periphery flags it "redundant" only because it is never used as an
49+
// existential type. Do not collapse into CIFPDataLinkable.
4550
/// Protocol for procedure models that contain legs requiring closure injection.
4651
///
4752
/// Procedures (SID, STAR, Approach) contain nested `ProcedureLeg` structures
@@ -62,6 +67,9 @@ protocol ProcedureLinkable: CIFPDataLinkable {
6267
)
6368
}
6469

70+
// periphery:ignore - Live linking-architecture protocol; injectFixResolvers is called in
71+
// CIFPData.swift. Periphery flags it "redundant" only because it is never used as an
72+
// existential type. Do not collapse into CIFPDataLinkable.
6573
/// Protocol for airway models that contain fixes requiring closure injection.
6674
///
6775
/// Airways contain nested `AirwayFix` structures that need to resolve

Sources/SwiftCIFP/Models/Heliport/HeliportApproach.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ public struct HeliportApproach: Sendable, Codable, ProcedureLinkable {
88
/// Reference to the parent CIFPData container for model linking.
99
public weak var data: CIFPData?
1010

11-
/// Closure for resolving fix identifiers (internal use).
12-
var findFix: FixResolver?
13-
14-
/// Closure for resolving navaid identifiers (internal use).
15-
var findNavaid: NavaidResolver?
16-
1711
/// Parent heliport ICAO identifier.
1812
let parentId: String
1913

@@ -59,7 +53,7 @@ public struct HeliportApproach: Sendable, Codable, ProcedureLinkable {
5953
private enum CodingKeys: String, CodingKey {
6054
case parentId, icaoRegion, identifier, approachType
6155
case transitionId, legs, missedApproachLegs
62-
// Note: 'data', 'findFix', 'findNavaid' are excluded
56+
// Note: 'data' is excluded
6357
}
6458
}
6559

@@ -91,9 +85,6 @@ extension HeliportApproach {
9185
findFix: @escaping FixResolver,
9286
findNavaid: @escaping NavaidResolver
9387
) {
94-
self.findFix = findFix
95-
self.findNavaid = findNavaid
96-
9788
// Inject into approach legs
9889
for i in legs.indices {
9990
legs[i].findFix = findFix

Sources/SwiftCIFP/Models/Procedures/Approach.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ public struct Approach: Sendable, Codable, ProcedureLinkable {
1111
/// Reference to the parent CIFPData container for model linking.
1212
public weak var data: CIFPData?
1313

14-
/// Closure for resolving fix identifiers (internal use).
15-
var findFix: FixResolver?
16-
17-
/// Closure for resolving navaid identifiers (internal use).
18-
var findNavaid: NavaidResolver?
19-
2014
/// Parent airport ICAO identifier.
2115
let airportId: String
2216

@@ -131,7 +125,7 @@ public struct Approach: Sendable, Codable, ProcedureLinkable {
131125
case routeType, transitionId, runwayId
132126
case multipleIndicator, legs, missedApproachLegs
133127
case sbasServiceLevel, requiredNavPerformance, lateralNavCapability
134-
// Note: 'data', 'findFix', 'findNavaid' are excluded
128+
// Note: 'data' is excluded
135129
}
136130
}
137131

@@ -175,9 +169,6 @@ extension Approach {
175169
findFix: @escaping FixResolver,
176170
findNavaid: @escaping NavaidResolver
177171
) {
178-
self.findFix = findFix
179-
self.findNavaid = findNavaid
180-
181172
// Inject into approach legs
182173
for i in legs.indices {
183174
legs[i].findFix = findFix

Sources/SwiftCIFP/Models/Procedures/SID.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ public struct SID: Sendable, Codable, ProcedureLinkable {
1111
/// Reference to the parent CIFPData container for model linking.
1212
public weak var data: CIFPData?
1313

14-
/// Closure for resolving fix identifiers (internal use).
15-
var findFix: FixResolver?
16-
17-
/// Closure for resolving navaid identifiers (internal use).
18-
var findNavaid: NavaidResolver?
19-
2014
/// Parent airport ICAO identifier.
2115
let airportId: String
2216

@@ -72,7 +66,7 @@ public struct SID: Sendable, Codable, ProcedureLinkable {
7266
private enum CodingKeys: String, CodingKey {
7367
case airportId, icaoRegion, identifier, routeType
7468
case transitionId, runwayNames = "runways", legs
75-
// Note: 'data', 'findFix', 'findNavaid' are excluded
69+
// Note: 'data' is excluded
7670
}
7771
}
7872

@@ -116,9 +110,6 @@ extension SID {
116110
findFix: @escaping FixResolver,
117111
findNavaid: @escaping NavaidResolver
118112
) {
119-
self.findFix = findFix
120-
self.findNavaid = findNavaid
121-
122113
// Inject into all legs
123114
for i in legs.indices {
124115
legs[i].findFix = findFix

Sources/SwiftCIFP/Models/Procedures/STAR.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ public struct STAR: Sendable, Codable, ProcedureLinkable {
1111
/// Reference to the parent CIFPData container for model linking.
1212
public weak var data: CIFPData?
1313

14-
/// Closure for resolving fix identifiers (internal use).
15-
var findFix: FixResolver?
16-
17-
/// Closure for resolving navaid identifiers (internal use).
18-
var findNavaid: NavaidResolver?
19-
2014
/// Parent airport ICAO identifier.
2115
let airportId: String
2216

@@ -77,7 +71,7 @@ public struct STAR: Sendable, Codable, ProcedureLinkable {
7771
private enum CodingKeys: String, CodingKey {
7872
case airportId, icaoRegion, identifier, routeType
7973
case transitionId, runwayNames = "runways", legs
80-
// Note: 'data', 'findFix', 'findNavaid' are excluded
74+
// Note: 'data' is excluded
8175
}
8276
}
8377

@@ -121,9 +115,6 @@ extension STAR {
121115
findFix: @escaping FixResolver,
122116
findNavaid: @escaping NavaidResolver
123117
) {
124-
self.findFix = findFix
125-
self.findNavaid = findNavaid
126-
127118
// Inject into all legs
128119
for i in legs.indices {
129120
legs[i].findFix = findFix

Sources/SwiftCIFP/Models/Standalone/Airway.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,6 @@ public struct Airway: Sendable, Codable, AirwayLinkable {
195195
/// Reference to the parent CIFPData container for model linking.
196196
public weak var data: CIFPData?
197197

198-
/// Closure for resolving fix identifiers (internal use).
199-
var findFix: FixResolver?
200-
201198
/// The airway identifier (e.g., "V1", "J60", "Q105").
202199
public let identifier: String
203200

@@ -237,7 +234,7 @@ public struct Airway: Sendable, Codable, AirwayLinkable {
237234

238235
private enum CodingKeys: String, CodingKey {
239236
case identifier, routeType, level, fixes
240-
// Note: 'data', 'findFix' are excluded
237+
// Note: 'data' is excluded
241238
}
242239
}
243240

@@ -246,8 +243,6 @@ public struct Airway: Sendable, Codable, AirwayLinkable {
246243
extension Airway {
247244
/// Injects fix resolver closures into the airway's fixes.
248245
mutating func injectFixResolvers(findFix: @escaping FixResolver) {
249-
self.findFix = findFix
250-
251246
// Inject into all fixes
252247
for i in fixes.indices {
253248
fixes[i].findFix = findFix

Sources/SwiftCIFP/Parser/ASCII.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import Foundation
22

33
/// ASCII byte constants for efficient byte-level parsing.
4+
///
5+
/// This is a deliberately complete byte-constant table (full A-Z, 0-9, and
6+
/// punctuation) plus the `isUpperAlpha`/`isAlphanumeric` helpers. The currently
7+
/// unused members are retained intentionally so the table stays whole and
8+
/// callers can reference any byte without piecemeal additions. Whole-file
9+
/// retention is configured in `.periphery.yml` (`retain_files`) rather than a
10+
/// comment directive, because Periphery 3.7.4 does not propagate
11+
/// `// periphery:ignore:all` to an enum's static members.
412
@usableFromInline
513
enum ASCII {
614
@usableFromInline static let LF: UInt8 = 0x0A // '\n'

Sources/SwiftCIFP/Parser/ByteParsing.swift

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,6 @@ extension RandomAccessCollection where Element == UInt8, Index == Int {
9999
return negative ? -value : value
100100
}
101101

102-
/// Get a single byte at offset, or nil if out of bounds.
103-
@inlinable
104-
func byte(at offset: Int) -> UInt8? {
105-
let idx = startIndex + offset
106-
guard idx < endIndex else { return nil }
107-
return self[idx]
108-
}
109-
110102
/// Get a subsequence using a relative range from startIndex.
111103
@inlinable
112104
func slice(_ range: Range<Int>) -> SubSequence {
@@ -115,20 +107,6 @@ extension RandomAccessCollection where Element == UInt8, Index == Int {
115107
return self[lower..<Swift.min(upper, endIndex)]
116108
}
117109

118-
/// Check if bytes match a string (trimming trailing whitespace).
119-
@inlinable
120-
func matches(_ string: String) -> Bool {
121-
let target = Array(string.utf8)
122-
var selfTrimmed = self[...]
123-
124-
while let last = selfTrimmed.last, last == ASCII.space {
125-
selfTrimmed = selfTrimmed.dropLast()
126-
}
127-
128-
guard selfTrimmed.count == target.count else { return false }
129-
return zip(selfTrimmed, target).allSatisfy { $0 == $1 }
130-
}
131-
132110
/// Convert to trimmed String (only when actually needed).
133111
@inlinable
134112
func toString() -> String {

0 commit comments

Comments
 (0)