Skip to content

Commit 7685aed

Browse files
committed
Project cleanup
- Bump swift version to 5.2 - Remove cocoapods - Remove demo workspace - Code cleanup - Update swiftlint and swiftformat rules - Update README.md
1 parent 2281a24 commit 7685aed

16 files changed

Lines changed: 323 additions & 216 deletions

File tree

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.2
1+
5.2

.swiftformat

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
--exclude Demo/Pods
1+
--exclude Pods,Carthage,**/*.generated.swift
22
--disable consecutiveSpaces,indent,isEmpty,redundantParens,strongOutlets,trailingClosures
33

44
--allman false
@@ -8,6 +8,7 @@
88
--comments indent
99
--decimalgrouping ignore
1010
--elseposition same-line
11+
--empty void
1112
--header ignore
1213
--hexgrouping ignore
1314
--hexliteralcase lowercase
@@ -21,7 +22,11 @@
2122
--patternlet hoist
2223
--ranges no-space
2324
--semicolons never
25+
--self remove
26+
--selfrequired true
2427
--stripunusedargs closure-only
28+
--trailingclosures true
2529
--trimwhitespace nonblank-lines
2630
--wraparguments before-first
2731
--wrapcollections before-first
32+
--closingparen balanced

.swiftlint.yml

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ excluded:
1010
- Demo/Pods
1111

1212
disabled_rules:
13-
- block_based_kvo # Prefer the new block based KVO API with keypaths when using Swift 3.2 or later.
1413
- cyclomatic_complexity # Complexity of function bodies should be limited.
1514
- file_length # Files should not span too many lines.
1615
- for_where # where clauses are preferred over a single if inside a for.
@@ -21,39 +20,51 @@ disabled_rules:
2120
- todo # TODOs and FIXMEs should be resolved.
2221
- trailing_whitespace # Lines should not have trailing whitespace.
2322
- unused_setter_value # Setter value is not used.
23+
- multiple_closures_with_trailing_closure # Trailing closure syntax should not be used when passing more than one closure argument.
2424

2525
opt_in_rules:
26-
- anyobject_protocol # Prefer using AnyObject over class for class-only protocols.
27-
- array_init # Prefer using Array(seq) over seq.map { $0 } to convert a sequence into an Array.
26+
- anyobject_protocol # Prefer using `AnyObject` over class for class-only protocols.
27+
- array_init # Prefer using `Array(seq)` over `seq.map { $0 }` to convert a sequence into an Array.
2828
- closure_end_indentation # Closure end should have the same indentation as the line that started it.
2929
- closure_spacing # Closure expressions should have a single space inside each brace.
3030
- collection_alignment # All elements in a collection literal should be vertically aligned
31-
- conditional_returns_on_newline # Conditional statements should always return on the next line.
31+
- contains_over_filter_count # Prefer `contains` over comparing `filter(where:).count` to `0`.
32+
- contains_over_filter_is_empty # Prefer `contains` over using `filter(where:).isEmpty`
33+
- contains_over_first_not_nil # Prefer `contains` over `first(where:) != nil` and `firstIndex(where:) != nil`.
34+
- contains_over_range_nil_comparison # Prefer `contains` over `range(of:) != nil` and `range(of:) == nil`.
3235
- discouraged_object_literal # Prefer initializers over object literals.
33-
- empty_count # Prefer checking isEmpty over comparing count to zero.
34-
- empty_string # Prefer checking isEmpty over comparing string to an empty string literal.
35-
- empty_xctest_method # Empty XCTest method should be avoided.
36-
- explicit_init # Explicitly calling .init() should be avoided.
37-
- extension_access_modifier # Prefer to use extension access modifiers.
36+
- empty_collection_literal # Prefer checking `isEmpty` over comparing collection to an empty array or dictionary literal.
37+
- empty_count # Prefer checking `isEmpty` over comparing count to zero.
38+
- empty_string # Prefer checking `isEmpty` over comparing string to an empty string literal.
39+
- empty_xctest_method # Empty `XCTest` method should be avoided.
40+
- explicit_init # Explicitly calling `.init()` should be avoided.
3841
- fallthrough # Fallthrough should be avoided.
39-
- fatal_error_message # A fatalError call should have a message.
42+
- fatal_error_message # A `fatalError` call should have a message.
4043
- file_header # Header comments should be consistent with project patterns.
41-
- first_where # Prefer using .first(where:) over .filter { }.first in collections.
44+
- first_where # Prefer using `.first(where:)` over `.filter { }.first` in collections.
45+
- flatmap_over_map_reduce # Prefer `flatMap` over `map` followed by `reduce([], +)`.
4246
- function_default_parameter_at_end # Prefer to locate parameters with defaults toward the end of the parameter list.
47+
- legacy_multiple # Prefer using the `isMultiple(of:)` function instead of using the remainder operator (`%`).
4348
- joined_default_parameter # Discouraged explicit usage of the default. separator.
44-
- last_where # Prefer using .last(where:) over .filter { }.last in collections.
45-
- legacy_random # Prefer using type.random(in:) over legacy functions.
49+
- last_where # Prefer using `.last(where:)` over `.filter { }.last` in collections.
50+
- legacy_random # Prefer using `type.random(in:)` over legacy functions.
4651
- literal_expression_end_indentation # Array and dictionary literal end should have the same indentation as the line that started it.
4752
- lower_acl_than_parent # Ensure definitions have a lower access control level than their enclosing parent.
4853
- multiline_literal_brackets # Multiline literals should have their surrounding brackets in a new line.
4954
- prohibited_super_call # Some methods should not call super.
50-
- sorted_imports # Imports should be sorted.
51-
- toggle_bool # Prefer someBool.toggle() over someBool = !someBool.
55+
- redundant_type_annotation # Variables should not have redundant type annotation
56+
- toggle_bool # Prefer `someBool.toggle()` over `someBool = !someBool`.
5257
- unneeded_parentheses_in_closure_argument # Parentheses are not needed when declaring closure arguments.
5358
- unused_import # All imported modules should be required to make the file compile.
5459
- unused_private_declaration # Private declarations should be referenced in that file.
5560
- vertical_parameter_alignment_on_call # Function parameters should be aligned vertically if they're in multiple lines in a method call.
5661

62+
custom_rules:
63+
trailing_logical_operator:
64+
name: 'Trailing logical operator'
65+
message: 'Leading logical operator should move to trailing.'
66+
regex: '^[\s]*(\|\||&&)'
67+
5768
function_parameter_count:
5869
warning: 11
5970
error: 11
@@ -76,11 +87,6 @@ nesting:
7687
warning: 2
7788
error: 2
7889

79-
# Type bodies should not span too many lines.
80-
type_body_length:
81-
warning: 1100
82-
error: 1100
83-
8490
# Type name should only contain alphanumeric characters, start with an uppercase character and span between 3 and 50 characters in length.
8591
type_name:
8692
allowed_symbols: ['_']
@@ -91,3 +97,7 @@ type_name:
9197
# Limit vertical whitespace to a single empty line.
9298
vertical_whitespace:
9399
max_empty_lines: 2
100+
101+
# Forbid "Created by" line in file header
102+
file_header:
103+
forbidden_pattern: \b(Created by)\b

Demo/Podfile

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)