Skip to content

Commit 4008595

Browse files
Fix SwiftLint violations
1 parent 883fe47 commit 4008595

32 files changed

+88
-149
lines changed

.swiftlint.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
disabled_rules:
22
- line_length
33
- type_body_length
4-
- variable_name
5-
- variable_name_min_length
64
- file_length
5+
- trailing_comma
76
- valid_docs
7+
- variable_name

C4/Core/Color.swift

-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ public class Color {
9191
internalColor = CGColor(colorSpace: colorSpace, components: [CGFloat(red), CGFloat(green), CGFloat(blue), CGFloat(alpha)])!
9292
}
9393

94-
9594
/// Initializes and returns a new Color object based on specified color values.
9695
/// ````
9796
/// let c = Color(hue: 1.0, saturation: 0.0, brightness: 0.0, alpha: 1.0)

C4/Core/EventSource.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ extension NSObject : EventSource {
9393
@discardableResult
9494
public func on(event notificationName: String, from sender: AnyObject?, run executionBlock: @escaping (Void) -> Void) -> AnyObject {
9595
let nc = NotificationCenter.default
96-
return nc.addObserver(forName: NSNotification.Name(rawValue: notificationName), object: sender, queue: OperationQueue.current, using: { notification in
96+
return nc.addObserver(forName: NSNotification.Name(rawValue: notificationName), object: sender, queue: OperationQueue.current, using: { _ in
9797
executionBlock()
9898
})
9999
}

C4/Core/Foundation.swift

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import CoreGraphics
2121

22-
2322
/// Prints a string to the console. Replacement for the noisy NSlog.
2423
///
2524
/// ````
@@ -32,7 +31,6 @@ public func C4Log<T>(_ value: T) {
3231
print("[C4Log] \(value)")
3332
}
3433

35-
3634
/// Returns a rectangle that contains all of the specified coordinates in an array.
3735
///
3836
/// ````
@@ -61,6 +59,6 @@ public func CGRectMakeFromPoints(_ points: [CGPoint]) -> CGRect {
6159
///
6260
/// - parameter delay: The amount of time in seconds to wait before executing the block of code.
6361
/// - parameter action: A block of code to perform after the delay.
64-
public func wait(_ seconds: Double, action: @escaping ()->()) {
62+
public func wait(_ seconds: Double, action: @escaping () -> Void) {
6563
DispatchQueue.main.asyncAfter(wallDeadline: DispatchWallTime.now() + seconds, execute: action)
6664
}

C4/Core/Path.swift

+1-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public enum FillRule {
3333
case EvenOdd
3434
}
3535

36-
3736
/// A Path is a sequence of geometric segments which can be straight lines or curves.
3837
@IBDesignable
3938
public class Path: Equatable {
@@ -86,9 +85,7 @@ public class Path: Equatable {
8685

8786
/// A CGPathRef representation of the receiver's path.
8887
public var CGPath: CoreGraphics.CGPath {
89-
get {
90-
return internalPath
91-
}
88+
return internalPath
9289
}
9390
}
9491

C4/Core/Point.swift

+1-3
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@ public struct Point: Equatable, CustomStringConvertible {
9696
///
9797
/// - returns: A string formatted to look like {x,y}
9898
public var description: String {
99-
get {
100-
return "{\(x), \(y)}"
101-
}
99+
return "{\(x), \(y)}"
102100
}
103101
}
104102

C4/Core/Rect.swift

+7-11
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public struct Rect: Equatable, CustomStringConvertible {
119119
self.init(f.origin, f.size)
120120
}
121121

122-
//MARK: - Comparing
122+
// MARK: - Comparing
123123

124124
/// Returns whether two rectangles intersect.
125125
/// ````
@@ -135,7 +135,7 @@ public struct Rect: Equatable, CustomStringConvertible {
135135
return CGRect(self).intersects(CGRect(rect))
136136
}
137137

138-
//MARK: - Center & Max
138+
// MARK: - Center & Max
139139

140140
/// The center point of the receiver.
141141
/// ````
@@ -158,9 +158,7 @@ public struct Rect: Equatable, CustomStringConvertible {
158158
/// r.max //-> {15,15}
159159
/// ````
160160
public var max: Point {
161-
get {
162-
return Point(origin.x + size.width, origin.y + size.height)
163-
}
161+
return Point(origin.x + size.width, origin.y + size.height)
164162
}
165163

166164
/// Checks to see if the receiver has zero size and position
@@ -173,7 +171,7 @@ public struct Rect: Equatable, CustomStringConvertible {
173171
return origin.isZero() && size.isZero()
174172
}
175173

176-
//MARK: - Membership
174+
// MARK: - Membership
177175

178176
/// Returns whether a rectangle contains a specified point.
179177
/// ````
@@ -206,13 +204,11 @@ public struct Rect: Equatable, CustomStringConvertible {
206204
/// A string representation of the rect.
207205
/// - returns: A string formatted to look like {{x,y},{w,h}}
208206
public var description: String {
209-
get {
210-
return "{\(origin),\(size)}"
211-
}
207+
return "{\(origin),\(size)}"
212208
}
213209
}
214210

215-
//MARK: - Comparing
211+
// MARK: - Comparing
216212

217213
/// Checks to see if two Rects share identical origin and size
218214
///
@@ -228,7 +224,7 @@ public func == (lhs: Rect, rhs: Rect) -> Bool {
228224
return lhs.origin == rhs.origin && lhs.size == rhs.size
229225
}
230226

231-
//MARK: - Manipulating
227+
// MARK: - Manipulating
232228

233229
/// Returns the intersection of two rectangles.
234230
///

C4/Core/Size.swift

+1-3
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ public struct Size: Equatable, Comparable, CustomStringConvertible {
8080
///
8181
/// - returns: A string formatted to look like {w,h}
8282
public var description: String {
83-
get {
84-
return "{\(width),\(height)}"
85-
}
83+
return "{\(width),\(height)}"
8684
}
8785
}
8886

C4/Core/Transform.swift

-2
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ public func * (t: Transform, s: Double) -> Transform {
277277
return r
278278
}
279279

280-
281280
/// Transform matrix scalar multiplication
282281
/// - parameter s: A scalar value to apply to the transform
283282
/// - parameter t: The transform to scale
@@ -286,7 +285,6 @@ public func * (s: Double, t: Transform) -> Transform {
286285
return t * s
287286
}
288287

289-
290288
/// Concatenate two transformations. This is the same as t2 * t1.
291289
/// - parameter t1: The first transform to contatenate
292290
/// - parameter t2: The second transform to contatenate

C4/UI/Animation.swift

+2-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ public class Animation {
6969
private var completionObservers: [AnyObject] = []
7070
private var cancelObservers: [AnyObject] = []
7171

72-
7372
static var stack = [Animation]()
7473
static var currentAnimation: Animation? {
7574
return stack.last
@@ -102,7 +101,7 @@ public class Animation {
102101
/// - returns: the observer object.
103102
public func addCompletionObserver(_ action: @escaping () -> Void) -> AnyObject {
104103
let nc = NotificationCenter.default
105-
let observer = nc.addObserver(forName: NSNotification.Name(rawValue: AnimationCompletedEvent), object: self, queue: OperationQueue.current, using: { notification in
104+
let observer = nc.addObserver(forName: NSNotification.Name(rawValue: AnimationCompletedEvent), object: self, queue: OperationQueue.current, using: { _ in
106105
action()
107106
})
108107
completionObservers.append(observer)
@@ -135,7 +134,7 @@ public class Animation {
135134
/// - returns: the observer object.
136135
public func addCancelObserver(_ action: @escaping () -> Void) -> AnyObject {
137136
let nc = NotificationCenter.default
138-
let observer = nc.addObserver(forName: NSNotification.Name(rawValue: AnimationCancelledEvent), object: self, queue: OperationQueue.current, using: { notification in
137+
let observer = nc.addObserver(forName: NSNotification.Name(rawValue: AnimationCancelledEvent), object: self, queue: OperationQueue.current, using: { _ in
139138
action()
140139
})
141140
cancelObservers.append(observer)

C4/UI/AudioPlayer.swift

+2-6
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,12 @@ public class AudioPlayer: NSObject, AVAudioPlayerDelegate {
9898

9999
/// Returns the total duration, in seconds, of the sound associated with the audio player. (read-only)
100100
public var duration: Double {
101-
get {
102-
return Double(player.duration)
103-
}
101+
return Double(player.duration)
104102
}
105103

106104
/// Returns true if the receiver's current playback rate > 0. Otherwise returns false.
107105
public var playing: Bool {
108-
get {
109-
return player.isPlaying
110-
}
106+
return player.isPlaying
111107
}
112108

113109
/// The audio player’s stereo pan position.

C4/UI/Camera.swift

+5-7
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class Camera: View {
3737
var input: AVCaptureDeviceInput?
3838
var stillImageOutput: AVCaptureStillImageOutput?
3939
var captureSession: AVCaptureSession?
40-
var didCaptureAction: (()->())?
40+
var didCaptureAction: (() -> Void)?
4141
var orientationObserver: AnyObject?
4242

4343
class CameraView: UIView {
@@ -51,9 +51,7 @@ public class Camera: View {
5151
}
5252

5353
var previewLayer: PreviewLayer {
54-
get {
55-
return self.cameraView.previewLayer
56-
}
54+
return self.cameraView.previewLayer
5755
}
5856

5957
var cameraView: CameraView {
@@ -139,7 +137,7 @@ public class Camera: View {
139137
func initializeOutput(_ device: AVCaptureDevice) {
140138
if stillImageOutput == nil {
141139
stillImageOutput = AVCaptureStillImageOutput()
142-
stillImageOutput?.outputSettings = [AVVideoCodecKey : AVVideoCodecJPEG]
140+
stillImageOutput?.outputSettings = [AVVideoCodecKey: AVVideoCodecJPEG]
143141
}
144142
}
145143

@@ -182,7 +180,7 @@ public class Camera: View {
182180
updateOrientation()
183181
connection.videoOrientation = previewLayer.connection.videoOrientation
184182

185-
stillImageOutput?.captureStillImageAsynchronously(from: connection) { imageSampleBuffer, error in
183+
stillImageOutput?.captureStillImageAsynchronously(from: connection) { imageSampleBuffer, _ in
186184
guard imageSampleBuffer != nil else {
187185
print("Couldn't capture image from still image output")
188186
return
@@ -218,7 +216,7 @@ public class Camera: View {
218216
return image
219217
}
220218

221-
public func didCaptureImage(_ action: (()->())?) {
219+
public func didCaptureImage(_ action: (() -> Void)?) {
222220
didCaptureAction = action
223221
}
224222
}

C4/UI/Curve.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class Curve: Shape {
4646
}
4747
set {
4848
let diff = newValue - center
49-
batchUpdates() {
49+
batchUpdates {
5050
self.endPoints.0 += diff
5151
self.endPoints.1 += diff
5252
self.controlPoints.0 += diff
@@ -62,7 +62,7 @@ public class Curve: Shape {
6262
}
6363
set {
6464
let diff = newValue - origin
65-
batchUpdates() {
65+
batchUpdates {
6666
self.endPoints.0 += diff
6767
self.endPoints.1 += diff
6868
self.controlPoints.0 += diff

C4/UI/Font.swift

-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ public class Font {
113113
return Font(font: UIFont.italicSystemFont(ofSize: CGFloat(size)))
114114
}
115115

116-
117116
/// Returns a font object that is the same as the receiver but which has the specified size instead.
118117
/// ````
119118
/// let f = Font(name: "Avenir Next")

C4/UI/Image.swift

+11-24
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,10 @@ public class Image: View, NSCopying {
3333

3434
/// Shape's contents are drawn on a ShapeLayer.
3535
public var imageLayer: ImageLayer {
36-
get {
37-
return self.imageView.imageLayer
38-
}
36+
return self.imageView.imageLayer
3937
}
4038

41-
//MARK: Initializers
39+
// MARK: Initializers
4240

4341
/// Initializes an empty Image
4442
public override init() {
@@ -288,7 +286,7 @@ public class Image: View, NSCopying {
288286
return img
289287
}
290288

291-
//MARK: Properties
289+
// MARK: Properties
292290

293291
/// Returns the UIImageView of the object.
294292
/// - returns: A UIImageView object.
@@ -299,27 +297,21 @@ public class Image: View, NSCopying {
299297
/// Returns a UIImage representation of the receiver.
300298
/// - returns: A UIImage object.
301299
public var uiimage: UIImage {
302-
get {
303-
let layer = imageView.layer as CALayer
304-
let contents = layer.contents as! CGImage // swiftlint:disable:this force_cast
305-
return UIImage(cgImage: contents, scale: CGFloat(scale), orientation: imageView.image!.imageOrientation)
306-
}
300+
let layer = imageView.layer as CALayer
301+
let contents = layer.contents as! CGImage // swiftlint:disable:this force_cast
302+
return UIImage(cgImage: contents, scale: CGFloat(scale), orientation: imageView.image!.imageOrientation)
307303
}
308304

309305
/// Returns a CGImageRef representation of the receiver.
310306
/// - returns: A CGImageRef object.
311307
public var cgImage: CGImage {
312-
get {
313-
return uiimage.cgImage!
314-
}
308+
return uiimage.cgImage!
315309
}
316310

317311
/// Returns a CIImage representation of the receiver. Generally, this would be used to work with filters.
318312
/// - returns: A CIImage object.
319313
public var ciImage: CIImage {
320-
get {
321-
return CIImage(cgImage: cgImage)
322-
}
314+
return CIImage(cgImage: cgImage)
323315
}
324316

325317
/// An object that provides the contents of the layer. Animatable.
@@ -350,7 +342,6 @@ public class Image: View, NSCopying {
350342
}
351343
}
352344

353-
354345
/// The scale factor of the image. (read-only)
355346
var scale: Double {
356347
return Double(imageView.image!.scale)
@@ -402,19 +393,15 @@ public class Image: View, NSCopying {
402393
internal var _originalSize: Size = Size()
403394
/// The original size of the receiver when it was initialized.
404395
public var originalSize: Size {
405-
get {
406-
return _originalSize
407-
}
396+
return _originalSize
408397
}
409398

410399
/// The original width/height ratio of the receiver when it was initialized.
411400
public var originalRatio: Double {
412-
get {
413-
return _originalSize.width / _originalSize.height
414-
}
401+
return _originalSize.width / _originalSize.height
415402
}
416403

417-
//MARK: Filters
404+
// MARK: Filters
418405
lazy internal var output: CIImage = self.ciImage
419406
lazy internal var filterQueue: DispatchQueue = {
420407
return DispatchQueue.global(qos: .background)

C4/UI/ImageLayer.swift

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ public class ImageLayer: CALayer {
5555
return animation
5656
}
5757

58-
5958
private var _rotation = 0.0
6059

6160
/// The value of the receiver's current rotation state.

0 commit comments

Comments
 (0)