OSDN Git Service

swiftlint 'statement_position' の警告を修正
authormasakih <masakih@users.sourceforge.jp>
Mon, 13 Mar 2017 13:01:45 +0000 (22:01 +0900)
committermasakih <masakih@users.sourceforge.jp>
Mon, 13 Mar 2017 13:01:45 +0000 (22:01 +0900)
21 files changed:
.swiftlint.yml
EquipmentEnhancementListBuilder/main.swift
KCD/AppDelegate.swift
KCD/BroserWindowController.swift
KCD/CalculateDamageCommand.swift
KCD/ChangeHenseiCommand.swift
KCD/CombinedCommand.swift
KCD/CoreDataCore.swift
KCD/Fleet.swift
KCD/FleetManager.swift
KCD/JSONMapper.swift
KCD/JSONTracker.swift
KCD/JSONViewCommand.swift
KCD/KenzoDockStatus.swift
KCD/MissionStatus.swift
KCD/NyukyoDockStatus.swift
KCD/ScreenshotInformation.swift
KCD/ScreenshotListViewController.swift
KCD/TSVSupport.swift
KCD/TiledImageView.swift
KCD/UserDefaultsExtension.swift

index eb1468d..9b72ade 100644 (file)
@@ -6,7 +6,6 @@ disabled_rules:
     - trailing_comma
     - function_parameter_count
     - opening_brace
-    - statement_position
     - todo
     - trailing_whitespace
 
index df91a47..cb2aad7 100644 (file)
@@ -84,8 +84,9 @@ func generate(threeLines: ThreeItemsQueue<TabSeparatedLine>) -> [RequiredEquipme
 
 //
 func loadFile(path: String) -> String? {
-    do { return try String(contentsOfFile: path) }
-    catch {
+    do {
+        return try String(contentsOfFile: path)
+    } catch {
         print("Can not create String from \(path)")
         return nil
     }
index db0cbed..4ae6a32 100644 (file)
@@ -239,8 +239,9 @@ class AppDelegate: NSObject {
                 let array = self.jsonViewWindowController?.commands
                 else { return }
             let data = NSKeyedArchiver.archivedData(withRootObject: array)
-            do { try data.write(to: url) }
-            catch { print("Can not write to \(url)") }
+            do {
+                try data.write(to: url)
+            } catch { print("Can not write to \(url)") }
         }
     }
     @IBAction func openDocument(_ sender: AnyObject?) {
@@ -263,8 +264,7 @@ class AppDelegate: NSObject {
                 self.logedJSONViewWindowController?.commands = commands
                 self.logedJSONViewWindowController?.window?.title = "SAVED LOG FILE VIEWER"
                 self.logedJSONViewWindowController?.showWindow(nil)
-            }
-            catch { print("Can not load \(url)") }
+            } catch { print("Can not load \(url)") }
         }
     }
     
