- trailing_comma
- function_parameter_count
- opening_brace
- - statement_position
- todo
- trailing_whitespace
//
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
}
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?) {
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)") }
}
}
UserDefaults.standard.screenshotButtonSize = newSize
}
@IBAction func showHideCombinedView(_ sender: AnyObject?) {
- if isCombinedMode { hideCombinedView() }
- else { showCombinedView() }
+ isCombinedMode ? hideCombinedView() : showCombinedView()
}
@IBAction func fleetListAbove(_ sender: AnyObject?) {
// 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 {
fleetNumber: deckNumber,
position: shipIndex,
shipID: replaceShipId)
- }
- else if alreadyInFleet {
+ } else if alreadyInFleet {
notify(type: .replace,
fleetNumber: deckNumber,
position: shipIndex,
replaceFleetNumber: shipDeckNumber + 1,
replacePosition: shipDeckIndex,
replaceShipID: replaceShipId)
- }
- else {
+ } else {
notify(type: .append,
fleetNumber: deckNumber,
position: shipIndex,
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
}
private class func removeDatabaseFileAtURL(url: URL) {
do {
try FileManager.default.removeItem(at: url)
- }
- catch {
+ } catch {
print("Could not remove file for URL (\(url))")
}
}
let coordinator = try createPersistentStoreCoordinator(info, model)
let moc = createManagedObjectContext(coordinator)
return (model: model, coordinator: coordinator, moc: moc)
- }
- catch {
+ } catch {
throw error
}
}
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 {
do {
try coordinator!.addPersistentStore(ofType: info.storeType, configurationName: nil, at: url, options: info.storeOptions)
failError = nil
- }
- catch {
+ } catch {
failError = error as NSError
}
}
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) }
}
}
}
req.predicate = deckController.fetchPredicate
do {
try deckController.fetch(with: req, merge: false)
- }
- catch {
+ } catch {
print("Fetch error")
return nil
}
self.setupFleetController()
center.post(name: .DidPrepareFleet, object: self)
}
- }
- else { setupFleetController() }
+ } else { setupFleetController() }
}
private func setNewFleetNumberToShip() {
}
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) {
else { return print("Dequeued item is not APIResponse") }
do {
try CommandRegister.command(for: item).execute()
- }
- catch {
+ } catch {
print("JSONTracker Cought Exception -> \(error)")
}
}
override func execute() {
do {
try command.execute()
- }
- catch {
+ } catch {
print("JSONTracker Cought Exception -> \(error)")
}
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 }
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 }
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 }
} else {
try url.setResourceValue([] as NSArray, forKey: .tagNamesKey)
}
- }
- catch {
+ } catch {
print("Can not set tagNames")
}
}
print("\(url) is regular file, not direcory.")
return parentURL
}
- }
- catch {
+ } catch {
print("Can not create screenshot save directory.")
return parentURL
}
let pathURL = FileManager.default.uniqueFileURL(url)
do {
try data.write(to: pathURL)
- }
- catch {
+ } catch {
print("Can not write image")
return
}
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)")
}
}
let infos = deletedPaths.filter { $0.url == url }
if var info = infos.first {
info.incrementVersion()
- }
- else {
+ } else {
deletedPaths.append(CacheVersionInfo(url: url))
}
}
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") }
}
}
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)
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 }
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 {