Skip to content

Commit

Permalink
linting code
Browse files Browse the repository at this point in the history
  • Loading branch information
leogdion committed Sep 9, 2024
1 parent 7778fcc commit d19f8b9
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 16 deletions.
28 changes: 27 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,31 @@

import PackageDescription

let swiftSettings: [SwiftSetting] = [
SwiftSetting.enableExperimentalFeature("AccessLevelOnImport"),
SwiftSetting.enableExperimentalFeature("BitwiseCopyable"),
SwiftSetting.enableExperimentalFeature("GlobalActorIsolatedTypesUsability"),
SwiftSetting.enableExperimentalFeature("IsolatedAny"),
SwiftSetting.enableExperimentalFeature("MoveOnlyPartialConsumption"),
SwiftSetting.enableExperimentalFeature("NestedProtocols"),
SwiftSetting.enableExperimentalFeature("NoncopyableGenerics"),
SwiftSetting.enableExperimentalFeature("RegionBasedIsolation"),
SwiftSetting.enableExperimentalFeature("TransferringArgsAndResults"),
SwiftSetting.enableExperimentalFeature("VariadicGenerics"),

SwiftSetting.enableUpcomingFeature("FullTypedThrows"),
SwiftSetting.enableUpcomingFeature("InternalImportsByDefault")

// SwiftSetting.unsafeFlags([
// "-Xfrontend",
// "-warn-long-function-bodies=100"
// ]),
// SwiftSetting.unsafeFlags([
// "-Xfrontend",
// "-warn-long-expression-type-checking=100"
// ])
]

let package = Package(
name: "DataThespian",
platforms: [.iOS(.v17), .macCatalyst(.v17), .macOS(.v14), .tvOS(.v17), .visionOS(.v1), .watchOS(.v10)],
Expand All @@ -22,7 +47,8 @@ let package = Package(
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "DataThespian",
dependencies: ["FelinePine"]
dependencies: ["FelinePine"],
swiftSettings: swiftSettings
),
.testTarget(
name: "DataThespianTests",
Expand Down
38 changes: 38 additions & 0 deletions Sources/DataThespian/Assert.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// Assert.swift
// DataThespian
//
// Created by Leo Dion.
// Copyright © 2024 BrightDigit.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//

public import Foundation

@inlinable internal func assert(isMainThread: Bool) { assert(isMainThread == Thread.isMainThread) }

@inlinable internal func assertionFailure(
error: any Error,
file: StaticString = #file,
line: UInt = #line
) { assertionFailure(error.localizedDescription, file: file, line: line) }
1 change: 0 additions & 1 deletion Sources/DataThespian/DataMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
//

#if canImport(Combine) && canImport(SwiftData) && canImport(CoreData)
@inlinable public func assert(isMainThread: Bool) { assert(isMainThread == Thread.isMainThread) }

import Combine

Expand Down
2 changes: 1 addition & 1 deletion Sources/DataThespian/Logging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// OTHER DEALINGS IN THE SOFTWARE.
//

import FelinePine
public import FelinePine

public enum ThespianLogging: LoggingSystem {
public enum Category: String, CaseIterable {
Expand Down
5 changes: 0 additions & 5 deletions Sources/DataThespian/ManagedObjectMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@
//

#if canImport(SwiftData)
@inlinable internal func assertionFailure(
error: any Error,
file: StaticString = #file,
line: UInt = #line
) { assertionFailure(error.localizedDescription, file: file, line: line) }

public import SwiftData

Expand Down
5 changes: 3 additions & 2 deletions Sources/DataThespian/ModelContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

#if canImport(SwiftData)
import Foundation
import SwiftData
public import SwiftData

extension ModelContext: Loggable {
extension ModelContext: DataThespian.Loggable {
public static var loggingCategory: ThespianLogging.Category { .data }
func existingModel<T>(for objectID: PersistentIdentifier) throws -> T?
where T: PersistentModel {
Expand All @@ -45,4 +45,5 @@
return try fetch(fetchDescriptor).first
}
}

#endif
25 changes: 19 additions & 6 deletions Sources/DataThespian/NSManagedObjectID.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,27 @@

public import SwiftData

// Model to represent identifier implementation as JSON
// periphery:ignore
fileprivate struct PersistentIdentifierJSON: Codable {
fileprivate struct Implementation: Codable {
var primaryKey: String
var uriRepresentation: URL
var isTemporary: Bool
var storeIdentifier: String
var entityName: String
fileprivate init(
primaryKey: String,
uriRepresentation: URL,
isTemporary: Bool,
storeIdentifier: String,
entityName: String
) {
self.primaryKey = primaryKey
self.uriRepresentation = uriRepresentation
self.isTemporary = isTemporary
self.storeIdentifier = storeIdentifier
self.entityName = entityName
}
private var primaryKey: String
private var uriRepresentation: URL
private var isTemporary: Bool
private var storeIdentifier: String
private var entityName: String
}

fileprivate var implementation: Implementation
Expand Down

0 comments on commit d19f8b9

Please sign in to comment.