Skip to content

Commit 3a32809

Browse files
authored
Merge pull request #13 from TheNounProject/SwiftLint
SwiftLint
2 parents 027ffed + 41b978f commit 3a32809

67 files changed

Lines changed: 1473 additions & 2271 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.swiftlint.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
disabled_rules:
2+
- trailing_whitespace
3+
- identifier_name
4+
- statement_position
5+
- large_tuple
6+
- force_cast
7+
- force_try
8+
- type_name
9+
- function_parameter_count
10+
- cyclomatic_complexity
11+
- operator_whitespace
12+
- private_over_fileprivate
13+
- nesting
14+
- type_body_length
15+
- multiple_closures_with_trailing_closure
16+
- notification_center_detachment
17+
opt_in_rules:
18+
- empty_count
19+
- empty_string
20+
excluded:
21+
- Carthage
22+
- Pods
23+
- Example
24+
- SwiftLint/Common/3rdPartyLib
25+
line_length:
26+
warning: 150
27+
error: 200
28+
ignores_function_declarations: true
29+
ignores_comments: true
30+
ignores_urls: true
31+
ignores_interpolated_strings: true
32+
function_body_length:
33+
warning: 300
34+
error: 500
35+
function_parameter_count:
36+
warning: 6
37+
error: 8
38+
type_body_length:
39+
warning: 300
40+
error: 500
41+
file_length:
42+
warning: 1000
43+
error: 1500
44+
ignore_comment_only_lines: true
45+
cyclomatic_complexity:
46+
warning: 20
47+
error: 25
48+
reporter: "xcode"

CollectionView.xcodeproj/project.pbxproj

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@
294294
DE9071E51CAC7FD800AD0E37 /* Frameworks */,
295295
DE9071E61CAC7FD800AD0E37 /* Headers */,
296296
DE9071E71CAC7FD800AD0E37 /* Resources */,
297+
1CB6A657211D6BAC00907CEF /* SwiftLint */,
297298
);
298299
buildRules = (
299300
);
@@ -377,6 +378,27 @@
377378
};
378379
/* End PBXResourcesBuildPhase section */
379380

