Skip to content

Commit ec834de

Browse files
committed
modify swift format
1 parent 028c5bf commit ec834de

8 files changed

+17
-22
lines changed

OTPKit/Features/OriginDestination/Sheets/AddFavoriteLocationsSheet.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public struct AddFavoriteLocationsSheet: View {
6060
.padding(.horizontal, 16)
6161

6262
List {
63-
if search.isEmpty, let userLocation = userLocation {
63+
if search.isEmpty, let userLocation {
6464
Button(action: {
6565
switch UserDefaultsServices.shared.saveFavoriteLocationData(data: userLocation) {
6666
case .success:

OTPKit/Features/OriginDestination/Sheets/OriginDestinationSheetView.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ public struct OriginDestinationSheetView: View {
132132
// swiftlint:enable function_body_length
133133
private func recentsSection() -> some View {
134134
if sheetEnvironment.recentLocations.isEmpty {
135-
return AnyView(EmptyView())
135+
AnyView(EmptyView())
136136
} else {
137-
return AnyView(
137+
AnyView(
138138
Section(content: {
139139
ForEach(Array(sheetEnvironment.recentLocations.prefix(5)), content: { location in
140140
VStack(alignment: .leading) {
@@ -190,7 +190,7 @@ public struct OriginDestinationSheetView: View {
190190

191191
private func currentUserSection() -> some View {
192192
Group {
193-
if let userLocation = userLocation {
193+
if let userLocation {
194194
Button(action: {
195195
switch UserDefaultsServices.shared.saveRecentLocations(data: userLocation) {
196196
case .success:
@@ -222,7 +222,7 @@ public struct OriginDestinationSheetView: View {
222222
.padding(.horizontal, 16)
223223

224224
List {
225-
if search.isEmpty && isSearchFocused {
225+
if search.isEmpty, isSearchFocused {
226226
currentUserSection()
227227
} else if search.isEmpty {
228228
favoritesSection()

OTPKit/Services/LocationServices.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ public final class LocationService: NSObject, ObservableObject, MKLocalSearchCom
5151
let search = MKLocalSearch(request: searchRequest)
5252

5353
search.start { [weak self] response, error in
54-
guard let self = self, let response = response else {
55-
if let error = error {
54+
guard let self, let response else {
55+
if let error {
5656
print("Error performing local search: \(error)")
5757
}
5858
return

OTPKit/Services/MapExtensionServices.swift

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import Foundation
99
import MapKit
1010
import SwiftUI
1111

12-
1312
/// Manage Map extension such as markers, etc
1413
public final class MapExtensionServices: ObservableObject {
1514
public static let shared = MapExtensionServices()

OTPKit/Services/UserDefaultsServices.swift

+6-10
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,11 @@ public final class UserDefaultsServices {
3535
}
3636

3737
func saveFavoriteLocationData(data: Location) -> Result<Void, Error> {
38-
var locations: [Location]
39-
40-
switch getFavoriteLocationsData() {
38+
var locations: [Location] = switch getFavoriteLocationsData() {
4139
case let .success(existingLocations):
42-
locations = existingLocations
40+
existingLocations
4341
case .failure:
44-
locations = []
42+
[]
4543
}
4644

4745
locations.append(data)
@@ -98,13 +96,11 @@ public final class UserDefaultsServices {
9896
}
9997

10098
func saveRecentLocations(data: Location) -> Result<Void, Error> {
101-
var locations: [Location]
102-
103-
switch getFavoriteLocationsData() {
99+
var locations: [Location] = switch getFavoriteLocationsData() {
104100
case let .success(existingLocations):
105-
locations = existingLocations
101+
existingLocations
106102
case .failure:
107-
locations = []
103+
[]
108104
}
109105

110106
locations.insert(data, at: 0)

OTPKitTests/Helpers/MockDataLoader.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct MockDataResponse {
2828

2929
class MockTask: URLSessionDataTask {
3030
override var progress: Progress {
31-
return Progress()
31+
Progress()
3232
}
3333

3434
private var closure: (Data?, URLResponse?, Error?) -> Void
@@ -130,7 +130,7 @@ class MockDataLoader: NSObject, URLDataLoader {
130130
// MARK: - URL Response
131131

132132
func buildURLResponse(URL: URL, statusCode: Int) -> HTTPURLResponse {
133-
return HTTPURLResponse(
133+
HTTPURLResponse(
134134
url: URL,
135135
statusCode: statusCode,
136136
httpVersion: "2",

OTPKitTests/Helpers/OTPTestCase.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class OTPTestCase: XCTestCase {
3232
}
3333

3434
var userDefaultsSuiteName: String {
35-
return String(describing: self)
35+
String(describing: self)
3636
}
3737

3838
// MARK: - Network and Data

scripts/swiftformat.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ if [[ "$(uname -m)" == arm64 ]]; then
33
fi
44

55
if which swiftformat > /dev/null; then
6-
swiftformat .
6+
swiftformat . --swiftversion 5.9
77
else
88
echo "warning: SwiftFormat not installed, download from https://github.com/nicklockwood/SwiftFormat"
99
fi

0 commit comments

Comments
 (0)