index 657d873..4cdf92e 100644 (file)
@@ -229,8 +229,7 @@ class BroserWindowController: NSWindowController {
         UserDefaults.standard.screenshotButtonSize = newSize
     }
     @IBAction func showHideCombinedView(_ sender: AnyObject?) {
-        if isCombinedMode { hideCombinedView() }
-        else { showCombinedView() }
+         isCombinedMode ? hideCombinedView() : showCombinedView()
     }
     
     @IBAction func fleetListAbove(_ sender: AnyObject?) {
index 9568cc7..cfe685e 100644 (file)
@@ -172,8 +172,7 @@ class CalculateDamageCommand: JSONCommand {
                 // targetは自軍か?
                 if let e = eFlags, 0..<e.count ~= i {
                     if e[i] != 1 { return }
-                }
-                else {
+                } else {
                     if battleFleet == .each {
                         guard 1...12 ~= targetPosition else { return }
                     } else {
index fd9fdc7..a0d3b88 100644 (file)
@@ -121,8 +121,7 @@ class ChangeHenseiCommand: JSONCommand {
                    fleetNumber: deckNumber,
                    position: shipIndex,
                    shipID: replaceShipId)
-        }
-        else if alreadyInFleet {
+        } else if alreadyInFleet {
             notify(type: .replace,
                    fleetNumber: deckNumber,
                    position: shipIndex,
@@ -130,8 +129,7 @@ class ChangeHenseiCommand: JSONCommand {
                    replaceFleetNumber: shipDeckNumber + 1,
                    replacePosition: shipDeckIndex,
                    replaceShipID: replaceShipId)
-        }
-        else {
+        } else {
             notify(type: .append,
                    fleetNumber: deckNumber,
                    position: shipIndex,
index a364275..c2033b7 100644 (file)
@@ -33,8 +33,9 @@ class CombinedCommand: JSONCommand {
             if let t = data["api_combined_flag"] as? Int {
                 CombineType(rawValue: t)
                     .map { postNotification(withType: $0) }
+            } else {
+                postNotification(withType: .cancel)
             }
-            else { postNotification(withType: .cancel) }
             return
         }
         
index b2fa37c..817363c 100644 (file)
@@ -104,8 +104,7 @@ private class CoreDataRemover {
     private class func removeDatabaseFileAtURL(url: URL) {
         do {
             try FileManager.default.removeItem(at: url)
-        }
-        catch {
+        } catch {
             print("Could not remove file for URL (\(url))")
         }
     }
@@ -118,8 +117,7 @@ private class MocGenerater {
             let coordinator = try createPersistentStoreCoordinator(info, model)
             let moc = createManagedObjectContext(coordinator)
             return (model: model, coordinator: coordinator, moc: moc)
-        }
-        catch {
+        } catch {
             throw error
         }
     }
@@ -143,8 +141,7 @@ private class MocGenerater {
                 failureReason = "Expected a folder to store application data, found a file \(ApplicationDirecrories.support.path)."
                 shouldFail = true
             }
-        }
-        catch {
+        } catch {
             let nserror = error as NSError
             if nserror.code == NSFileReadNoSuchFileError {
                 do {
@@ -172,8 +169,7 @@ private class MocGenerater {
                     do {
                         try coordinator!.addPersistentStore(ofType: info.storeType, configurationName: nil, at: url, options: info.storeOptions)
                         failError = nil
-                    }
-                    catch {
+                    } catch {
                         failError = error as NSError
                     }
                 }
@@ -211,12 +207,14 @@ extension CoreDataProvider {
             NSLog("\(String(describing: type(of: self))) unable to commit editing before saveing")
             return
         }
-        do { try managedObjectContext.save() }
-        catch { presentOnMainThread(error) }
+        do {
+            try managedObjectContext.save()
+        } catch { presentOnMainThread(error) }
         if let p = managedObjectContext.parent {
             p.performAndWait {
-                do { try p.save() }
-                catch { self.presentOnMainThread(error) }
+                do {
+                    try p.save()
+                } catch { self.presentOnMainThread(error) }
             }
         }
     }
index c21bab5..3f99384 100644 (file)
@@ -35,8 +35,7 @@ class Fleet: NSObject {
         req.predicate = deckController.fetchPredicate
         do {
             try deckController.fetch(with: req, merge: false)
-        }
-        catch {
+        } catch {
             print("Fetch error")
             return nil
         }
index 07b308b..c608f3a 100644 (file)
@@ -44,8 +44,7 @@ class FleetManager: NSObject {
                 self.setupFleetController()
                 center.post(name: .DidPrepareFleet, object: self)
             }
-        }
-        else { setupFleetController() }
+        } else { setupFleetController() }
     }
     
     private func setNewFleetNumberToShip() {
index da213b8..1cf5c76 100644 (file)
@@ -62,8 +62,11 @@ extension JSONMapper {
     }
     func setValueIfNeeded(_ value: AnyObject?, to object: ObjectType, forKey key: String) {
         var validValue = value
-        do { try object.validateValue(&validValue, forKey: key) }
-        catch { return }
+        do {
+            try object.validateValue(&validValue, forKey: key)
+        } catch {
+            return
+        }
         
         let old = object.value(forKey: key)
         if !isEqual(old as AnyObject?, validValue) {
index c949b2e..089514b 100644 (file)
@@ -26,8 +26,7 @@ class JSONTracker {
             else { return print("Dequeued item is not APIResponse") }
         do {
             try CommandRegister.command(for: item).execute()
-        }
-        catch {
+        } catch {
             print("JSONTracker Cought Exception -> \(error)")
         }
     }
index 173418d..b774545 100644 (file)
@@ -35,8 +35,7 @@ class JSONViewCommand: JSONCommand {
     override func execute() {
         do {
             try command.execute()
-        }
-        catch {
+        } catch {
             print("JSONTracker Cought Exception -> \(error)")
         }
         
index ed5de66..3ef5ea5 100644 (file)
@@ -67,8 +67,7 @@ class KenzoDockStatus: NSObject {
         let now = Date()
         let diff = compTime - now.timeIntervalSince1970
         
-        if diff < 0 { realTime = 0 }
-        else { realTime = diff }
+        realTime = diff < 0 ? 0 : diff
         
         if didNotify { return }
         if diff > 0 { return }
index b8ad937..4cce635 100644 (file)
@@ -85,8 +85,7 @@ class MissionStatus: NSObject {
         let now = Date()
         let diff = compTime - now.timeIntervalSince1970
         
-        if diff < 0 { realTime = 0 }
-        else { realTime = diff }
+        realTime = diff < 0 ? 0 : diff
         
         if didNotify { return }
         if diff >= 1 * 60 { return }
index 8b07ded..f30f3ad 100644 (file)
@@ -81,8 +81,7 @@ class NyukyoDockStatus: NSObject {
         let now = Date()
         let diff = compTime - now.timeIntervalSince1970
         
-        if diff < 0 { realTime = 0 }
-        else { realTime = diff }
+        realTime = diff < 0 ? 0 : diff
         
         if didNotify { return }
         if diff >= 1 * 60 { return }
index 252afe5..57b0100 100644 (file)
@@ -34,8 +34,7 @@ class ScreenshotInformation: NSObject, NSCoding {
                 } else {
                     try url.setResourceValue([] as NSArray, forKey: .tagNamesKey)
                 }
-            }
-            catch {
+            } catch {
                 print("Can not set tagNames")
             }
         }
index 6c952dc..c3628c4 100644 (file)
@@ -73,8 +73,7 @@ class ScreenshotListViewController: NSViewController {
                 print("\(url) is regular file, not direcory.")
                 return parentURL
             }
-        }
-        catch {
+        } catch {
             print("Can not create screenshot save directory.")
             return parentURL
         }
@@ -152,8 +151,7 @@ class ScreenshotListViewController: NSViewController {
                 let pathURL = FileManager.default.uniqueFileURL(url)
                 do {
                     try data.write(to: pathURL)
-                }
-                catch {
+                } catch {
                     print("Can not write image")
                     return
                 }
@@ -232,8 +230,7 @@ class ScreenshotListViewController: NSViewController {
         let data = NSKeyedArchiver.archivedData(withRootObject: screenshots.screenshots)
         do {
             try data.write(to: cachURL)
-        }
-        catch let e {
+        } catch let e {
             print("Can not write cache: \(e)")
         }
     }
@@ -257,8 +254,7 @@ class ScreenshotListViewController: NSViewController {
         let infos = deletedPaths.filter { $0.url == url }
         if var info = infos.first {
             info.incrementVersion()
-        }
-        else {
+        } else {
             deletedPaths.append(CacheVersionInfo(url: url))
         }
     }
index 0a84615..cd0e2e5 100644 (file)
@@ -82,8 +82,9 @@ class TSVSupport {
             fileW.addRegularFile(withContents: kenzoHistory, preferredFilename: "kenzo.tsv")
             fileW.addRegularFile(withContents: kenzoMark, preferredFilename: "kenzoMark.tsv")
             fileW.addRegularFile(withContents: dropShipHistory, preferredFilename: "dropShip.tsv")
-            do { try fileW.write(to: url, originalContentsURL: nil) }
-            catch { print("Error to write") }
+            do {
+                try fileW.write(to: url, originalContentsURL: nil)
+            } catch { print("Error to write") }
         }
     }
     
index 07882f5..b8376a4 100644 (file)
@@ -210,8 +210,7 @@ extension TiledImageView {
 
 extension TiledImageView: NSDraggingSource {
     func draggingSession(_ session: NSDraggingSession, sourceOperationMaskFor context: NSDraggingContext) -> NSDragOperation {
-        if context == .withinApplication { return .move }
-        else { return [] }
+        return context == .withinApplication ? .move : []
     }
     override func draggingEntered(_ sender: NSDraggingInfo) -> NSDragOperation {
         return draggingUpdated(sender)
index 075b9fc..e11ef50 100644 (file)
@@ -170,8 +170,7 @@ extension UserDefaults {
         get {
             let r = double(forKey: "screenShotBorderWidth")
             if r < 0 { return 0.0 }
-            else if r > 20 { return 20.0 }
-            return CGFloat(r)
+            return r > 20 ? 20.0 : CGFloat(r)
         }
         set {
             if 0.0..<20 ~= newValue { return }
@@ -298,9 +297,13 @@ extension UserDefaults {
     var notifyTimeBeforeTimeSignal: Int {
         get { return integer(forKey: "notifyTimeBeforeTimeSignal") }
         set {
-            if newValue < 1 { set(1, forKey: "notifyTimeBeforeTimeSignal") }
-            else if newValue > 59 { set(59, forKey: "notifyTimeBeforeTimeSignal") }
-            else { set(newValue, forKey: "notifyTimeBeforeTimeSignal") }
+            if newValue < 1 {
+                set(1, forKey: "notifyTimeBeforeTimeSignal")
+            } else if newValue > 59 {
+                set(59, forKey: "notifyTimeBeforeTimeSignal")
+            } else {
+                set(newValue, forKey: "notifyTimeBeforeTimeSignal")
+            }
         }
     }
     var playNotifyTimeSignalSound: Bool {