381+
/* Begin PBXShellScriptBuildPhase section */
382+
1CB6A657211D6BAC00907CEF /* SwiftLint */ = {
383+
isa = PBXShellScriptBuildPhase;
384+
buildActionMask = 2147483647;
385+
files = (
386+
);
387+
inputFileListPaths = (
388+
);
389+
inputPaths = (
390+
);
391+
name = SwiftLint;
392+
outputFileListPaths = (
393+
);
394+
outputPaths = (
395+
);
396+
runOnlyForDeploymentPostprocessing = 0;
397+
shellPath = /bin/sh;
398+
shellScript = "if which swiftlint >/dev/null; then\nswiftlint\nelse\necho \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
399+
};
400+
/* End PBXShellScriptBuildPhase section */
401+
380402
/* Begin PBXSourcesBuildPhase section */
381403
DE9071E41CAC7FD800AD0E37 /* Sources */ = {
382404
isa = PBXSourcesBuildPhase;

CollectionView/ClipView.swift

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,17 @@
99
//import Foundation
1010
import AppKit
1111

12-
1312
//typealias DisplayLinkCallback = @convention(block) ( CVDisplayLink!, UnsafePointer<CVTimeStamp>, UnsafePointer<CVTimeStamp>, CVOptionFlags, UnsafeMutablePointer<CVOptionFlags>, UnsafeMutablePointer<Void>)->Void
1413

15-
open class ClipView : NSClipView {
14+
open class ClipView: NSClipView {
1615

17-
static let DefaultDecelerationRate : CGFloat = 0.78
16+
static let DefaultDecelerationRate: CGFloat = 0.78
1817

1918
var shouldAnimateOriginChange = false
2019
var destinationOrigin = CGPoint.zero
21-
var scrollView : NSScrollView? { return self.enclosingScrollView ?? self.superview as? NSScrollView }
22-
23-
var scrollEnabled : Bool = true
24-
20+
var scrollView: NSScrollView? { return self.enclosingScrollView ?? self.superview as? NSScrollView }
2521

22+
var scrollEnabled: Bool = true
2623

2724
/**
2825
The rate of deceleration for animated scrolls. Higher is slower. default is 0.78
@@ -34,7 +31,7 @@ open class ClipView : NSClipView {
3431
}
3532
}
3633

37-
var completionBlock : AnimationCompletion?
34+
var completionBlock: AnimationCompletion?
3835

3936
init(clipView: NSClipView) {
4037
super.init(frame: clipView.frame)
@@ -47,7 +44,6 @@ open class ClipView : NSClipView {
4744
NotificationCenter.default.removeObserver(self)
4845
}
4946

50-
5147
override init(frame frameRect: NSRect) {
5248
super.init(frame: frameRect)
5349
self.setup()
@@ -64,12 +60,15 @@ open class ClipView : NSClipView {
6460
}
6561

6662
override open func viewWillMove(toWindow newWindow: NSWindow?) {
67-
if (self.window != nil) {
68-
NotificationCenter.default.removeObserver(self, name: NSWindow.didChangeScreenNotification, object: self.window)
63+
if self.window != nil {
64+
NotificationCenter.default.removeObserver(self, name: NSWindow.didChangeScreenNotification,
65+
object: self.window)
6966
}
7067
super.viewWillMove(toWindow: newWindow)
71-
if (newWindow != nil) {
72-
NotificationCenter.default.addObserver(self, selector: #selector(ClipView.updateCVDisplay(_:)), name: NSWindow.didChangeScreenNotification, object: newWindow)
68+
if newWindow != nil {
69+
NotificationCenter.default.addObserver(self, selector: #selector(ClipView.updateCVDisplay(_:)),
70+
name: NSWindow.didChangeScreenNotification,
71+
object: newWindow)
7372
}
7473
}
7574

@@ -79,23 +78,22 @@ open class ClipView : NSClipView {
7978
// return rect
8079
// }
8180

82-
var _displayLink : CVDisplayLink?
81+
var _displayLink: CVDisplayLink?
8382

84-
var displayLink : CVDisplayLink {
83+
var displayLink: CVDisplayLink {
8584
if let link = _displayLink { return link }
8685

87-
let linkCallback : CVDisplayLinkOutputCallback = {( displayLink, _, _, _, _, displayLinkContext) -> CVReturn in
86+
let linkCallback: CVDisplayLinkOutputCallback = {( displayLink, _, _, _, _, displayLinkContext) -> CVReturn in
8887
unsafeBitCast(displayLinkContext, to: ClipView.self).updateOrigin()
8988
return kCVReturnSuccess
9089
}
91-
var link : CVDisplayLink?
90+
var link: CVDisplayLink?
9291
CVDisplayLinkCreateWithActiveCGDisplays(&link)
9392
CVDisplayLinkSetOutputCallback(link!, linkCallback, UnsafeMutableRawPointer(Unmanaged.passUnretained(self).toOpaque()))
9493
self._displayLink = link
9594
return link!
9695
}
9796

98-
9997
open override func mouseDown(with event: NSEvent) {
10098
self.cancelScrollAnimation()
10199
super.mouseDown(with: event)
@@ -140,10 +138,9 @@ open class ClipView : NSClipView {
140138
return success
141139
}
142140

143-
144141
func finishedScrolling(_ success: Bool) {
145142
self.completionBlock?(success)
146-
self.completionBlock = nil;
143+
self.completionBlock = nil
147144
}
148145

149146
open override func scroll(to newOrigin: NSPoint) {
@@ -181,7 +178,7 @@ open class ClipView : NSClipView {
181178
if self.window == nil {
182179
cancel = true
183180
}
184-
o = self.bounds.origin;
181+
o = self.bounds.origin
185182
integral = self.window?.backingScaleFactor == 1
186183
}
187184

@@ -190,12 +187,12 @@ open class ClipView : NSClipView {
190187
return
191188
}
192189

193-
let lastOrigin = o;
194-
let deceleration = self.decelerationRate;
190+
let lastOrigin = o
191+
let deceleration = self.decelerationRate
195192

196193
// Calculate the next origin on a basic ease-out curve.
197-
o.x = o.x * deceleration + self.destinationOrigin.x * (1 - self.decelerationRate);
198-
o.y = o.y * deceleration + self.destinationOrigin.y * (1 - self.decelerationRate);
194+
o.x = o.x * deceleration + self.destinationOrigin.x * (1 - self.decelerationRate)
195+
o.y = o.y * deceleration + self.destinationOrigin.y * (1 - self.decelerationRate)
199196

200197
if integral {
201198
o = o.integral
@@ -213,7 +210,7 @@ open class ClipView : NSClipView {
213210

214211
//.postNotificationName(NSScrollViewDidLiveScrollNotification, object: self, userInfo: nil)
215212

216-
if ((fabs(o.x - lastOrigin.x) < 0.1 && fabs(o.y - lastOrigin.y) < 0.1)) {
213+
if fabs(o.x - lastOrigin.x) < 0.1 && fabs(o.y - lastOrigin.y) < 0.1 {
217214
self.endScrolling()
218215

219216
// Make sure we always finish out the animation with the actual coordinates
@@ -244,10 +241,4 @@ open class ClipView : NSClipView {
244241
CVDisplayLinkStop(self.displayLink)
245242
}
246243

247-
248-
249-
250-
251-
252-
253244
}

CollectionView/CollapsableCollectionViewProvider.swift

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@
88

99
import Foundation
1010

11-
12-
public class CollapsableCollectionViewProvider : CollectionViewResultsProxy {
11+
public class CollapsableCollectionViewProvider: CollectionViewResultsProxy {
1312

1413
/// When set as the delegate
15-
public unowned let collectionView : CollectionView
16-
public unowned let resultsController : ResultsController
14+
public unowned let collectionView: CollectionView
15+
public unowned let resultsController: ResultsController
1716
public weak var delegate: CollectionViewProviderDelegate?
1817

1918
/// The last known section count of real data
@@ -48,14 +47,11 @@ public class CollapsableCollectionViewProvider : CollectionViewResultsProxy {
4847

4948
*/
5049
public var populateWhenEmpty = false
51-
52-
53-
5450
}
5551

5652
// MARK: - Results Controller Delegate
5753
/*-------------------------------------------------------------------------------*/
58-
extension CollapsableCollectionViewProvider : ResultsControllerDelegate {
54+
extension CollapsableCollectionViewProvider: ResultsControllerDelegate {
5955

6056
public func controllerDidLoadContent(controller: ResultsController) {
6157
self.sectionCount = controller.numberOfSections
@@ -99,5 +95,3 @@ extension CollapsableCollectionViewProvider : ResultsControllerDelegate {
9995
self.collectionView.applyChanges(from: self, completion: completion)
10096
}
10197
}
102-
103-

0 commit comments

Comments
 (0)