Skip to content

Commit

Permalink
More swiftlint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
terribilis committed Mar 8, 2024
1 parent c39ea16 commit 677966a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Stronger.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
38756AB22B946D0E00FDF599 /* ExerciseInfo.json in Resources */ = {isa = PBXBuildFile; fileRef = 38756AB12B946D0E00FDF599 /* ExerciseInfo.json */; };
38C4563E2B96CF3B009D69AA /* WorkoutHomeButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38C4563D2B96CF3B009D69AA /* WorkoutHomeButton.swift */; };
38FE1D022B716A42008F8BE0 /* WorkoutVideoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38FE1D012B7169DF008F8BE0 /* WorkoutVideoView.swift */; };
4002F0AC2B9AFC4D00AD3D47 /* MissedWorkoutTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4002F0AB2B9AFC4D00AD3D47 /* MissedWorkoutTest.swift */; };
4011141A2B7EE59A000083A2 /* ProgressCircle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 401114192B7EE59A000083A2 /* ProgressCircle.swift */; };
4011141D2B83FCD1000083A2 /* SummaryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4011141C2B83FCD1000083A2 /* SummaryView.swift */; };
401114232B8489D1000083A2 /* GoalResist.swift in Sources */ = {isa = PBXBuildFile; fileRef = 401114222B8489D1000083A2 /* GoalResist.swift */; };
Expand Down Expand Up @@ -218,6 +219,7 @@
38756AB12B946D0E00FDF599 /* ExerciseInfo.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = ExerciseInfo.json; sourceTree = "<group>"; };
38C4563D2B96CF3B009D69AA /* WorkoutHomeButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WorkoutHomeButton.swift; sourceTree = "<group>"; };
38FE1D012B7169DF008F8BE0 /* WorkoutVideoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WorkoutVideoView.swift; sourceTree = "<group>"; };
4002F0AB2B9AFC4D00AD3D47 /* MissedWorkoutTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MissedWorkoutTest.swift; sourceTree = "<group>"; };
401114192B7EE59A000083A2 /* ProgressCircle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressCircle.swift; sourceTree = "<group>"; };
4011141C2B83FCD1000083A2 /* SummaryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SummaryView.swift; sourceTree = "<group>"; };
401114222B8489D1000083A2 /* GoalResist.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoalResist.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -566,6 +568,7 @@
40D4E47E2B97CB9900261632 /* HomeTest.swift */,
40D4E4812B97CBB800261632 /* TapSwitchTest.swift */,
40D4E4832B97CD0A00261632 /* WorkoutTest.swift */,
4002F0AB2B9AFC4D00AD3D47 /* MissedWorkoutTest.swift */,
);
path = StrongerUITests;
sourceTree = "<group>";
Expand Down Expand Up @@ -920,6 +923,7 @@
40D4E47F2B97CB9900261632 /* HomeTest.swift in Sources */,
2F4E237E2989A2FE0013F3D9 /* LaunchTests.swift in Sources */,
40D4E4822B97CBB800261632 /* TapSwitchTest.swift in Sources */,
4002F0AC2B9AFC4D00AD3D47 /* MissedWorkoutTest.swift in Sources */,
40D4E4842B97CD0A00261632 /* WorkoutTest.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
12 changes: 8 additions & 4 deletions Stronger/Exercise/WorkoutSelection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ struct WorkoutSelection: View {
}
}

private func populateUniqueValuesSet(from documents: [QueryDocumentSnapshot]) -> Set<String> {
private func populateUniqueValuesSet(from documents: [QueryDocumentSnapshot] = []) -> Set<String> {
var uniqueValuesSet = Set<String>()

// Iterate over documents to populate the set
Expand Down Expand Up @@ -271,8 +271,12 @@ struct WorkoutSelection: View {
if let error = error {
print("Error fetching documents: \(error)")
} else {
guard let querySnapshot = querySnapshot else {
print("querySnapshot is nil")
return
}

Check warning on line 277 in Stronger/Exercise/WorkoutSelection.swift

View check run for this annotation

Codecov / codecov/patch

Stronger/Exercise/WorkoutSelection.swift#L274-L277

Added lines #L274 - L277 were not covered by tests
// Get the count of documents
let documentCount = querySnapshot?.documents.count ?? 0
let documentCount = querySnapshot.documents.count

Check warning on line 279 in Stronger/Exercise/WorkoutSelection.swift

View check run for this annotation

Codecov / codecov/patch

Stronger/Exercise/WorkoutSelection.swift#L279

Added line #L279 was not covered by tests

print("Number of documents returned: \(documentCount)")

Expand All @@ -282,14 +286,14 @@ struct WorkoutSelection: View {
self.selectedDay = 1
} else {
// Check if there are documents with selectedDay equal to 1
let selectedDay2Count = populateUniqueValuesSet(from: querySnapshot!.documents.filter { $0["exerciseDay"] as? Int == 2 }).count
let selectedDay2Count = populateUniqueValuesSet(from: querySnapshot.documents.filter { $0["exerciseDay"] as? Int == 2 }).count
if selectedDay2Count > 3 {

Check warning on line 290 in Stronger/Exercise/WorkoutSelection.swift

View check run for this annotation

Codecov / codecov/patch

Stronger/Exercise/WorkoutSelection.swift#L289-L290

Added lines #L289 - L290 were not covered by tests
print("Documents found with selectedDay equal to 2. Setting selectedDay to 3.")
self.selectedDay = 3
} else {
// Check if there are documents with selectedDay equal to 2
let selectedDay1Count = populateUniqueValuesSet(
from: querySnapshot!.documents.filter { $0["exerciseDay"] as? Int == 1 }
from: querySnapshot.documents.filter { $0["exerciseDay"] as? Int == 1 }
).count
if selectedDay1Count > 3 {

Check warning on line 298 in Stronger/Exercise/WorkoutSelection.swift

View check run for this annotation

Codecov / codecov/patch

Stronger/Exercise/WorkoutSelection.swift#L295-L298

Added lines #L295 - L298 were not covered by tests
print("Documents found with selectedDay equal to 1. Setting selectedDay to 2.")
Expand Down
39 changes: 39 additions & 0 deletions StrongerUITests/MissedWorkoutTest.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
////
//// This source file is part of the Stronger based on the Stanford Spezi Template Application project
////
//// SPDX-FileCopyrightText: 2023 Stanford University
////
//// SPDX-License-Identifier: MIT
////
//
//import XCTest

Check failure on line 9 in StrongerUITests/MissedWorkoutTest.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint

Comment Spacing Violation: Prefer at least one space after slashes for comments (comment_spacing)
//
//
//class MissedWorkoutTests: XCTestCase {

Check failure on line 12 in StrongerUITests/MissedWorkoutTest.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint

Comment Spacing Violation: Prefer at least one space after slashes for comments (comment_spacing)
// override func setUpWithError() throws {
// try super.setUpWithError()
//
// continueAfterFailure = false
//
// let app = XCUIApplication()
// app.launchArguments = ["--skipOnboarding"]
// app.launch()
// }
//
//
// func testApplicationMissedWorkouts() throws {
// let app = XCUIApplication()
// XCTAssertEqual(app.state, .runningForeground)
//
// XCTAssertTrue(app.tabBars["Tab Bar"].buttons["Workout"].waitForExistence(timeout: 2))
// app.tabBars["Tab Bar"].buttons["Workout"].tap()
//
// XCTAssertTrue(app.buttons["Enter Missed Workout"].waitForExistence(timeout: 2))
// app.buttons["Enter Missed Workout"].tap()
//
//
// XCTAssertTrue(app.buttons["Week 1"].waitForExistence(timeout: 2))
// app.buttons["Week1 1"].tap()
// XCTAssertTrue(app.buttons["Week 1"].waitForExistence(timeout: 2))
// }
//}

Check failure on line 39 in StrongerUITests/MissedWorkoutTest.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint

Comment Spacing Violation: Prefer at least one space after slashes for comments (comment_spacing)

0 comments on commit 677966a

Please sign in to comment.