Skip to content

Commit f4c0a77

Browse files
authored
Merge pull request #168 from IntrepidPursuits/bobgilmore/swiftlint-update-may-2019
Update .swiftlint.yml to latest Intrepid version and clean up resulting issues
2 parents 760d598 + c8beb6d commit f4c0a77

18 files changed

+142
-29
lines changed

.swiftlint.yml

+106-11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Compiled with 0.30.1 rules
2+
13
# Don't add any files/directories to the 'include:' section. Everything not
24
# listed under 'excluded:' should be linted.
35
# included:
@@ -14,6 +16,7 @@ reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, junit)
1416

1517
# enabled_rules_for_documentation:
1618
# - attributes
19+
# - block_based_kvo
1720
# - class_delegate_protocol
1821
# - closing_brace
1922
# - closure_end_indentation
@@ -22,84 +25,168 @@ reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, junit)
2225
# - colon
2326
# - comma
2427
# - compiler_protocol_init
28+
# - contains_over_first_not_nil
2529
# - control_statement
2630
# - custom_rules
2731
# - discarded_notification_center_observer
32+
# - discouraged_direct_init
33+
# - duplicate_imports
2834
# - dynamic_inline
2935
# - empty_parameters
3036
# - empty_parentheses_with_trailing_closure
37+
# - fallthrough
38+
# - file_length
3139
# - first_where
3240
# - force_cast
3341
# - force_try
3442
# - force_unwrapping
3543
# - generic_type_name
36-
# - identifier
44+
# - is_disjoint
45+
# - identifier_name
46+
# - inert_defer
3747
# - implicit_getter
3848
# - implicitly_unwrapped_optional
3949
# - leading_whitespace
4050
# - legacy_cggeometry_functions
4151
# - legacy_constant
4252
# - legacy_constructor
53+
# - legacy_hashing
4354
# - legacy_nsgeometry_functions
4455
# - mark
45-
# - missing_docs
4656
# - nesting
4757
# - notification_center_detachment
58+
# - no_fallthrough_only
4859
# - object_literal
4960
# - opening_brace
5061
# - operator_usage_whitespace
5162
# - operator_whitespace
5263
# - private_outlet
5364
# - private_unit_test
65+
# - protocol_property_accessors_order
5466
# - redundant_discardable_let
5567
# - redundant_nil_coalescing
68+
# - redundant_objc_attribute
5669
# - redundant_optional_initialization
70+
# - redundant_set_access_control
5771
# - redundant_string_enum_value
5872
# - return_arrow_whitespace
5973
# - statement_position
74+
# - superfluous_disable_command
75+
# - switch_case_alignment
6076
# - syntactic_sugar
6177
# - trailing_comma
6278
# - trailing_newline
6379
# - trailing_semicolon
6480
# - trailing_whitespace
6581
# - type_body_length
6682
# - type_name
83+
# - unneeded_break_in_switch
6784
# - unused_closure_parameter
85+
# - unused_control_flow_label
6886
# - unused_enumerated
6987
# - unused_optional_binding
70-
# - valid_docs
88+
# - unused_setter_value
7189
# - valid_ibinspectable
7290
# - vertical_parameter_alignment
7391
# - vertical_whitespace
7492
# - weak_delegate
93+
# - xctfail_message
7594

7695
opt_in_rules:
96+
- anyobject_protocol
97+
- closure_body_length
98+
- collection_alignment
99+
- convenience_type
100+
- empty_xctest_method
77101
- explicit_init
78102
- fatal_error_message
103+
- function_default_parameter_at_end
104+
- identical_operands
105+
- joined_default_parameter
106+
- legacy_random
107+
- lower_acl_than_parent
108+
- multiline_arguments
109+
- multiline_function_chains
110+
- multiline_parameters
111+
- nslocalizedstring_key
79112
- overridden_super_call
80113
- prohibited_super_call
81114
- redundant_void_return
115+
- sorted_first_last
116+
- static_operator
117+
- strong_iboutlet
118+
- unavailable_function
119+
- unused_import
120+
- unused_private_declaration
121+
- vertical_parameter_alignment_on_call
122+
- xct_specific_matcher
82123

