Skip to content

Commit cfddb24

Browse files
authored
Use explicit set of rules in SwiftFormat and SwiftLint and bump versions (#3824)
1 parent 7bba56b commit cfddb24

34 files changed

+166
-147
lines changed

.swiftformat

Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,66 @@
22
--header "\nCopyright © {year} Stream.io Inc. All rights reserved.\n"
33
--swiftversion 5.6
44

5-
--ifdef no-indent
6-
--disable redundantType
7-
--disable extensionAccessControl
8-
--disable andOperator
9-
--disable hoistPatternLet
10-
--disable typeSugar
11-
12-
--disable redundantGet # it removes get async throws from getters
5+
# Use allow-list
6+
--rules blankLinesAroundMark
7+
--rules blankLinesAtEndOfScope
8+
--rules blankLinesAtStartOfScope
9+
--rules blankLinesBetweenScopes
10+
--rules braces
11+
--rules consecutiveBlankLines
12+
--rules consecutiveSpaces
13+
--rules duplicateImports
14+
--rules elseOnSameLine
15+
--rules emptyBraces
16+
--rules enumNamespaces
17+
--rules fileHeader
18+
--rules indent
19+
--rules initCoderUnavailable
20+
--rules isEmpty
21+
--rules leadingDelimiters
22+
--rules linebreakAtEndOfFile
23+
--rules linebreaks
24+
--rules modifierOrder
25+
--rules numberFormatting
26+
--rules redundantBackticks
27+
--rules redundantBreak
28+
--rules redundantExtensionACL
29+
--rules redundantFileprivate
30+
--rules redundantLet
31+
--rules redundantLetError
32+
--rules redundantNilInit
33+
--rules redundantObjc
34+
--rules redundantPattern
35+
--rules redundantRawValues
36+
--rules redundantVoidReturnType
37+
--rules semicolons
38+
--rules sortedImports
39+
--rules spaceAroundBraces
40+
--rules spaceAroundBrackets
41+
--rules spaceAroundComments
42+
--rules spaceAroundGenerics
43+
--rules spaceAroundOperators
44+
--rules spaceAroundParens
45+
--rules spaceInsideBraces
46+
--rules spaceInsideBrackets
47+
--rules spaceInsideComments
48+
--rules spaceInsideGenerics
49+
--rules spaceInsideParens
50+
--rules strongOutlets
51+
--rules strongifiedSelf
52+
--rules todos
53+
--rules trailingCommas
54+
--rules trailingSpace
55+
--rules unusedArguments
56+
--rules void
57+
--rules wrap
58+
--rules wrapArguments
59+
--rules wrapAttributes
60+
--rules yodaConditions
1361

14-
# Rules inferred from Swift Standard Library:
15-
--disable anyObjectProtocol, wrapMultilineStatementBraces
62+
# Configuration for enabled rules
63+
--ifdef no-indent
1664
--indent 4
17-
--enable isEmpty
18-
--disable redundantParens # it generates mistakes for e.g. "if (a || b), let x = ... {}"
1965
--semicolons inline
2066
--nospaceoperators ..., ..< # what about ==, +=?
2167
--commas inline

.swiftlint.yml

Lines changed: 42 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -18,72 +18,62 @@ excluded:
1818
- .ruby-lsp
1919
- derived_data
2020

21-
disabled_rules:
22-
- large_tuple
23-
- multiple_closures_with_trailing_closure
24-
- todo
25-
- function_parameter_count
26-
- type_name
27-
- nesting
28-
- identifier_name
29-
- file_length
30-
- type_body_length
31-
- opening_brace
32-
- line_length
33-
- switch_case_alignment
34-
- notification_center_detachment
35-
36-
# TODO: https://github.com/GetStream/ios-issues-tracking/issues/538
37-
- attributes # it should be included in `opt_in_rules`
38-
- orphaned_doc_comment
39-
- void_function_in_ternary
40-
- unneeded_synthesized_initializer
41-
- ns_number_init_as_function_reference
42-
- for_where
43-
44-
opt_in_rules:
45-
- convenience_type
46-
- empty_string
47-
- fatal_error_message
48-
- first_where
49-
- toggle_bool
50-
- identical_operands
21+
only_rules:
22+
- attribute_name_spacing
23+
- closing_brace
24+
- colon
25+
- comma
26+
- comment_spacing
27+
- control_statement
28+
- custom_rules
29+
- cyclomatic_complexity
30+
- duplicate_imports
31+
- empty_enum_arguments
32+
- empty_parameters
33+
- empty_parentheses_with_trailing_closure
34+
- file_name_no_space
5135
- joined_default_parameter
52-
- unavailable_function
53-
- explicit_init
36+
- leading_whitespace
37+
- legacy_cggeometry_functions
38+
- legacy_constant
39+
- legacy_constructor
40+
- legacy_nsgeometry_functions
41+
- mark
42+
- multiline_arguments
43+
- no_space_in_method_call
44+
- prefer_type_checking
45+
- private_over_fileprivate
46+
- private_unit_test
47+
- protocol_property_accessors_order
48+
- redundant_discardable_let
49+
- redundant_objc_attribute
5450
- redundant_optional_initialization
51+
- redundant_sendable
52+
- redundant_void_return
53+
- return_arrow_whitespace
5554
- syntactic_sugar
56-
- multiline_arguments
57-
- multiline_function_chains
58-
- file_name_no_space
59-
60-
analyzer_rules:
55+
- toggle_bool
56+
- trailing_comma
57+
- trailing_newline
58+
- trailing_semicolon
59+
- trailing_whitespace
60+
- unneeded_break_in_switch
61+
- unneeded_override
62+
- unused_closure_parameter
63+
- unused_control_flow_label
6164
- unused_import
65+
- vertical_whitespace
66+
- void_return
6267

6368
multiline_arguments:
6469
only_enforce_after_first_closure_on_first_line: true
6570

66-
# TODO: https://github.com/GetStream/ios-issues-tracking/issues/538
67-
# attributes:
68-
# always_on_same_line: ["@IBAction", "@NSManaged", "@objc"]
69-
# always_on_line_above: ["@discardableResult"]
70-
7171
trailing_whitespace:
7272
ignores_empty_lines: true
7373

74-
function_body_length:
75-
warning: 150
76-
error: 200
77-
7874
file_name_no_space:
7975
severity: error
8076

81-
identifier_name:
82-
excluded:
83-
[r, g, b, a, x, y, z, dx, dy, dz, i, j, k, id, op, or, me, at, to, in]
84-
allowed_symbols: ["_"]
85-
validates_start_with_lowercase: "warning"
86-
8777
cyclomatic_complexity:
8878
ignores_case_statements: true
8979
warning: 25

DemoApp/Screens/Livestream/DemoLivestreamChatChannelVC.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ class DemoLivestreamChatChannelVC: _ViewController,
1111
ChatMessageListVCDataSource,
1212
ChatMessageListVCDelegate,
1313
LivestreamChannelControllerDelegate,
14-
EventsControllerDelegate
15-
{
14+
EventsControllerDelegate {
1615
/// Controller for observing data changes within the channel.
1716
var livestreamChannelController: LivestreamChannelController!
1817

DemoApp/Screens/UserProfile/UserProfileViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class UserProfileViewController: UITableViewController, CurrentChatUserControlle
155155

156156
private func showDetailedUnreads() {
157157
let unreadDetailsView = UnreadDetailsView(
158-
onLoadData: { [weak self](completion: @escaping (Result<CurrentUserUnreads, Error>) -> Void) in
158+
onLoadData: { [weak self] (completion: @escaping (Result<CurrentUserUnreads, Error>) -> Void) in
159159
self?.currentUserController.loadAllUnreads { result in
160160
DispatchQueue.main.async {
161161
completion(result)

Githubfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ export MINT_VERSION='0.17.5'
88
export SONAR_VERSION='6.2.1.4610'
99
export IPSW_VERSION='3.1.592'
1010
export INTERFACE_ANALYZER_VERSION='1.0.7'
11-
export SWIFT_LINT_VERSION='0.52.4'
12-
export SWIFT_FORMAT_VERSION='0.47.12'
11+
export SWIFT_LINT_VERSION='0.59.1'
12+
export SWIFT_FORMAT_VERSION='0.58.2'
1313
export SWIFT_GEN_VERSION='6.5.1'

Integration/CocoaPods/CocoaPods/ViewController.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,4 @@
44

55
import UIKit
66

7-
class ViewController: UIViewController {
8-
override func viewDidLoad() {
9-
super.viewDidLoad()
10-
// Do any additional setup after loading the view.
11-
}
12-
}
7+
class ViewController: UIViewController {}

Integration/SPM/SwiftPackageManager/ViewController.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,4 @@
44

55
import UIKit
66

7-
class ViewController: UIViewController {
8-
override func viewDidLoad() {
9-
super.viewDidLoad()
10-
// Do any additional setup after loading the view.
11-
}
12-
}
7+
class ViewController: UIViewController {}

0 commit comments

Comments
 (0)