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
18 changes: 18 additions & 0 deletions .github/workflows/periphery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Periphery
on:
push:
branches: [master]
pull_request:
jobs:
periphery:
name: Run Periphery
runs-on: macos-latest
steps:
- uses: actions/checkout@v6
- uses: SwiftyLab/setup-swift@latest
with:
swift-version: "6.2"
- name: Install Periphery
run: brew install peripheryapp/periphery/periphery
- name: Run Periphery
run: periphery scan
1 change: 1 addition & 0 deletions .periphery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
retain_public: true
38 changes: 0 additions & 38 deletions Sources/SwiftNASR/Distribution/Distribution.swift
Original file line number Diff line number Diff line change
@@ -1,29 +1,5 @@
import Foundation

private let metatypes =
[
(RecordType.states, State.self),
(RecordType.airports, Airport.self),
(RecordType.ARTCCFacilities, ARTCC.self),
(RecordType.reportingPoints, Fix.self),
(RecordType.weatherReportingStations, WeatherStation.self),
(RecordType.airways, Airway.self),
(RecordType.ILSes, ILS.self),
(RecordType.terminalCommFacilities, TerminalCommFacility.self),
(RecordType.departureArrivalProceduresComplete, DepartureArrivalProcedure.self),
(RecordType.preferredRoutes, PreferredRoute.self),
(RecordType.holds, Hold.self),
(RecordType.weatherReportingLocations, WeatherReportingLocation.self),
(RecordType.parachuteJumpAreas, ParachuteJumpArea.self),
(RecordType.militaryTrainingRoutes, MilitaryTrainingRoute.self),
(RecordType.codedDepartureRoutes, CodedDepartureRoute.self),
(RecordType.miscActivityAreas, MiscActivityArea.self),
(RecordType.ARTCCBoundarySegments, ARTCCBoundarySegment.self),
(RecordType.FSSCommFacilities, FSSCommFacility.self),
(RecordType.ATSAirways, ATSAirway.self),
(RecordType.locationIdentifiers, LocationIdentifier.self)
] as [(RecordType, any Record.Type)]