83124
disabled_rules:
125+
- array_init
84126
- conditional_returns_on_newline
85127
- cyclomatic_complexity
128+
- discouraged_object_literal
129+
- discouraged_optional_boolean
130+
- discouraged_optional_collection
86131
- empty_count
132+
- empty_enum_arguments
133+
- empty_string
134+
- explicit_acl
135+
- explicit_enum_raw_value
136+
- explicit_self
137+
- explicit_top_level_acl
87138
- explicit_type_interface
139+
- extension_access_modifier
88140
- file_header
141+
- file_name
89142
- for_where
143+
- implicit_return
144+
- let_var_whitespace
145+
- missing_docs
146+
- multiline_arguments_brackets
147+
- multiline_literal_brackets
148+
- multiline_parameters_brackets
90149
- nimble_operator
150+
- no_extension_access_modifier
151+
- no_grouping_extension
152+
- number_separator
153+
- override_in_extension
154+
- pattern_matching_keywords
155+
- prefixed_toplevel_constant
156+
- private_action
157+
- private_over_fileprivate
158+
- prohibited_interface_builder
159+
- quick_discouraged_call
160+
- quick_discouraged_focused_test
161+
- quick_discouraged_pending_test
162+
- redundant_type_annotation
163+
- required_enum_case
164+
- single_test_class
165+
- sorted_imports
91166
- shorthand_operator
167+
- strict_fileprivate
92168
- switch_case_on_newline
93169
- todo
170+
- toggle_bool
171+
- trailing_closure
172+
- unneeded_parentheses_in_closure_argument
173+
- untyped_error_in_catch
174+
- vertical_whitespace_between_cases
94175
- void_return
95-
- identifier_name
176+
- yoda_condition
96177

97-
# These next four rules are recommended to be enabled on a project-by-project
178+
# These next rules are recommended to be enabled on a project-by-project
98179
# basis with specific configurations that fit the project style.
99180
- function_body_length
100181
- function_parameter_count
101182
- large_tuple
183+
- last_where
102184
- line_length
185+
- literal_expression_end_indentation
186+
- modifier_order
187+
- multiple_closures_with_trailing_closure
188+
- vertical_whitespace_closing_braces
189+
- vertical_whitespace_opening_braces
103190

104191
## Rule Configuration
105192

@@ -110,12 +197,20 @@ file_length:
110197
warning: 750
111198
error: 1500
112199

113-
nesting:
114-
type_level: 3
115-
116200
identifier_name:
117-
allowed_symbols: _
201+
allowed_symbols: "_"
118202
min_length: 2
203+
excluded:
204+
- id
205+
- r
206+
- g
207+
- b
208+
- a
209+
- x
210+
- y
119211

120-
type_name:
121-
min_length: 2
212+
lower_acl_than_parent:
213+
severity: error
214+
215+
nesting:
216+
type_level: 3

Intrepid.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "Intrepid"
3-
s.version = "0.13.2"
3+
s.version = "0.13.3"
44
s.summary = "Swift Bag"
55
s.description = <<-DESC
66
Collection of extensions and utility classes by and for the developers at Intrepid Pursuits.

SwiftWisdom/AppDelegate.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1313

1414
var window: UIWindow?
1515

16-
public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
16+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
1717
// Override point for customization after application launch.
1818
return true
1919
}

SwiftWisdom/Core/Async/Qu/Qu.swift

+2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ public typealias CompletableBlock = (@escaping Block) -> ()
1616

1717
// MARK: Qu
1818

