Skip to content

Commit b10caf8

Browse files
authored
chore(geo): resolve swiftformat errors and warnings (#3849)
* chore(geo): resolve swiftformat errors and warnings * updated swiftformat rules * update rules
1 parent 748755e commit b10caf8

21 files changed

+491
-304
lines changed

AmplifyPlugins/Geo/Sources/AWSLocationGeoPlugin/AWSLocationGeoPlugin+ClientBehavior.swift

Lines changed: 59 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Foundation
1010

1111
import AWSLocation
1212

13-
extension AWSLocationGeoPlugin {
13+
public extension AWSLocationGeoPlugin {
1414

1515
// MARK: - Search
1616

@@ -30,8 +30,10 @@ extension AWSLocationGeoPlugin {
3030
/// `Geo.Error.networkError` if request failed or network unavailable
3131
/// `Geo.Error.pluginError` if encapsulated error received by a dependent plugin
3232
/// `Geo.Error.unknown` if error is unknown
33-
public func search(for text: String,
34-
options: Geo.SearchForTextOptions? = nil) async throws -> [Geo.Place] {
33+
func search(
34+
for text: String,
35+
options: Geo.SearchForTextOptions? = nil
36+
) async throws -> [Geo.Place] {
3537

3638
var request = SearchPlaceIndexForTextInput()
3739

@@ -41,21 +43,26 @@ extension AWSLocationGeoPlugin {
4143
guard request.indexName != nil else {
4244
throw Geo.Error.invalidConfiguration(
4345
GeoPluginErrorConstants.missingDefaultSearchIndex.errorDescription,
44-
GeoPluginErrorConstants.missingDefaultSearchIndex.recoverySuggestion)
46+
GeoPluginErrorConstants.missingDefaultSearchIndex.recoverySuggestion
47+
)
4548
}
4649

4750
request.text = text
4851

4952
if let area = options?.area {
5053
switch area {
5154
case .near(let coordinates):
52-
request.biasPosition = [coordinates.longitude,
53-
coordinates.latitude]
55+
request.biasPosition = [
56+
coordinates.longitude,
57+
coordinates.latitude
58+
]
5459
case .within(let boundingBox):
55-
request.filterBBox = [boundingBox.southwest.longitude,
56-
boundingBox.southwest.latitude,
57-
boundingBox.northeast.longitude,
58-
boundingBox.northeast.latitude]
60+
request.filterBBox = [
61+
boundingBox.southwest.longitude,
62+
boundingBox.southwest.latitude,
63+
boundingBox.northeast.longitude,
64+
boundingBox.northeast.latitude
65+
]
5966
}
6067
}
6168

@@ -73,9 +80,7 @@ extension AWSLocationGeoPlugin {
7380
let response = try await locationService.searchPlaceIndex(forText: request)
7481
var results = [LocationClientTypes.Place]()
7582
if let responseResults = response.results {
76-
results = responseResults.compactMap {
77-
$0.place
78-
}
83+
results = responseResults.compactMap(\.place)
7984
}
8085

8186
let places: [Geo.Place] = results.compactMap {
@@ -85,16 +90,18 @@ extension AWSLocationGeoPlugin {
8590
return nil
8691
}
8792

88-
return Geo.Place(coordinates: Geo.Coordinates(latitude: lat, longitude: long),
89-
label: $0.label,
90-
addressNumber: $0.addressNumber,
91-
street: $0.street,
92-
municipality: $0.municipality,
93-
neighborhood: $0.neighborhood,
94-
region: $0.region,
95-
subRegion: $0.subRegion,
96-
postalCode: $0.postalCode,
97-
country: $0.country)
93+
return Geo.Place(
94+
coordinates: Geo.Coordinates(latitude: lat, longitude: long),
95+
label: $0.label,
96+
addressNumber: $0.addressNumber,
97+
street: $0.street,
98+
municipality: $0.municipality,
99+
neighborhood: $0.neighborhood,
100+
region: $0.region,
101+
subRegion: $0.subRegion,
102+
postalCode: $0.postalCode,
103+
country: $0.country
104+
)
98105
}
99106
return places
100107
} catch let error as GeoErrorConvertible {
@@ -123,8 +130,10 @@ extension AWSLocationGeoPlugin {
123130
/// `Geo.Error.networkError` if request failed or network unavailable
124131
/// `Geo.Error.pluginError` if encapsulated error received by a dependent plugin
125132
/// `Geo.Error.unknown` if error is unknown
126-
public func search(for coordinates: Geo.Coordinates,
127-
options: Geo.SearchForCoordinatesOptions? = nil) async throws -> [Geo.Place] {
133+
func search(
134+
for coordinates: Geo.Coordinates,
135+
options: Geo.SearchForCoordinatesOptions? = nil
136+
) async throws -> [Geo.Place] {
128137

129138
var request = SearchPlaceIndexForPositionInput()
130139

@@ -134,11 +143,14 @@ extension AWSLocationGeoPlugin {
134143
guard request.indexName != nil else {
135144
throw Geo.Error.invalidConfiguration(
136145
GeoPluginErrorConstants.missingDefaultSearchIndex.errorDescription,
137-
GeoPluginErrorConstants.missingDefaultSearchIndex.recoverySuggestion)
146+
GeoPluginErrorConstants.missingDefaultSearchIndex.recoverySuggestion
147+
)
138148
}
139149

140-
request.position = [coordinates.longitude,
141-
coordinates.latitude]
150+
request.position = [
151+
coordinates.longitude,
152+
coordinates.latitude
153+
]
142154

143155
if let maxResults = options?.maxResults {
144156
request.maxResults = maxResults as Int
@@ -148,9 +160,7 @@ extension AWSLocationGeoPlugin {
148160
let response = try await locationService.searchPlaceIndex(forPosition: request)
149161
var results = [LocationClientTypes.Place]()
150162
if let responseResults = response.results {
151-
results = responseResults.compactMap {
152-
$0.place
153-
}
163+
results = responseResults.compactMap(\.place)
154164
}
155165

156166
let places: [Geo.Place] = results.compactMap {
@@ -160,16 +170,18 @@ extension AWSLocationGeoPlugin {
160170
return nil
161171
}
162172

163-
return Geo.Place(coordinates: Geo.Coordinates(latitude: lat, longitude: long),
164-
label: $0.label,
165-
addressNumber: $0.addressNumber,
166-
street: $0.street,
167-
municipality: $0.municipality,
168-
neighborhood: $0.neighborhood,
169-
region: $0.region,
170-
subRegion: $0.subRegion,
171-
postalCode: $0.postalCode,
172-
country: $0.country)
173+
return Geo.Place(
174+
coordinates: Geo.Coordinates(latitude: lat, longitude: long),
175+
label: $0.label,
176+
addressNumber: $0.addressNumber,
177+
street: $0.street,
178+
municipality: $0.municipality,
179+
neighborhood: $0.neighborhood,
180+
region: $0.region,
181+
subRegion: $0.subRegion,
182+
postalCode: $0.postalCode,
183+
country: $0.country
184+
)
173185
}
174186
return places
175187
} catch let error as GeoErrorConvertible {
@@ -194,12 +206,13 @@ extension AWSLocationGeoPlugin {
194206
/// `Geo.Error.networkError` if request failed or network unavailable
195207
/// `Geo.Error.pluginError` if encapsulated error received by a dependent plugin
196208
/// `Geo.Error.unknown` if error is unknown
197-
public func availableMaps() async throws -> [Geo.MapStyle] {
209+
func availableMaps() async throws -> [Geo.MapStyle] {
198210
let mapStyles = Array(pluginConfig.maps.values)
199211
guard !mapStyles.isEmpty else {
200212
throw Geo.Error.invalidConfiguration(
201213
GeoPluginErrorConstants.missingMaps.errorDescription,
202-
GeoPluginErrorConstants.missingMaps.recoverySuggestion)
214+
GeoPluginErrorConstants.missingMaps.recoverySuggestion
215+
)
203216
}
204217
return mapStyles
205218
}
@@ -213,11 +226,12 @@ extension AWSLocationGeoPlugin {
213226
/// `Geo.Error.networkError` if request failed or network unavailable
214227
/// `Geo.Error.pluginError` if encapsulated error received by a dependent plugin
215228
/// `Geo.Error.unknown` if error is unknown
216-
public func defaultMap() async throws -> Geo.MapStyle {
229+
func defaultMap() async throws -> Geo.MapStyle {
217230
guard let mapName = pluginConfig.defaultMap, let mapStyle = pluginConfig.maps[mapName] else {
218231
throw Geo.Error.invalidConfiguration(
219232
GeoPluginErrorConstants.missingDefaultMap.errorDescription,
220-
GeoPluginErrorConstants.missingDefaultMap.recoverySuggestion)
233+
GeoPluginErrorConstants.missingDefaultMap.recoverySuggestion
234+
)
221235
}
222236
return mapStyle
223237
}

AmplifyPlugins/Geo/Sources/AWSLocationGeoPlugin/AWSLocationGeoPlugin+Configure.swift

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77

88
import Foundation
99
@_spi(InternalAmplifyConfiguration) import Amplify
10+
import AWSClientRuntime
11+
import AWSLocation
1012
import AWSPluginsCore
1113
@_spi(PluginHTTPClientEngine) import InternalAmplifyCredentials
12-
import AWSLocation
13-
import AWSClientRuntime
1414

15-
extension AWSLocationGeoPlugin {
15+
public extension AWSLocationGeoPlugin {
1616
/// Configures AWSLocationPlugin with the specified configuration.
1717
///
1818
/// This method will be invoked as part of the Amplify configuration flow.
1919
///
2020
/// - Parameter configuration: The configuration specified for this plugin.
2121
/// - Throws:
2222
/// - PluginError.pluginConfigurationError: If one of the configuration values is invalid or empty.
23-
public func configure(using configuration: Any?) throws {
23+
func configure(using configuration: Any?) throws {
2424
let pluginConfiguration: AWSLocationGeoPluginConfiguration
2525
if let configuration = configuration as? AmplifyOutputsData {
2626
pluginConfiguration = try AWSLocationGeoPluginConfiguration(config: configuration)
@@ -34,7 +34,7 @@ extension AWSLocationGeoPlugin {
3434
}
3535

3636
/// Configure AWSLocationPlugin programatically using AWSLocationPluginConfiguration
37-
public func configure(using configuration: AWSLocationGeoPluginConfiguration) throws {
37+
func configure(using configuration: AWSLocationGeoPluginConfiguration) throws {
3838
let authService = AWSAuthService()
3939
let credentialsProvider = authService.getCredentialsProvider()
4040
let region = configuration.regionName
@@ -49,9 +49,11 @@ extension AWSLocationGeoPlugin {
4949
let location = LocationClient(config: serviceConfiguration)
5050
let locationService = AWSLocationAdapter(location: location)
5151

52-
configure(locationService: locationService,
53-
authService: authService,
54-
pluginConfig: configuration)
52+
configure(
53+
locationService: locationService,
54+
authService: authService,
55+
pluginConfig: configuration
56+
)
5557
}
5658

5759
// MARK: - Internal
@@ -64,9 +66,11 @@ extension AWSLocationGeoPlugin {
6466
/// - locationService: The location service object.
6567
/// - authService: The authentication service object.
6668
/// - pluginConfig: The configuration for the plugin.
67-
func configure(locationService: AWSLocationBehavior,
68-
authService: AWSAuthServiceBehavior,
69-
pluginConfig: AWSLocationGeoPluginConfiguration) {
69+
internal func configure(
70+
locationService: AWSLocationBehavior,
71+
authService: AWSAuthServiceBehavior,
72+
pluginConfig: AWSLocationGeoPluginConfiguration
73+
) {
7074
self.locationService = locationService
7175
self.authService = authService
7276
self.pluginConfig = pluginConfig

AmplifyPlugins/Geo/Sources/AWSLocationGeoPlugin/AWSLocationGeoPlugin+Reset.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
import Amplify
99
import Foundation
1010

11-
extension AWSLocationGeoPlugin {
11+
public extension AWSLocationGeoPlugin {
1212

1313
/// Resets the state of the plugin.
1414
///
1515
/// Sets stored objects to nil to allow deallocation, then calls onComplete closure
1616
/// to signal the reset has completed.
17-
public func reset() async {
17+
func reset() async {
1818
locationService = nil
1919
authService = nil
2020
pluginConfig = nil

0 commit comments

Comments
 (0)