/// Record types available to load from a distribution.
public enum RecordType: String, Codable, Sendable {
case ARTCCFacilities = "AFF"
Expand Down Expand Up @@ -51,20 +27,6 @@ public enum RecordType: String, Codable, Sendable {
/// This is a pseudo-record-type intended to represent the `STATE.txt` file.
/// `states` is not a loadable record type.
case states = "_ST"

var metatype: any Record.Type {
guard let type = metatypes.first(where: { $0.0 == self })?.1 else {
preconditionFailure("Unsupported type \(self)")
}
return type
}

static func forType(_ type: any Record.Type) -> Self {
guard let value = metatypes.first(where: { $0.1 == type })?.0 else {
preconditionFailure("Unsupported type \(type)")
}
return value
}
}

/// Global actor that guarantees exclusive access to the distribution file.
Expand Down
6 changes: 0 additions & 6 deletions Sources/SwiftNASR/Loaders/ArchiveLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ public final class ArchiveLoader: Loader {
/// The data format for the archive (.txt or .csv).
public let format: DataFormat

private let queue = DispatchQueue(
label: "codes.tim.SwiftNASR.ArchiveLoader",
qos: .utility,
attributes: .concurrent
)

/**
Creates a loader that loads from a given location on disk.

Expand Down
12 changes: 0 additions & 12 deletions Sources/SwiftNASR/Models/Records/Airport/Remark.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,6 @@ public struct Remarks<F: RemarkField>: Record {
/// All remarks added to the record.
public var remarks = [Remark<F>]()

/// Remarks applied to a record as a whole.
var general: [String] {
var remarks = [String]()

for remark in self.remarks {
guard case .general(let content) = remark else { break }
remarks.append(content)
}

return remarks
}

/**
Gets the remarks for a specific field.

Expand Down
17 changes: 0 additions & 17 deletions Sources/SwiftNASR/Parsers/CSV/CSVHeaderMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ struct CSVHeaderMap: Sendable {

// MARK: - Methods

/// Check if a column exists in this CSV.
/// - Parameter columnName: The column name to check.
/// - Returns: True if the column exists.
func contains(_ columnName: String) -> Bool {
nameToIndex[columnName] != nil
}

/// Validate that all required columns exist.
/// - Parameter requiredColumns: Array of column names that must be present.
/// - Throws: `CSVParserError.missingRequiredColumns` if any are missing.
Expand All @@ -45,16 +38,6 @@ struct CSVHeaderMap: Sendable {
}
}

/// Build an index array for transformer compatibility.
///
/// Returns -1 for columns that don't exist, allowing transformers
/// to handle missing optional columns gracefully.
/// - Parameter columnNames: The column names to map.
/// - Returns: Array of indices (-1 for missing columns).
func indices(for columnNames: [String]) -> [Int] {
columnNames.map { nameToIndex[$0] ?? -1 }
}

// MARK: - Subscripts

/// Look up column index by name.
Expand Down
3 changes: 0 additions & 3 deletions Sources/SwiftNASR/Parsers/CSV/CSVRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ struct CSVRow: Sendable {
/// The raw field values for this row.
let values: [String]

/// Number of fields in this row.
var count: Int { values.count }

// MARK: - Methods

/// Access a field that should exist but may be empty.
Expand Down
9 changes: 0 additions & 9 deletions Sources/SwiftNASR/Parsers/Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,6 @@ final class OffsetParser: Sendable {
}
}

extension Parser {
static func raw<T: RecordEnum>(_ rawValue: T.RawValue, toEnum _: T.Type) throws -> T {
guard let val = T.for(rawValue) else {
throw ParserError.unknownRecordEnumValue(rawValue)
}
return val
}
}

enum ParserError: Swift.Error, CustomStringConvertible {
case badData(_ reason: String)
case unknownRecordIdentifier(_ recordIdentifier: String)
Expand Down
16 changes: 0 additions & 16 deletions Sources/SwiftNASR/Parsers/Record Parsers/FSSParser/FSSParser.swift
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
import Foundation

private var dateFormatter: DateFormatter {
let df = DateFormatter()
df.dateFormat = "dd MMM yyyy"
df.locale = Locale(identifier: "en_US_POSIX")
df.timeZone = zulu
return df
}

private var lastUpdatedDateFormatter: DateFormatter {
let df = DateFormatter()
df.dateFormat = "dd MMM yyyy"
df.locale = Locale(identifier: "en_US_POSIX")
df.timeZone = zulu
return df
}

actor FixedWidthFSSParser: FixedWidthNoRecordIDParser {
static let type: RecordType = .flightServiceStations
var formats = [NASRTable]()
Expand Down
2 changes: 0 additions & 2 deletions Sources/SwiftNASR/Parsers/Record Parsers/NavaidParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,6 @@ actor FixedWidthNavaidParser: FixedWidthParser {
}
}

private let classDesignatorDelimiters = CharacterSet(charactersIn: "-/")

private func parseLFRLegs(_ string: String, fieldIndex: Int) throws -> [(LFRLeg.Quadrant, UInt)] {
let scanner = Scanner(string: string)
var legs = [(LFRLeg.Quadrant, UInt)]()
Expand Down
1 change: 0 additions & 1 deletion Sources/SwiftNASR/Support/JSONZipCoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public class JSONZipDecoder: JSONDecoder, @unchecked Sendable {
}

enum JSONZipError: Swift.Error {
case couldntCreateArchive
case couldntReadArchive
case emptyArchive
case noDistributionFile
Expand Down
2 changes: 0 additions & 2 deletions Sources/SwiftNASR/Support/String+SwiftNASR.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import Foundation

extension String {
var nsRange: NSRange { return NSRange(location: 0, length: count) }

func partitionSlices(by length: Int) -> [Substring] {
var startIndex = self.startIndex
var results = [Substring]()
Expand Down
4 changes: 0 additions & 4 deletions Tests/SwiftNASR_E2E/ErrorCollector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import Foundation
actor ErrorCollector {
private var errors: [RecordError] = []

var errorCount: Int {
errors.count
}

func record(_ error: Swift.Error, recordType: String) {
errors.append(RecordError(recordType: recordType, error: error))
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/SwiftNASR_E2E/ProgressTracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func trackProgress(progress: ProgressTracker) -> Task<Void, Swift.Error> {
}

@MainActor
func renderProgressBar(progress: ProgressTracker, barWidth: Int = 80) async {
func renderProgressBar(progress: ProgressTracker) async {
let fractionCompleted = await progress.fractionCompleted
let currentRecordType = await progress.currentRecordType
let percent = Int((fractionCompleted * 100).rounded())
Expand Down
7 changes: 0 additions & 7 deletions Tests/SwiftNASR_E2E/ProgressWeights.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ var CSVRecordTypes: Set<RecordType> {
Set(recordTypeRegistry.values.filter(\.availableInCSV).map(\.recordType))
}

/// Calculates the total progress weight for a given format.
func totalWeight(isCSV: Bool) -> Int64 {
let recordTypes = isCSV ? CSVRecordTypes : txtRecordTypes
let recordTotal = recordTypes.reduce(0) { $0 + weight(for: $1, isCSV: isCSV) }
return loadingWeight + recordTotal
}

/// Calculates the total progress weight for selected record types.
func totalWeight(isCSV: Bool, selectedRecordTypes: Set<RecordType>) -> Int64 {
let recordTotal = selectedRecordTypes.reduce(0) { $0 + weight(for: $1, isCSV: isCSV) }
Expand Down
3 changes: 1 addition & 2 deletions Tests/SwiftNASR_E2E/SwiftNASR_E2E.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ struct SwiftNASR_E2E: AsyncParsableCommand {
}

private let progress = ProgressTracker()
private var progressTask: Task<Void, Swift.Error>?

init() {}

Expand Down Expand Up @@ -157,7 +156,7 @@ struct SwiftNASR_E2E: AsyncParsableCommand {
}
print("Done loading \(formatName); parsing…")

progressTask = trackProgress(progress: progress)
_ = trackProgress(progress: progress)
let errorCollector = ErrorCollector()
try await parseValues(
nasr: nasr,
Expand Down