19+
//swiftlint:disable type_name
1920
public class Qu {
21+
//swiftlint:enable type_name
2022

2123
// MARK: Priority Enumeration
2224

SwiftWisdom/Core/CommonTypes/Multicast.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public struct Weak<T> where T: AnyObject {
2525
Only subclasses of NSObject can conform to this protocol. In addition, you can only typealias `MulticastDelegate` to a
2626
class or an `@objc` protocol.
2727
*/
28-
public protocol Multicast: class {
28+
public protocol Multicast: AnyObject {
2929

3030
associatedtype MulticastDelegate: AnyObject
3131

SwiftWisdom/Core/Controls/VideoPlayer.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ extension Video {
6969

7070
// MARK: Player
7171

72-
public protocol VideoPlayerDelegate: class {
72+
public protocol VideoPlayerDelegate: AnyObject {
7373
/**
7474
The delegate is notified when the video finishes playing and returns
7575
a boolean whether or not the video should repeat
@@ -109,6 +109,7 @@ public final class VideoPlayer: UIViewController {
109109
setupItemNotification(item)
110110
}
111111

112+
@available(*, unavailable)
112113
public required init?(coder aDecoder: NSCoder) {
113114
fatalError("init(coder:) has not been implemented")
114115
}

SwiftWisdom/Core/DirectoryManager/DirectoryManager.swift

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public final class DirectoryManager {
5959
return ((try? data.write(to: URL(fileURLWithPath: path), options: [.atomicWrite])) != nil)
6060
}
6161

62+
//swiftlint:disable function_default_parameter_at_end
6263
public func writeInBackground(_ data: Data, withName name: String = UUID().uuidString, completion: @escaping (String, Bool) -> Void = { _, _ in }) {
6364
Background {
6465
let success = self.write(data, withName: name)
@@ -67,6 +68,7 @@ public final class DirectoryManager {
6768
}
6869
}
6970
}
71+
//swiftlint:enable function_default_parameter_at_end
7072

7173
// MARK: Delete
7274

SwiftWisdom/Core/Foundation/Data/Data+Extensions.swift

+2
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ extension Data {
141141
}
142142

143143
extension Data {
144+
//swiftlint:disable function_default_parameter_at_end
144145
public func ip_segmentIterator(start: Int = 0, chunkLength: Int) -> AnyIterator<Data> {
145146
var iteratedData = ip_suffix(from: start)
146147
return AnyIterator {
@@ -157,4 +158,5 @@ extension Data {
157158
return nextData
158159
}
159160
}
161+
//swiftlint:enable function_default_parameter_at_end
160162
}

SwiftWisdom/Core/Foundation/Not.swift

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
let newNames = ["Joe", "Betty"].filter(!existingNames.contains)
1313
*/
14+
15+
//swiftlint:disable static_operator
1416
public prefix func ! <T>(original: @escaping (T) -> Bool) -> (T) -> Bool {
1517
return { !original($0) }
1618
}
19+
//swiftlint:enable static_operator

SwiftWisdom/Core/StandardLibrary/Array/Sequence+Utilities.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ extension Sequence where Iterator.Element: Equatable {
7979
///
8080
/// - returns: `true` if the sequence contains `all`
8181
public func ip_contains<T: Sequence>(all: T) -> Bool where T.Iterator.Element == Iterator.Element {
82-
for e in all where !contains(e) {
82+
for element in all where !contains(element) {
8383
return false
8484
}
8585
return true

SwiftWisdom/Core/StandardLibrary/Numbers/UnsignedInteger+Extensions.swift

+3-6
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,14 @@ import Foundation
1111
extension UnsignedInteger {
1212
public static func ip_random() -> Self {
1313
let intMax = Int(Int64(ip_maxValue))
14-
let rand = random(inRange: 0...intMax)
14+
let rand = Int.random(in: 0...intMax)
1515
return self.init(ip_safely: rand)
1616
}
1717
}
1818

19-
// TODO: evaluate whether we should move random to be a member of CountableClosedRange
19+
@available(*, deprecated, message: "Use Int.random(in:) instead", renamed: "Int.random(in:)")
2020
public func random(inRange range: CountableClosedRange<Int>) -> Int {
21-
let diff = range.upperBound - range.lowerBound
22-
let randomOffset = Int(arc4random_uniform(UInt32(diff + 1)))
23-
let random = range.lowerBound + randomOffset
24-
return random
21+
return Int.random(in: range)
2522
}
2623

2724
// TODO: write tests for this extension

SwiftWisdom/Core/StandardLibrary/String/String+Data.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ extension String {
1717

1818
var data = Data(capacity: trimmed.count / 2)
1919

20-
for i in stride(from: 0, through: trimmed.count - 2, by: 2) {
21-
let byteString = trimmed[i...i + 1]
20+
for step in stride(from: 0, through: trimmed.count - 2, by: 2) {
21+
let byteString = trimmed[step...step + 1]
2222
var byte = UInt8(byteString.ip_hexInt)
2323
data.append(&byte, count: MemoryLayout<UInt8>.size)
2424
}

SwiftWisdom/Core/StandardLibrary/String/String+Localization.swift

+2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import Foundation
22

33
extension String {
44
public func ip_localized(_ args: [CVarArg] = [], comment: String = "") -> String {
5+
//swiftlint:disable nslocalizedstring_key
56
let localizedFormat = NSLocalizedString(self, comment: comment)
7+
//swiftlint:enable nslocalizedstring_key
68
return String(format: localizedFormat, arguments: args)
79
}
810
}

SwiftWisdom/Core/UIKit/CoreAnimation/BasicVerticalGradientLayer.swift

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public final class BasicVerticalGradientLayer: CAGradientLayer {
1818
colors = [topColor.cgColor, bottomColor.cgColor]
1919
}
2020

21+
@available(*, unavailable)
2122
required public init(coder aDecoder: NSCoder) {
2223
fatalError("init(coder:) has not been implemented")
2324
}

SwiftWisdom/Core/UIKit/PercentAnimator/PercentAnimator.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ private final class PercentAnimator {
5252

5353
private static let shared = PercentAnimator()
5454

55-
static func animateWithDuration(
55+
fileprivate static func animateWithDuration(
5656
_ duration: TimeInterval,
5757
animation: @escaping (AnimationState) -> Void) {
5858
let id = UUID().uuidString

SwiftWisdom/Core/UIKit/UIButton+AttributedTitle.swift

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import UIKit
1010

1111
public extension UIButton {
1212

13+
//swiftlint:disable function_default_parameter_at_end
1314
/**
1415
This will use existing attributes on the attributed text, plus the spacing passed in and apply
1516
them to the string passed in.
@@ -30,4 +31,5 @@ public extension UIButton {
3031
}
3132
setAttributedTitle(spacedText, for: state)
3233
}
34+
//swiftlint:enable function_default_parameter_at_end
3335
}

0 commit comments

Comments
 (0)