OSDN Git Service

swiftlint 'legacy_constructor' の警告を修正
authormasakih <masakih@users.sourceforge.jp>
Sun, 12 Mar 2017 13:03:15 +0000 (22:03 +0900)
committermasakih <masakih@users.sourceforge.jp>
Sun, 12 Mar 2017 13:03:15 +0000 (22:03 +0900)
.swiftlint.yml
KCD/GameViewController.swift
KCD/HistoryMarkTransformer.swift
KCD/ImageView.swift
KCD/ScreenshotCollectionViewItem.swift
KCD/ScreenshotEditorViewController.swift
KCD/ScreenshotListViewController.swift
KCD/StrokeTextFieldCell.swift
KCD/SuppliesCell.swift

index 473a7e6..1ecefc6 100644 (file)
@@ -6,7 +6,6 @@ disabled_rules:
     - force_try
     - leading_whitespace
     - vertical_whitespace
-    - legacy_constructor
     - cyclomatic_complexity
     - legacy_nsgeometry_functions
     - redundant_optional_initialization
index 0bad2c3..97bc53e 100644 (file)
@@ -163,7 +163,7 @@ extension GameViewController: WebFrameLoadDelegate, WebUIDelegate {
             )
             let top = context.objectForKeyedSubscript("atop").toDouble()
             let left = context.objectForKeyedSubscript("aleft").toDouble()
-            flashTopLeft = NSMakePoint(CGFloat(left), webView.frame.size.height - CGFloat(top) - 480)
+            flashTopLeft = NSPoint(x: CGFloat(left), y: webView.frame.size.height - CGFloat(top) - 480)
         }
         if path.hasSuffix("app_id=854854") {
             guard let context = frame.javaScriptContext else { return }
@@ -183,7 +183,7 @@ extension GameViewController: WebFrameLoadDelegate, WebUIDelegate {
             guard validIframe != 0 else { return }
             let top = context.objectForKeyedSubscript("atop").toDouble()
             let left = context.objectForKeyedSubscript("aleft").toDouble()
-            flashTopLeft = NSMakePoint(flashTopLeft.x + CGFloat(left), flashTopLeft.y - CGFloat(top))
+            flashTopLeft = NSPoint(x: flashTopLeft.x + CGFloat(left), y: flashTopLeft.y - CGFloat(top))
             adjustFlash()
         }
     }
index a55431d..3e633d0 100644 (file)
@@ -19,10 +19,10 @@ class HistoryMarkTransformer: ValueTransformer {
     
     static var markImage: NSImage = {
         let radius: CGFloat = 10.0
-        let image = NSImage(size: NSMakeSize(radius, radius))
+        let image = NSImage(size: NSSize(width: radius, height: radius))
         image.lockFocus()
         NSColor.red.highlight(withLevel: 0.6)?.set()
-        NSBezierPath(roundedRect: NSMakeRect(0, 0, radius, radius),
+        NSBezierPath(roundedRect: NSRect(x: 0, y: 0, width: radius, height: radius),
                      xRadius: radius / 2,
                      yRadius: radius / 2)
         .fill()
index 1f24293..83267de 100644 (file)
@@ -33,7 +33,7 @@ class ImageView: NSView {
     private var imageShadow: NSShadow {
         if let s = internalImageShadow { return s }
         let s = NSShadow()
-        s.shadowOffset = NSMakeSize(2, -2)
+        s.shadowOffset = NSSize(width: 2, height: -2)
         s.shadowBlurRadius = 4
         s.shadowColor = NSColor.darkGray
         internalImageShadow = s
index 55d315c..65ad979 100644 (file)
@@ -48,10 +48,10 @@ class ScreenshotCollectionViewItem: NSCollectionViewItem {
         } else {
             ratio = ratioX
         }
-        let fitSize = NSMakeSize(imageSize.width * ratio, imageSize.height * ratio)
+        let fitSize = NSSize(width: imageSize.width * ratio, height: imageSize.height * ratio)
         let left = (target.size.width - fitSize.width) * 0.5
         let bottom = (target.size.height - fitSize.height) * 0.5
-        return NSMakeRect(left, bottom, fitSize.width, fitSize.height)
+        return NSRect(x: left, y: bottom, width: fitSize.width, height: fitSize.height)
     }
 }
 
index dc3f356..b1ccded 100644 (file)
@@ -39,9 +39,9 @@ class ScreenshotEditorViewController: BridgeViewController {
     
     override init?(nibName: String?, bundle: Bundle?) {
         trimInfo = [
-            TrimRectInformation(name: "Status", rect: NSMakeRect(328, 13, 470, 365)),
-            TrimRectInformation(name: "List", rect: NSMakeRect(362, 15, 438, 368)),
-            TrimRectInformation(name: "AirplaneBase", rect: NSMakeRect(575, 13, 225, 358))
+            TrimRectInformation(name: "Status", rect: NSRect(x: 328, y: 13, width: 470, height: 365)),
+            TrimRectInformation(name: "List", rect: NSRect(x: 362, y: 15, width: 438, height: 368)),
+            TrimRectInformation(name: "AirplaneBase", rect: NSRect(x: 575, y: 13, width: 225, height: 358))
         ]
         currentTrimInfo = trimInfo[0]
         super.init(nibName: "ScreenshotEditorViewController", bundle: nil)
index e024c8c..10ce903 100644 (file)
@@ -307,7 +307,7 @@ class ScreenshotListViewController: NSViewController {
 extension ScreenshotListViewController: NSCollectionViewDelegateFlowLayout {
     func collectionView(_ collectionView: NSCollectionView, layout collectionViewLayout: NSCollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> NSSize {
         let f = realFromZoom(zoom: zoom)
-        return NSMakeSize(f, f)
+        return NSSize(width: f, height: f)
     }
 }
 
index 4064759..3b2568f 100644 (file)
@@ -40,7 +40,7 @@ class StrokeTextFieldCell: NSTextFieldCell {
         let range = layoutManager.glyphRange(for: textContainer)
         let glyph = UnsafeMutablePointer<CGGlyph>.allocate(capacity: range.length)
         let glyphLength = layoutManager.getGlyphs(in: range, glyphs: glyph, properties: nil, characterIndexes: nil, bidiLevels: nil)
-        var point = NSMakePoint(StrokeTextFieldCell.boarderWidth, 0)
+        var point = NSPoint(x: StrokeTextFieldCell.boarderWidth, y: 0)
         point.y -= font.descender
         if controlView.isFlipped {
             point.y -= NSHeight(controlView.frame)
index fac6767..7f7557a 100644 (file)
@@ -61,7 +61,7 @@ class SuppliesCell: NSCell {
         let y: CGFloat = type == .fuel ? height + 2.0 : 1.0
         for i in 0...10 {
             let x: CGFloat = CGFloat(1 + i) + width * CGFloat(i)
-            let cellRect = NSMakeRect(x, y, width, height)
+            let cellRect = NSRect(x: x, y: y, width: width, height: height)
             color(of: type, position: i, border: border).set()
             NSBezierPath(rect: cellRect).fill()
         }