Skip to content
This repository was archived by the owner on Jun 17, 2023. It is now read-only.

Commit c235375

Browse files
committed
Add SwiftLint
1 parent 6c81c42 commit c235375

39 files changed

+269
-128
lines changed

.swiftlint.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
disabled_rules:
2+
- file_length
3+
- type_body_length
4+
- function_body_length
5+
- trailing_whitespace
6+
- empty_enum_arguments
7+
- function_parameter_count
8+
- identifier_name
9+
- type_name
10+
- nesting
11+
- large_tuple
12+
13+
opt_in_rules:
14+
- private_action
15+
- private_outlet
16+
- prefixed_toplevel_constant
17+
- overridden_super_call
18+
- file_header
19+
- weak_delegate
20+
- collection_alignment
21+
- empty_count
22+
- empty_string
23+
- fatal_error_message
24+
- function_default_parameter_at_end
25+
- last_where
26+
- legacy_random
27+
- multiline_function_chains
28+
- multiline_literal_brackets
29+
- multiline_parameters
30+
- override_in_extension
31+
- sorted_first_last
32+
- toggle_bool
33+
- unused_optional_binding
34+
- vertical_parameter_alignment_on_call
35+
- yoda_condition
36+
37+
excluded:
38+
- Package.swift
39+
- Pods
40+
41+
# adjusting rules
42+
43+
vertical_whitespace:
44+
max_empty_lines: 2
45+
46+
line_length:
47+
warning: 180
48+
error: 200
49+
50+
file_header:
51+
required_pattern: |
52+
\/\/
53+
\/\/ .*?\.swift
54+
\/\/ (CollectionViewPagingLayout.*?|Unit Tests)
55+
\/\/
56+
\/\/ (Created by .*? on .*?)
57+
\/\/ Copyright © \d{4} Amir Khorsandi. All rights reserved\.
58+
\/\/
59+
60+
type_name:
61+
min_length: 3
62+
max_length:
63+
warning: 50
64+
error: 65
65+
excluded: id # excluded via string
66+
reporter: "xcode"
67+
68+
cyclomatic_complexity:
69+
ignores_case_statements: true

.swiftlint_autocorrect.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
whitelist_rules:
2+
- let_var_whitespace
3+
- return_arrow_whitespace
4+
- opening_brace
5+
- colon
6+
- mark
7+
- trailing_newline
8+
- statement_position
9+
- trailing_semicolon
10+
- control_statement
11+
- comma
12+
- vertical_whitespace
13+
- closure_end_indentation
14+
- closure_spacing
15+
- empty_parameters
16+
- joined_default_parameter
17+
- operator_usage_whitespace
18+
- unneeded_parentheses_in_closure_argument
19+
- redundant_optional_initialization
20+
- implicit_return
21+
- literal_expression_end_indentation
22+
- nimble_operator
23+
- number_separator
24+
- unused_import
25+
26+
excluded:
27+
- Pods
28+
29+
# adjusting rules
30+
31+
vertical_whitespace:
32+
max_empty_lines: 2

CollectionViewPagingLayout.xcodeproj/project.pbxproj

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@
203203
298DBBF22441C94900341D8E /* Sources */,
204204
298DBBF32441C94900341D8E /* Frameworks */,
205205
298DBBF42441C94900341D8E /* Resources */,
206+
2967003224420B4100A1F508 /* Swiftlint */,
206207
);
207208
buildRules = (
208209
);
@@ -255,6 +256,27 @@
255256
};
256257
/* End PBXResourcesBuildPhase section */
257258

