Skip to content

Commit

Permalink
Run `swiftlint —fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jdisho committed Jan 3, 2025
1 parent 1c1e9e0 commit b71333d
Showing 1 changed file with 22 additions and 25 deletions.
47 changes: 22 additions & 25 deletions Tests/SpeziFHIRTests/FHIRResourceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import ModelsR4
@testable import SpeziFHIR
import XCTest

// swiftlint:disable file_length
final class FHIRResourceTests: XCTestCase {

Check warning on line 15 in Tests/SpeziFHIRTests/FHIRResourceTests.swift

View workflow job for this annotation

GitHub Actions / Build and Test UI Tests / Test using xcodebuild or run fastlane

File Types Order Violation: A 'main_type' should not be placed amongst the file type(s) 'supporting_type' (file_types_order)

Check failure on line 15 in Tests/SpeziFHIRTests/FHIRResourceTests.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint / SwiftLint

File Types Order Violation: A 'main_type' should not be placed amongst the file type(s) 'supporting_type' (file_types_order)

Check failure on line 15 in Tests/SpeziFHIRTests/FHIRResourceTests.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint / SwiftLint

Type Body Length Violation: Type body should span 250 lines or less excluding comments and whitespace: currently spans 255 lines (type_body_length)

let testDate = Date(timeIntervalSince1970: 1735123266)
let calendar = Calendar.current

Expand Down Expand Up @@ -116,7 +116,7 @@ final class FHIRResourceTests: XCTestCase {

let jsonString = resource.json(withConfiguration: [])

let jsonData = jsonString.data(using: .utf8)!
let jsonData = jsonString.data(using: .utf8) ?? Data()
let decoder = JSONDecoder()
let decodedObservation = try decoder.decode(ModelsR4.Observation.self, from: jsonData)

Expand All @@ -143,7 +143,7 @@ final class FHIRResourceTests: XCTestCase {

let jsonString = resource.json(withConfiguration: [])

let jsonData = jsonString.data(using: .utf8)!
let jsonData = jsonString.data(using: .utf8) ?? Data()
let decoder = JSONDecoder()
let decodedObservation = try decoder.decode(ModelsDSTU2.Observation.self, from: jsonData)

Expand Down Expand Up @@ -312,10 +312,8 @@ final class FHIRResourceTests: XCTestCase {
mockPatient.name = nil
XCTAssertEqual(proxy.displayName, "Patient")
}
}

private extension FHIRResourceTests {
func assertEqualDates(_ resourceDate: Date?, _ expectedDate: Date, _ resourceName: String) {

private func assertEqualDates(_ resourceDate: Date?, _ expectedDate: Date, _ resourceName: String) {
guard let resourceDate = resourceDate else {
XCTFail("Date should not be nil for \(resourceName)")
return
Expand Down Expand Up @@ -352,7 +350,7 @@ private extension FHIRResourceTests {
}
}

private struct ModelsR4Mocks {
private enum ModelsR4Mocks {
static func createCarePlan(date: Date) throws -> ModelsR4.CarePlan {
let period = ModelsR4.Period()
period.start = try FHIRPrimitive(DateTime(date: date))
Expand Down Expand Up @@ -410,22 +408,22 @@ private struct ModelsR4Mocks {
}

static func createCondition(date: Date) throws -> ModelsR4.Condition {
return ModelsR4.Condition(
ModelsR4.Condition(
id: "condition-id".asFHIRStringPrimitive(),
onset: .dateTime(FHIRPrimitive(try DateTime(date: date))),
subject: Reference(id: "patient-id".asFHIRStringPrimitive())
)
}

static func createDevice(date: Date) throws -> ModelsR4.Device {
return ModelsR4.Device(
ModelsR4.Device(
id: "device-id".asFHIRStringPrimitive(),
manufactureDate: FHIRPrimitive(try DateTime(date: date))
)
}

static func createDiagnosticReport(date: Date) throws -> ModelsR4.DiagnosticReport {
return ModelsR4.DiagnosticReport(
ModelsR4.DiagnosticReport(
code: CodeableConcept(coding: [Coding(code: "code".asFHIRStringPrimitive())]),
effective: .dateTime(FHIRPrimitive(try DateTime(date: date))),
id: "diagnostic-report-id".asFHIRStringPrimitive(),
Expand Down Expand Up @@ -492,7 +490,7 @@ private struct ModelsR4Mocks {
}

static func createImmunization(date: Date) throws -> ModelsR4.Immunization {
return ModelsR4.Immunization(
ModelsR4.Immunization(
id: "immunization-id".asFHIRStringPrimitive(),
occurrence: .dateTime(FHIRPrimitive(try DateTime(date: date))),
patient: Reference(id: "patient-id".asFHIRStringPrimitive()),
Expand All @@ -506,7 +504,7 @@ private struct ModelsR4Mocks {
}

static func createMedicationRequest(date: Date) throws -> ModelsR4.MedicationRequest {
return ModelsR4.MedicationRequest(
ModelsR4.MedicationRequest(
authoredOn: FHIRPrimitive(try DateTime(date: date)),
id: "medication-request-id".asFHIRStringPrimitive(),
intent: FHIRPrimitive(.order),
Expand All @@ -521,7 +519,7 @@ private struct ModelsR4Mocks {
}

static func createMedicationAdministration(date: Date) throws -> ModelsR4.MedicationAdministration {
return ModelsR4.MedicationAdministration(
ModelsR4.MedicationAdministration(
effective: .dateTime(FHIRPrimitive(try DateTime(date: date))),
id: "medication-administration-id".asFHIRStringPrimitive(),
medication: .codeableConcept(
Expand All @@ -535,7 +533,7 @@ private struct ModelsR4Mocks {
}

static func createObservation(date: Date) throws -> ModelsR4.Observation {
return ModelsR4.Observation(
ModelsR4.Observation(
code: CodeableConcept(coding: [Coding(code: "code".asFHIRStringPrimitive())]),
id: "observation-id".asFHIRStringPrimitive(),
issued: FHIRPrimitive(try Instant(date: date)),
Expand All @@ -544,7 +542,7 @@ private struct ModelsR4Mocks {
}

static func createProcedure(date: Date) throws -> ModelsR4.Procedure {
return ModelsR4.Procedure(
ModelsR4.Procedure(
id: "procedure-id".asFHIRStringPrimitive(),
performed: .dateTime(FHIRPrimitive(try DateTime(date: date))),
status: FHIRPrimitive(.completed),
Expand All @@ -553,14 +551,14 @@ private struct ModelsR4Mocks {
}

static func createPatient(date: Date) throws -> ModelsR4.Patient {
return ModelsR4.Patient(
ModelsR4.Patient(
birthDate: FHIRPrimitive(try FHIRDate(date: date)),
id: "patient-id".asFHIRStringPrimitive()
)
}

static func createProvenance(date: Date) throws -> ModelsR4.Provenance {
return ModelsR4.Provenance(
ModelsR4.Provenance(
agent: [
ProvenanceAgent(
type: CodeableConcept(
Expand All @@ -578,7 +576,7 @@ private struct ModelsR4Mocks {
}

static func createSupplyDelivery(date: Date) throws -> ModelsR4.SupplyDelivery {
return ModelsR4.SupplyDelivery(
ModelsR4.SupplyDelivery(
id: "supply-delivery-id".asFHIRStringPrimitive(),
occurrence: .dateTime(FHIRPrimitive(try DateTime(date: date))),
status: FHIRPrimitive(.completed)
Expand All @@ -587,9 +585,9 @@ private struct ModelsR4Mocks {
}


private struct ModelsDSTU2Mocks {
private enum ModelsDSTU2Mocks {
static func createObservation(date: Date) throws -> ModelsDSTU2.Observation {
return ModelsDSTU2.Observation(
ModelsDSTU2.Observation(
code: CodeableConcept(
coding: [
Coding(code: "code".asFHIRStringPrimitive())
Expand All @@ -602,7 +600,7 @@ private struct ModelsDSTU2Mocks {
}

static func createMedicationOrder(date: Date) throws -> ModelsDSTU2.MedicationOrder {
return ModelsDSTU2.MedicationOrder(
ModelsDSTU2.MedicationOrder(
dateWritten: FHIRPrimitive(try DateTime(date: date)),
id: "medication-order-id".asFHIRStringPrimitive(),
medication: .codeableConcept(
Expand All @@ -615,7 +613,7 @@ private struct ModelsDSTU2Mocks {
}

static func createMedicationStatement(date: Date) throws -> ModelsDSTU2.MedicationStatement {
return ModelsDSTU2.MedicationStatement(
ModelsDSTU2.MedicationStatement(
effective: .dateTime(FHIRPrimitive(try DateTime(date: date))),
id: "medication-statement-id".asFHIRStringPrimitive(),
medication: .codeableConcept(
Expand All @@ -629,7 +627,7 @@ private struct ModelsDSTU2Mocks {
}

static func createCondition(date: Date) throws -> ModelsDSTU2.Condition {
return ModelsDSTU2.Condition(
ModelsDSTU2.Condition(
code: CodeableConcept(
coding: [
Coding(code: "condition-code".asFHIRStringPrimitive())
Expand Down Expand Up @@ -663,4 +661,3 @@ private struct ModelsDSTU2Mocks {
)
}
}

0 comments on commit b71333d

Please sign in to comment.