My code is being warned of violating following rules:
swift:S1481
swift:S1854
While the code is not really violating any of these rules and the code smell is on the last line of my below code
let coordinates = searchParameters.locations.compactMap(\.coordinate).uniqued().compactMap { $0.locationCoordinate() }
var cameraOptions: CameraOptions?
if coordinates.count > 1 {
cameraOptions = mapView.mapboxMap.camera(for: coordinates,
padding: Constants.padding,
bearing: mapView.mapboxMap.cameraState.bearing,
pitch: mapView.mapboxMap.cameraState.pitch)
} else {
guard let coordinate = coordinates.first else {
logger.warn("coordinates is nil")
return
}
cameraOptions = CameraOptions(center: coordinate,
padding: Constants.padding,
zoom: Country.current.mapSetupData.zoom * 1.8)
}
guard let cameraOptions = cameraOptions else { return }