259+
/* Begin PBXShellScriptBuildPhase section */
260+
2967003224420B4100A1F508 /* Swiftlint */ = {
261+
isa = PBXShellScriptBuildPhase;
262+
buildActionMask = 2147483647;
263+
files = (
264+
);
265+
inputFileListPaths = (
266+
);
267+
inputPaths = (
268+
);
269+
name = Swiftlint;
270+
outputFileListPaths = (
271+
);
272+
outputPaths = (
273+
);
274+
runOnlyForDeploymentPostprocessing = 0;
275+
shellPath = /bin/sh;
276+
shellScript = "if which swiftlint >/dev/null; then\n swiftlint autocorrect --config \"${SRCROOT}/.swiftlint_autocorrect.yml\";\n swiftlint --config \"${SRCROOT}/.swiftlint.yml\";\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
277+
};
278+
/* End PBXShellScriptBuildPhase section */
279+
258280
/* Begin PBXSourcesBuildPhase section */
259281
298DBBF22441C94900341D8E /* Sources */ = {
260282
isa = PBXSourcesBuildPhase;

Lib/BlurEffectView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class BlurEffectView: UIVisualEffectView {
4747
/// - Parameters:
4848
/// - effect: optional blur effect, eg UIBlurEffect(style: .dark), default value is current effect
4949
/// - radius: blur intensity between 0.0 and 1.0
50-
public func setBlurRadius(effect: UIBlurEffect? = nil, radius: CGFloat) {
50+
public func setBlurRadius(effect: UIBlurEffect? = nil, radius: CGFloat = 1.0) {
5151
guard let effect = (effect ?? self.effect) as? UIBlurEffect else {
5252
return
5353
}

Lib/CollectionViewPagingLayout.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ public class CollectionViewPagingLayout: UICollectionViewLayout {
128128
var currentPage: Int = 0
129129
if let collectionView = collectionView {
130130
let pageSize = scrollDirection == .horizontal ? collectionView.frame.width : collectionView.frame.height
131-
let contentOffset = scrollDirection == .horizontal ? (collectionView.contentOffset.x + collectionView.contentInset.left) : (collectionView.contentOffset.y + collectionView.contentInset.top)
131+
let contentOffset = scrollDirection == .horizontal ?
132+
(collectionView.contentOffset.x + collectionView.contentInset.left) :
133+
(collectionView.contentOffset.y + collectionView.contentInset.top)
132134
currentPage = Int(round(contentOffset / pageSize))
133135
}
134136
if currentPage != self.currentPage {

Lib/Scale/ScaleTransformView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public extension ScaleTransformView {
135135
var angle = options.angle * progress
136136
angle = max(angle, options.minAngle)
137137
angle = min(angle, options.maxAngle)
138-
transform.m34 = options.m34;
138+
transform.m34 = options.m34
139139
transform = CATransform3DRotate(transform, angle, options.x, options.y, options.z)
140140
scalableView.layer.isDoubleSided = options.isDoubleSided
141141
}
@@ -151,7 +151,7 @@ public extension ScaleTransformView {
151151
z = max(z, options.minTranslates.2)
152152
z = min(z, options.maxTranslates.2)
153153

154-
transform = CATransform3DTranslate(transform, x, y, z)
154+
transform = CATransform3DTranslate(transform, x, y, z)
155155
}
156156
scalableView.layer.transform = transform
157157
}

Lib/Scale/ScaleTransformViewOptions.Rotation3dOptions.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// CollectionViewPagingLayout
44
//
55
// Created by Amir on 27/03/2020.
6+
// Copyright © 2020 Amir Khorsandi. All rights reserved.
67
//
78

89
import UIKit

Lib/Scale/ScaleTransformViewOptions.Translation3dOptions.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// CollectionViewPagingLayout
44
//
55
// Created by Amir on 27/03/2020.
6+
// Copyright © 2020 Amir Khorsandi. All rights reserved.
67
//
78

89
import UIKit

Lib/Snapshot/SnapshotTransformView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public extension SnapshotTransformView where Self: UICollectionViewCell {
3939
/// if you have the same content with different indexes (like infinite list)
4040
/// you should override this and provide a content-based identifier
4141
var identifier: String {
42-
var collectionView: UICollectionView? = nil
42+
var collectionView: UICollectionView?
4343
var superview = self.superview
4444
while superview != nil {
4545
if let view = superview as? UICollectionView {

Lib/Snapshot/SnapshotTransformViewOptions.PiecePosition.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// CollectionViewPagingLayout
44
//
55
// Created by Amir on 27/03/2020.
6+
// Copyright © 2020 Amir Khorsandi. All rights reserved.
67
//
78

89
import UIKit

0 commit comments

Comments
 (0)