Skip to content

Commit ad594e3

Browse files
committed
fixed the large majority of the swiftlint warnings
1 parent 214e15f commit ad594e3

24 files changed

+137
-182
lines changed

Diff for: OpenGpxTracker-Watch Extension/GPXFileTableInterfaceController.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class GPXFileTableInterfaceController: WKInterfaceController {
176176
if gpxFilesFound {
177177
for index in 0..<fileTable.numberOfRows {
178178
guard let cell = fileTable.rowController(at: index) as? GPXFileTableRowController else { continue }
179-
// swiftlint:disable force_cast
179+
// swiftlint:disable:next force_cast
180180
let gpxFileInfo = fileList.object(at: index) as! GPXFileInfo
181181
cell.fileLabel.setText(gpxFileInfo.fileName)
182182
}
@@ -232,7 +232,7 @@ class GPXFileTableInterfaceController: WKInterfaceController {
232232
self.hideProgressIndicators()
233233
return
234234
}
235-
// swiftlint:disable force_cast
235+
// swiftlint:disable:next force_cast
236236
let gpxFileInfo = fileList.object(at: rowIndex) as! GPXFileInfo
237237
self.scroll(to: progressGroup, at: .top, animated: true) // scrolls to top when indicator is shown.
238238
self.updateProgressIndicators(status: .sending, fileName: gpxFileInfo.fileName)
@@ -257,7 +257,7 @@ class GPXFileTableInterfaceController: WKInterfaceController {
257257
}
258258
GPXFileManager.removeFileFromURL(fileURL)
259259

260-
//Delete from list and Table
260+
// Delete from list and Table
261261
fileList.removeObject(at: rowIndex)
262262

263263
}

Diff for: OpenGpxTracker-Watch Extension/InterfaceController.swift

+21-36
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import MapKit
1111
import CoreLocation
1212
import CoreGPX
1313

14-
//Button colors
14+
// Button colors
1515
let kPurpleButtonBackgroundColor: UIColor = UIColor(red: 146.0/255.0, green: 166.0/255.0, blue: 218.0/255.0, alpha: 0.90)
1616
let kGreenButtonBackgroundColor: UIColor = UIColor(red: 142.0/255.0, green: 224.0/255.0, blue: 102.0/255.0, alpha: 0.90)
1717
let kRedButtonBackgroundColor: UIColor = UIColor(red: 244.0/255.0, green: 94.0/255.0, blue: 94.0/255.0, alpha: 0.90)
@@ -20,7 +20,7 @@ let kDisabledBlueButtonBackgroundColor: UIColor = UIColor(red: 74.0/255.0, green
2020
let kDisabledRedButtonBackgroundColor: UIColor = UIColor(red: 244.0/255.0, green: 94.0/255.0, blue: 94.0/255.0, alpha: 0.10)
2121
let kWhiteBackgroundColor: UIColor = UIColor(red: 254.0/255.0, green: 254.0/255.0, blue: 254.0/255.0, alpha: 0.90)
2222

23-
//Accesory View buttons tags
23+
// Accesory View buttons tags
2424
let kDeleteWaypointAccesoryButtonTag = 666
2525
let kEditWaypointAccesoryButtonTag = 333
2626

@@ -70,7 +70,7 @@ class InterfaceController: WKInterfaceController {
7070
manager.requestAlwaysAuthorization()
7171

7272
manager.desiredAccuracy = kCLLocationAccuracyBest
73-
manager.distanceFilter = 2 //meters
73+
manager.distanceFilter = 2 // meters
7474
manager.allowsBackgroundLocationUpdates = true
7575
return manager
7676
}()
@@ -81,10 +81,10 @@ class InterfaceController: WKInterfaceController {
8181
/// Underlying class that handles background stuff
8282
let map = GPXMapView() // not even a map view. Considering renaming
8383

84-
//Status Vars
84+
// Status Vars
8585
var stopWatch = StopWatch()
8686
var lastGpxFilename: String = ""
87-
var wasSentToBackground: Bool = false //Was the app sent to background
87+
var wasSentToBackground: Bool = false // Was the app sent to background
8888
var isDisplayingLocationServicesDenied: Bool = false
8989

9090
/// Does the 'file' have any waypoint?
@@ -130,36 +130,24 @@ class InterfaceController: WKInterfaceController {
130130
// set Tracker button to allow Start
131131
trackerButton.setTitle(NSLocalizedString("START_TRACKING", comment: "no comment"))
132132
trackerButton.setBackgroundColor(kGreenButtonBackgroundColor)
133-
//save & reset button to transparent.
133+
// Save & reset button to transparent.
134134
saveButton.setBackgroundColor(kDisabledBlueButtonBackgroundColor)
135135
resetButton.setBackgroundColor(kDisabledRedButtonBackgroundColor)
136-
//reset clock
136+
// Reset clock
137137
stopWatch.reset()
138138
timeLabel.setText(stopWatch.elapsedTimeString)
139139

140-
map.reset() //reset gpx logging
141-
lastGpxFilename = "" //clear last filename, so when saving it appears an empty field
140+
map.reset() // Reset gpx logging
141+
lastGpxFilename = "" // Clear last filename, so when saving it appears an empty field
142142

143143
totalTrackedDistanceLabel.setText(map.totalTrackedDistance.toDistance(useImperial: preferences.useImperial))
144-
145-
//currentSegmentDistanceLabel.distance = (map.currentSegmentDistance)
146-
147-
/*
148-
// XXX Left here for reference
149-
UIView.animateWithDuration(0.2, delay: 0.0, options: UIViewAnimationOptions.CurveLinear, animations: { () -> Void in
150-
self.trackerButton.hidden = true
151-
self.pauseButton.hidden = false
152-
}, completion: {(f: Bool) -> Void in
153-
println("finished animation start tracking")
154-
})
155-
*/
156-
144+
157145
case .tracking:
158146
print("switched to tracking mode")
159147
// set trackerButton to allow Pause
160148
trackerButton.setTitle(NSLocalizedString("PAUSE", comment: "no comment"))
161149
trackerButton.setBackgroundColor(kPurpleButtonBackgroundColor)
162-
//activate save & reset buttons
150+
// Activate save & reset buttons
163151
saveButton.setBackgroundColor(kBlueButtonBackgroundColor)
164152
resetButton.setBackgroundColor(kRedButtonBackgroundColor)
165153
// start clock
@@ -173,7 +161,7 @@ class InterfaceController: WKInterfaceController {
173161
// activate save & reset (just in case switched from .NotStarted)
174162
saveButton.setBackgroundColor(kBlueButtonBackgroundColor)
175163
resetButton.setBackgroundColor(kRedButtonBackgroundColor)
176-
//pause clock
164+
// Pause clock
177165
self.stopWatch.stop()
178166
// start new track segment
179167
self.map.startNewTrackSegment()
@@ -182,7 +170,7 @@ class InterfaceController: WKInterfaceController {
182170
}
183171

184172
/// Editing Waypoint Temporal Reference
185-
var lastLocation: CLLocation? //Last point of current segment.
173+
var lastLocation: CLLocation? // Last point of current segment.
186174

187175
override func awake(withContext context: Any?) {
188176
print("InterfaceController:: awake")
@@ -242,7 +230,7 @@ class InterfaceController: WKInterfaceController {
242230
case .tracking:
243231
gpxTrackingStatus = .paused
244232
case .paused:
245-
//set to tracking
233+
// Set to tracking
246234
gpxTrackingStatus = .tracking
247235
}
248236

@@ -279,7 +267,7 @@ class InterfaceController: WKInterfaceController {
279267
let gpxString = self.map.exportToGPXString()
280268
GPXFileManager.save(filename, gpxContents: gpxString)
281269
self.lastGpxFilename = filename
282-
//print(gpxString)
270+
// print(gpxString)
283271

284272
/// Just a 'done' button, without
285273
let action = WKAlertAction(title: "Done", style: .default) {}
@@ -330,19 +318,19 @@ class InterfaceController: WKInterfaceController {
330318
func checkLocationServicesStatus() {
331319
let authorizationStatus = CLLocationManager.authorizationStatus()
332320

333-
//Has the user already made a permission choice?
321+
// Has the user already made a permission choice?
334322
guard authorizationStatus != .notDetermined else {
335-
//We should take no action until the user has made a choice
323+
// We should take no action until the user has made a choice
336324
return
337325
}
338326

339-
//Does the app have permissions to use the location servies?
327+
// Does the app have permissions to use the location servies?
340328
guard [.authorizedAlways, .authorizedWhenInUse ].contains(authorizationStatus) else {
341329
displayLocationServicesDeniedAlert()
342330
return
343331
}
344332

345-
//Are location services enabled?
333+
// Are location services enabled?
346334
guard CLLocationManager.locationServicesEnabled() else {
347335
displayLocationServicesDisabledAlert()
348336
return
@@ -408,8 +396,6 @@ extension InterfaceController: CLLocationManagerDelegate {
408396
altitudeLabel.setText(kUnknownAltitudeText)
409397
signalImageView.setImage(signalImage0)
410398
speedLabel.setText(kUnknownSpeedText)
411-
//signalAccuracyLabel.text = kUnknownAccuracyText
412-
//signalImageView.image = signalImage0
413399
let locationError = error as? CLError
414400
switch locationError?.code {
415401
case CLError.locationUnknown:
@@ -430,7 +416,7 @@ extension InterfaceController: CLLocationManagerDelegate {
430416
///
431417
///
432418
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
433-
//updates signal image accuracy
419+
// Updates signal image accuracy
434420
let newLocation = locations.first!
435421

436422
let hAcc = newLocation.horizontalAccuracy
@@ -461,14 +447,13 @@ extension InterfaceController: CLLocationManagerDelegate {
461447
coordinatesLabel.setText("\(latFormat),\(lonFormat)")
462448
altitudeLabel.setText(newLocation.altitude.toAltitude(useImperial: preferences.useImperial))
463449

464-
//Update speed (provided in m/s, but displayed in km/h)
450+
// Update speed (provided in m/s, but displayed in km/h)
465451
speedLabel.setText(newLocation.speed.toSpeed(useImperial: preferences.useImperial))
466452

467453
if gpxTrackingStatus == .tracking {
468454
print("didUpdateLocation: adding point to track (\(newLocation.coordinate.latitude),\(newLocation.coordinate.longitude))")
469455
map.addPointToCurrentTrackSegmentAtLocation(newLocation)
470456
totalTrackedDistanceLabel.setText(map.totalTrackedDistance.toDistance(useImperial: preferences.useImperial))
471-
//currentSegmentDistanceLabel.distance = map.currentSegmentDistance
472457
}
473458
}
474459
}

Diff for: OpenGpxTracker/AboutViewController.swift

+3-4
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ class AboutViewController: UIViewController {
4242

4343
self.title = NSLocalizedString("ABOUT", comment: "no comment")
4444

45-
//Add the done button
45+
// Add the done button
4646
let shareItem = UIBarButtonItem(title: NSLocalizedString("DONE", comment: "no comment"),
4747
style: UIBarButtonItem.Style.plain, target: self,
4848
action: #selector(AboutViewController.closeViewController))
4949
self.navigationItem.rightBarButtonItems = [shareItem]
5050

51-
//Add the Webview
51+
// Add the Webview
5252
self.webView = WKWebView(frame: self.view.frame, configuration: WKWebViewConfiguration())
5353

5454
self.webView?.navigationDelegate = self
@@ -82,8 +82,7 @@ extension AboutViewController: WKNavigationDelegate {
8282
if navigationAction.navigationType == .linkActivated {
8383
if #available(iOS 10, *) {
8484
UIApplication.shared.open(navigationAction.request.url!)
85-
}
86-
else {
85+
} else {
8786
UIApplication.shared.openURL(navigationAction.request.url!)
8887
}
8988
print("AboutViewController: external link sent to Safari")

Diff for: OpenGpxTracker/AppDelegate.swift

+2-3
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
6767
func applicationWillTerminate(_ application: UIApplication) {
6868
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
6969
// Saves changes in the application's managed object context before the application terminates.
70-
//self.saveContext()
70+
// self.saveContext()
7171
}
7272

7373
/// Default pandle load GPX file
@@ -211,9 +211,8 @@ extension AppDelegate: WCSessionDelegate {
211211
/// Called when a file is received from Apple Watch.
212212
/// Displays a popup informing about the reception of the file.
213213
func session(_ session: WCSession, didReceive file: WCSessionFile) {
214-
// swiftlint:disable force_cast
214+
// swiftlint:disable:next force_cast
215215
let fileName = file.metadata!["fileName"] as! String?
216-
217216
DispatchQueue.global().sync {
218217
GPXFileManager.moveFrom(file.fileURL, fileName: fileName)
219218
print("ViewController:: Received file from WatchConnectivity Session")

Diff for: OpenGpxTracker/CoreDataHelper+FetchRequests.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ extension CoreDataHelper {
2222
self.lastFileName = safePoint.lastFileName ?? ""
2323
self.lastTracksegmentId = safePoint.lastTrackSegmentId
2424
self.isContinued = safePoint.continuedAfterSave
25-
print("Core Data Helper: fetched CDRoot lastFileName:\(self.lastFileName) lastTracksegmentId: \(self.lastTracksegmentId) isContinued: \(self.isContinued)")
25+
// swiftlint:disable:next line_length
26+
print("Core Data Helper: fetched CDRoot lastFileName:\(self.lastFileName) lastTracksegmentId: \(self.lastTracksegmentId) isContinued: \(self.isContinued)")
2627
}
2728
}
2829
return asyncRootFetchRequest
@@ -70,6 +71,7 @@ extension CoreDataHelper {
7071
}
7172
self.trackpointId = trackPointResults.last?.trackpointId ?? Int64()
7273
self.tracksegments.append(self.currentSegment)
74+
// siftlint:disable:next line_length
7375
print("Core Data Helper: fetched CDTrackpoints. # of tracksegments: \(self.tracksegments.count). trackPointId: \(self.trackpointId) trackSegmentId: \(self.tracksegmentId)")
7476
}
7577
}

Diff for: OpenGpxTracker/CoreDataHelper.swift

+7-14
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ class CoreDataHelper {
3434
// MARK: Other Declarations
3535

3636
/// app delegate.
37-
// swiftlint:disable force_cast
3837
let appDelegate = UIApplication.shared.delegate as! AppDelegate
39-
38+
// swiftlint:disable:previous force_cast
4039
// arrays for handling retrieval of data when needed.
4140

4241
// recovered tracksegments
@@ -65,8 +64,8 @@ class CoreDataHelper {
6564
childManagedObjectContext.parent = appDelegate.managedObjectContext
6665

6766
childManagedObjectContext.perform {
67+
// swiftlint:disable:next force_cast
6868
let root = NSEntityDescription.insertNewObject(forEntityName: "CDRoot", into: childManagedObjectContext) as! CDRoot
69-
7069
root.lastFileName = lastFileName
7170
root.continuedAfterSave = willContinue
7271
root.lastTrackSegmentId = self.tracksegmentId
@@ -101,7 +100,7 @@ class CoreDataHelper {
101100

102101
childManagedObjectContext.perform {
103102
print("Core Data Helper: Add trackpoint with id: \(self.trackpointId)")
104-
// swiftlint:disable force_cast
103+
// swiftlint:disable:next force_cast
105104
let pt = NSEntityDescription.insertNewObject(forEntityName: "CDTrackpoint", into: childManagedObjectContext) as! CDTrackpoint
106105

107106
guard let elevation = trackpoint.elevation else { return }
@@ -153,9 +152,8 @@ class CoreDataHelper {
153152

154153
waypointChildManagedObjectContext.perform {
155154
print("Core Data Helper: Add waypoint with id: \(self.waypointId)")
156-
// swiftlint:disable force_cast
155+
// swiftlint:disable:next force_cast
157156
let pt = NSEntityDescription.insertNewObject(forEntityName: "CDWaypoint", into: waypointChildManagedObjectContext) as! CDWaypoint
158-
159157
guard let latitude = waypoint.latitude else { return }
160158
guard let longitude = waypoint.longitude else { return }
161159

@@ -252,7 +250,6 @@ class CoreDataHelper {
252250
print("Failure to update and save waypoint to context at child context: \(error)")
253251
}
254252
}
255-
256253
}
257254

258255
do {
@@ -332,7 +329,6 @@ class CoreDataHelper {
332329

333330
/// Delete all objects of entity given as parameter in Core Data.
334331
func coreDataDeleteAll<T: NSManagedObject>(of type: T.Type) {
335-
336332
print("Core Data Helper: Batch Delete \(T.self) from Core Data")
337333

338334
if #available(iOS 10.0, *) {
@@ -372,7 +368,7 @@ class CoreDataHelper {
372368
// generates a GPXRoot from recovered data
373369
if self.isContinued && self.tracksegments.count >= (self.lastTracksegmentId + 1) {
374370

375-
//Check if there was a tracksegment
371+
// Check if there was a tracksegment
376372
if root.tracks.last?.segments.count == 0 {
377373
root.tracks.last?.add(trackSegment: GPXTrackSegment())
378374
}
@@ -389,7 +385,8 @@ class CoreDataHelper {
389385
DispatchQueue.main.sync {
390386
NotificationCenter.default.post(name: .loadRecoveredFile, object: nil,
391387
userInfo: ["recoveredRoot": root, "fileName": self.lastFileName])
392-
let toastMessage = NSLocalizedString("LAST_SESSION_LOADED", comment: "the filename displayed after the text") + " \n" + self.lastFileName + ".gpx"
388+
let toastMessage = NSLocalizedString("LAST_SESSION_LOADED",
389+
comment: "the filename displayed after the text") + " \n" + self.lastFileName + ".gpx"
393390
Toast.regular(toastMessage, position: .top)
394391
}
395392
} else {
@@ -425,7 +422,6 @@ class CoreDataHelper {
425422
// clear aft save.
426423
self.clearAll()
427424
self.coreDataDeleteAll(of: CDRoot.self)
428-
//self.deleteCDRootFromCoreData()
429425
}
430426

431427
// MARK: Reset & Clear
@@ -438,7 +434,6 @@ class CoreDataHelper {
438434
self.trackpointId = 0
439435
self.waypointId = 0
440436
self.tracksegmentId = 0
441-
442437
}
443438

444439
/// Clear all arrays and current segment after recovery.
@@ -477,7 +472,5 @@ class CoreDataHelper {
477472

478473
// reset order sorting ids
479474
self.resetIds()
480-
481475
}
482-
483476
}

Diff for: OpenGpxTracker/DefaultDateFormat.swift

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class DefaultDateFormat {
4646

4747
/// Returns sample date time based on user input.
4848
func getDate(processedFormat dateFormat: String, useUTC: Bool = false, useENLocale: Bool = false) -> String {
49-
//processedDateFormat = DefaultDateFormat.getDateFormat(unprocessed: self.cellTextField.text!)
5049
dateFormatter.dateFormat = dateFormat
5150
dateFormatter.timeZone = useUTC ? TimeZone(secondsFromGMT: 0) : TimeZone.current
5251
dateFormatter.locale = useENLocale ? Locale(identifier: "en_US_POSIX") : Locale.current

0 commit comments

Comments
 (0)