Skip to content

Commit

Permalink
Fixing Linting (#5)
Browse files Browse the repository at this point in the history
* Updating RadiantKit tag

* fixing BushelKit changes

* fixing LibraryError

* fix for watchOS, tvOS
  • Loading branch information
leogdion authored Sep 30, 2024
1 parent 1f635e9 commit 6fe5d33
Show file tree
Hide file tree
Showing 229 changed files with 2,227 additions and 1,038 deletions.
5 changes: 4 additions & 1 deletion .periphery.yml
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
retain_public: true
targets:
- BushelLibrary
- BushelLibraryViews
- BushelLogging
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6
5.10
5 changes: 1 addition & 4 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,4 @@ disabled_rules:
- nesting
- implicit_getter
- switch_case_alignment
- opening_brace
- closure_parameter_position
- conditional_returns_on_newline
- trailing_comma
- closure_parameter_position
6 changes: 3 additions & 3 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "f050cfddefd29adb57cc80720bb8f9414e59394416ce6e6e914f127f32b4dbb4",
"originHash" : "ee743026b399cac129b044aee1c81d8d5f04cd96f457386fa37e10525b1c181a",
"pins" : [
{
"identity" : "felinepine",
Expand Down Expand Up @@ -33,8 +33,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/brightdigit/RadiantKit.git",
"state" : {
"revision" : "1d8e4020b289913a60204d50ae18df0c232d402b",
"version" : "1.0.0-alpha.1"
"revision" : "2cd22405a06b6c8f57263faa94f0a370d2ed9119",
"version" : "1.0.0-alpha.2"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ var dependency: Package.Dependency {
}
struct RadiantKit: PackageDependency, TargetDependency {
var dependency: Package.Dependency {
.package(url: "https://github.com/brightdigit/RadiantKit.git", from: "1.0.0-alpha.1")
.package(url: "https://github.com/brightdigit/RadiantKit.git", from: "1.0.0-alpha.2")
}
}
struct IPSWDownloads: PackageDependency, TargetDependency {
Expand Down
2 changes: 1 addition & 1 deletion Package/Sources/Dependencies/RadiantKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@

struct RadiantKit: PackageDependency, TargetDependency {
var dependency: Package.Dependency {
.package(url: "https://github.com/brightdigit/RadiantKit.git", from: "1.0.0-alpha.1")
.package(url: "https://github.com/brightdigit/RadiantKit.git", from: "1.0.0-alpha.2")
}
}
2 changes: 1 addition & 1 deletion Sources/BushelArgs/Bushel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import ArgumentParser
import Foundation

internal enum Bushel {
static let configuration = CommandConfiguration(
internal static let configuration = CommandConfiguration(
abstract: "A utility for performing maths.",
subcommands: [Machine.self, Image.self],
defaultSubcommand: Machine.self
Expand Down
4 changes: 3 additions & 1 deletion Sources/BushelArgs/BushelCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ import Foundation
public protocol BushelCommand: ParsableCommand {}

extension BushelCommand {
public static var configuration: CommandConfiguration { Bushel.configuration }
public static var configuration: CommandConfiguration {
Bushel.configuration
}
}
4 changes: 3 additions & 1 deletion Sources/BushelArgs/Image/List.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@
import ArgumentParser
import Foundation

extension Image { struct List: ParsableCommand {} }
extension Image {
internal struct List: ParsableCommand {}
}
4 changes: 3 additions & 1 deletion Sources/BushelArgs/Machine/Create.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@
import ArgumentParser
import Foundation

extension Machine { struct Create: ParsableCommand {} }
extension Machine {
internal struct Create: ParsableCommand {}
}
5 changes: 3 additions & 2 deletions Sources/BushelCore/Documents/InitializablePackage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ public import RadiantDocs
extension InitializablePackage {
#warning("logging-note: let's log what is going on here")
#warning("Might want to add parameters for creating data and creating directory.")
@discardableResult public static func createAt(_ fileURL: URL) throws -> Self {
@discardableResult
public static func createAt(_ fileURL: URL) throws -> Self {
let library = self.init()
try FileManager.default.createDirectory(at: fileURL, withIntermediateDirectories: false)
let metadataJSONPath = fileURL.appendingPathComponent(configurationFileWrapperKey)
let metadataJSONPath = fileURL.appendingPathComponent(self.configurationFileWrapperKey)
let data = try JSON.encoder.encode(library)
try data.write(to: metadataJSONPath)
return library
Expand Down
19 changes: 13 additions & 6 deletions Sources/BushelCore/Foundation/AsyncReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,30 @@

import Foundation

public actor AsyncReducer<AsyncSequenceType: AsyncSequence & Sendable>
where AsyncSequenceType.Element: Sendable {
public actor AsyncReducer<
AsyncSequenceType: AsyncSequence & Sendable
> where AsyncSequenceType.Element: Sendable {
private let sequence: AsyncSequenceType
private var currentElements: [AsyncSequenceType.Element]?

public var elements: [AsyncSequenceType.Element] {
get async throws {
if let currentElements { return currentElements }
return try await reduce()
if let currentElements {
return currentElements
}
return try await self.reduce()
}
}

public init(sequence: AsyncSequenceType) { self.sequence = sequence }
public init(sequence: AsyncSequenceType) {
self.sequence = sequence
}

private func reduce() async throws -> [AsyncSequenceType.Element] {
var elements = [AsyncSequenceType.Element]()
for try await element in sequence { elements.append(element) }
for try await element in sequence {
elements.append(element)
}
currentElements = elements
return elements
}
Expand Down
5 changes: 5 additions & 0 deletions Sources/BushelCore/Foundation/BookmarkError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public import Foundation

public struct BookmarkError: Error, Sendable {
public enum Details: Equatable, Sendable {
case database
case accessDeniedAt(URL)
case fileDoesNotExistAt(URL)
case notFound(Identifier)
Expand All @@ -50,6 +51,10 @@ extension BookmarkError {
BookmarkError(innerError: nil, details: .notFound(identifier))
}

public static func databaseError(_ error: any Error) -> BookmarkError {
BookmarkError(innerError: error, details: .database)
}

public static func accessDeniedError(_ error: any Error, at url: URL) -> BookmarkError {
let nsError = error as NSError
if nsError.code == NSFileReadNoSuchFileError {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public import Foundation

extension URL {
public struct Bushel: Sendable {
init(
internal init(
scheme: String,
privacyPolicy: URL,
termsOfUse: URL,
Expand Down Expand Up @@ -66,7 +66,9 @@ extension URL {
}
}

public static var bushel: Bushel { .shared }
public static var bushel: Bushel {
.shared
}
}

public protocol VZMacPaths: Sendable {
Expand Down Expand Up @@ -97,13 +99,22 @@ extension URL.Bushel {

private init?(bundle: Bundle = .main) {
guard let urlTypes = bundle.object(forInfoDictionaryKey: "CFBundleURLTypes") as? [[String: Any]]
else { return nil }
guard let urlSchemes = urlTypes.first?["CFBundleURLSchemes"] as? [String] else { return nil }
guard let scheme = urlSchemes.first else { return nil }
else {
return nil
}
guard let urlSchemes = urlTypes.first?["CFBundleURLSchemes"] as? [String] else {
return nil
}
guard let scheme = urlSchemes.first else {
return nil
}
guard
let dictionary = bundle.object(forInfoDictionaryKey: "BrightDigitURLDirectory")
as? [String: String]
else { return nil }
let dictionary = bundle.object(
forInfoDictionaryKey: "BrightDigitURLDirectory"
) as? [String: String]
else {
return nil
}
self.init(scheme: scheme, dictionary: dictionary)
}

Expand Down
14 changes: 11 additions & 3 deletions Sources/BushelCore/Foundation/DocumentTypeFilter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,23 @@ public struct DocumentTypeFilter: OptionSet, Sendable {

public let rawValue: Int

public init(rawValue: Int) { self.rawValue = rawValue }
public init(rawValue: Int) {
self.rawValue = rawValue
}
}

extension DocumentTypeFilter {
public var searchStrings: [String] {
var pathExtensions = [String?]()
if contains(.libraries) { pathExtensions.append(FileType.restoreImageLibrary.fileExtension) }
if self.contains(.libraries) {
pathExtensions.append(
FileType.restoreImageLibrary.fileExtension
)
}
return pathExtensions.compactMap { pathExtension in
guard let pathExtension else { return nil }
guard let pathExtension else {
return nil
}
return ".\(pathExtension)"
}
}
Expand Down
16 changes: 11 additions & 5 deletions Sources/BushelCore/Foundation/DocumentTypeFilterOption.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,24 @@ public enum DocumentTypeFilterOption: Int, CaseIterable, Identifiable, Localizab

public static let localizedStringIDMapping: [Self: String] = [
.machinesOnly: "settingsFilterRecentDocumentsMachinesOnly",
.machinesAndLibraries: "settingsFilterRecentDocumentsNone",
.machinesAndLibraries: "settingsFilterRecentDocumentsNone"
]

public var tag: Int { rawValue }
public var tag: Int {
self.rawValue
}

public var id: Int { rawValue }
public var id: Int {
self.rawValue
}

public var typeFilter: DocumentTypeFilter {
switch self {
case .machinesAndLibraries: []
case .machinesAndLibraries:
[]

case .machinesOnly: .libraries
case .machinesOnly:
.libraries
}
}

Expand Down
20 changes: 12 additions & 8 deletions Sources/BushelCore/Foundation/EnvironmentConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,29 @@ public struct EnvironmentConfiguration: CustomReflectable, Sendable {

public static let shared: EnvironmentConfiguration = .init()

@EnvironmentProperty(Key.disableAssertionFailureForError) public
var disableAssertionFailureForError: Bool
@EnvironmentProperty(Key.disableAssertionFailureForError)
public var disableAssertionFailureForError: Bool

@EnvironmentProperty(Key.disallowDatabaseRebuild) public var disallowDatabaseRebuild: Bool
@EnvironmentProperty(Key.disallowDatabaseRebuild)
public var disallowDatabaseRebuild: Bool

@EnvironmentProperty(Key.onboardingOveride) public var onboardingOveride: OnboardingOverrideOption
@EnvironmentProperty(Key.onboardingOveride)
public var onboardingOveride: OnboardingOverrideOption

@EnvironmentProperty(Key.resetApplication) public var resetApplication: Bool
@EnvironmentProperty(Key.resetApplication)
public var resetApplication: Bool

public var customMirror: Mirror {
Mirror(
self,
children: [
"disableAssertionFailureForError": disableAssertionFailureForError,
"disallowDatabaseRebuild": disallowDatabaseRebuild, "onboardingOveride": onboardingOveride,
"resetApplication": resetApplication,
"disallowDatabaseRebuild": disallowDatabaseRebuild,
"onboardingOveride": onboardingOveride,
"resetApplication": resetApplication
]
)
}

init() {}
internal init() {}
}
8 changes: 5 additions & 3 deletions Sources/BushelCore/Foundation/ImageMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ public import Foundation
import OperatingSystemVersion

/// Represents metadata associated with an image file.
public struct ImageMetadata: Codable, CustomDebugStringConvertible, Hashable,
OperatingSystemInstalled, Sendable
{
public struct ImageMetadata: Codable,
CustomDebugStringConvertible,
Hashable,
OperatingSystemInstalled,
Sendable {
/// Indicates whether the image format is supported by the system.
public let isImageSupported: Bool
/// The build version associated with the image, if available.
Expand Down
13 changes: 9 additions & 4 deletions Sources/BushelCore/Foundation/Initialization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,24 @@

import Foundation

@MainActor public final class Initialization {
@MainActor
public final class Initialization {
public static let begin = Initialization()
private var isCompleted = false

private init() {}

public nonisolated func callAsFunction(_ closure: @MainActor @Sendable @escaping () -> Void) {
Task { await self.execute(closure) }
Task {
await self.execute(closure)
}
}

func execute(_ closure: @MainActor @Sendable @escaping () -> Void) {
guard !isCompleted else { return }
isCompleted = true
guard !isCompleted else {
return
}
self.isCompleted = true
closure()
}
}
4 changes: 3 additions & 1 deletion Sources/BushelCore/Foundation/MachineBuilding/Bundle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ extension Bundle {
public static let suiteName = "group.com.brightdigit.Bushel"

public func clearUserDefaults() throws {
guard let domainName = bundleIdentifier else { throw MissingIdentifierError.shared }
guard let domainName = self.bundleIdentifier else {
throw MissingIdentifierError.shared
}
UserDefaults.standard.removePersistentDomain(forName: domainName)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ public struct ConfigurationRange: CustomStringConvertible, Sendable, Equatable {
public let cpuCount: ClosedRange<Float>
public let memory: ClosedRange<Float>

public var description: String { "cpuCount: \(cpuCount); memory: \(memory)" }
public var description: String {
"cpuCount: \(cpuCount); memory: \(memory)"
}

public init(cpuCount: ClosedRange<Float>, memory: ClosedRange<Float>) {
self.cpuCount = cpuCount
Expand Down
Loading

0 comments on commit 6fe5d33

Please sign in to comment.