Skip to content

Commit bff35fd

Browse files
martinpucikKaspik
andauthored
Added Swiftlint and Swiftformat plugins (MessageKit#1729)
* build: Swiftlint plugin * build: Swiftformat plugin * build: Swiftformat plugin * build: Swiftformat bash command * style: Swiftformat rules * style: Swiftformat applied to codebase * style: Ignore Tests for Swiftlint * Update bundler * Update changelog and migration guide * style: Ignore Example for Swiftlint * chore: Changelog * Update Xcode version for ci_pr_tests.yml * Update ci_pr_framework.yml * Update ci_pr_example.yml * chore: Changelog Co-authored-by: Jakub Kaspar <kaspikk@gmail.com>
1 parent f3f61eb commit bff35fd

133 files changed

Lines changed: 13292 additions & 12363 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.

.github/workflows/ci_pr_example.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ on: pull_request
55
jobs:
66
tests:
77
name: Build Example app
8-
runs-on: macOS-latest
8+
runs-on: macos-12
9+
env:
10+
DEVELOPER_DIR: /Applications/Xcode_13.4.1.app/Contents/Developer
911
steps:
1012
- name: Checkout the Git repository
1113
uses: actions/checkout@v2

.github/workflows/ci_pr_framework.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ on: pull_request
55
jobs:
66
tests:
77
name: Build Framework
8-
runs-on: macOS-latest
9-
#env:
10-
#DEVELOPER_DIR: /Applications/Xcode_12.app/Contents/Developer
8+
runs-on: macos-12
9+
env:
10+
DEVELOPER_DIR: /Applications/Xcode_13.4.1.app/Contents/Developer
1111
steps:
1212
- name: Checkout the Git repository
1313
uses: actions/checkout@v2

.github/workflows/ci_pr_tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ on: pull_request
55
jobs:
66
tests:
77
name: Run Tests
8-
runs-on: macOS-latest
9-
#env:
10-
#DEVELOPER_DIR: /Applications/Xcode_12.app/Contents/Developer
8+
runs-on: macos-12
9+
env:
10+
DEVELOPER_DIR: /Applications/Xcode_13.4.1.app/Contents/Developer
1111
steps:
1212
- name: Checkout the Git repository
1313
uses: actions/checkout@v2

.swiftformat

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# options
2+
--swiftversion 5.6
3+
--self remove # redundantSelf
4+
--importgrouping testable-bottom # sortedImports
5+
--commas always # trailingCommas
6+
--trimwhitespace always # trailingSpace
7+
--indent 2 #indent
8+
--ifdef no-indent #indent
9+
--indentstrings true #indent
10+
--wraparguments before-first # wrapArguments
11+
--wrapparameters before-first # wrapArguments
12+
--wrapcollections before-first # wrapArguments
13+
--wrapconditions before-first # wrapArguments
14+
--wrapreturntype if-multiline #wrapArguments
15+
--closingparen same-line # wrapArguments
16+
--wraptypealiases before-first # wrapArguments
17+
--funcattributes prev-line # wrapAttributes
18+
--typeattributes prev-line # wrapAttributes
19+
--wrapternary before-operators # wrap
20+
--structthreshold 20 # organizeDeclarations
21+
--enumthreshold 20 # organizeDeclarations
22+
--organizetypes class,struct,enum,extension,actor # organizeDeclarations
23+
--extensionacl on-declarations # extensionAccessControl
24+
--patternlet inline # hoistPatternLet
25+
--redundanttype inferred # redundantType
26+
--emptybraces spaced # emptyBraces
27+
--operatorfunc spaced
28+
29+
# We recommend a max width of 100 but _strictly enforce_ a max width of 130
30+
--maxwidth 130 # wrap
31+
32+
# file options
33+
--exclude Package.swift
34+
35+
# rules
36+
--rules anyObjectProtocol
37+
--rules blankLinesBetweenScopes
38+
--rules consecutiveSpaces
39+
--rules consecutiveBlankLines
40+
--rules duplicateImports
41+
--rules extensionAccessControl
42+
--rules hoistPatternLet
43+
--rules indent
44+
--rules markTypes
45+
--rules organizeDeclarations
46+
--rules redundantParens
47+
--rules redundantReturn
48+
--rules redundantSelf
49+
--rules redundantType
50+
--rules redundantPattern
51+
--rules redundantGet
52+
--rules redundantFileprivate
53+
--rules redundantRawValues
54+
--rules sortedImports
55+
--rules sortDeclarations
56+
--rules strongifiedSelf
57+
--rules trailingCommas
58+
--rules trailingSpace
59+
--rules typeSugar
60+
--rules wrap
61+
--rules wrapMultilineStatementBraces
62+
--rules wrapArguments
63+
--rules wrapAttributes
64+
--rules braces
65+
--rules redundantClosure
66+
--rules redundantInit
67+
--rules redundantVoidReturnType
68+
--rules unusedArguments
69+
--rules spaceInsideBrackets
70+
--rules spaceInsideBraces
71+
--rules spaceAroundBraces
72+
--rules spaceInsideParens
73+
--rules spaceAroundParens
74+
--rules enumNamespaces
75+
--rules blockComments
76+
--rules spaceAroundComments
77+
--rules spaceInsideComments
78+
--rules spaceAroundOperators
79+
--rules blankLinesAtStartOfScope
80+
--rules blankLinesAtEndOfScope
81+
--rules emptyBraces
82+
--rules andOperator

.swiftlint.yml

Lines changed: 34 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,40 @@
1-
disabled_rules:
2-
- trailing_whitespace
3-
- file_length
4-
- line_length
5-
- type_body_length
6-
- identifier_name
7-
- function_parameter_count
8-
- switch_case_alignment
9-
- orphaned_doc_comment
10-
- inclusive_language
11-
- multiple_closures_with_trailing_closure
12-
13-
opt_in_rules:
14-
- force_unwrapping
15-
- implicitly_unwrapped_optional
16-
- empty_count
17-
- empty_string
18-
- extension_access_modifier
19-
- closure_spacing
1+
only_rules:
2+
- colon
203
- fatal_error_message
21-
- first_where
22-
- toggle_bool
23-
- unused_declaration
24-
- modifier_order
25-
- contains_over_first_not_nil
26-
- convenience_type
27-
- fallthrough
28-
- unused_import
29-
- unavailable_function
30-
- strict_fileprivate
31-
- explicit_init
32-
- anyobject_protocol
33-
- switch_case_on_newline
34-
- contains_over_range_nil_comparison
35-
- contains_over_filter_count
36-
- contains_over_filter_is_empty
37-
- empty_collection_literal
38-
- flatmap_over_map_reduce
39-
- no_space_in_method_call
4+
- implicitly_unwrapped_optional
5+
- legacy_cggeometry_functions
6+
- legacy_constant
7+
- legacy_constructor
8+
- legacy_nsgeometry_functions
9+
- operator_usage_whitespace
10+
- return_arrow_whitespace
11+
- trailing_newline
12+
- unused_optional_binding
13+
- vertical_whitespace
14+
- void_return
15+
- custom_rules
4016

4117
excluded:
42-
- Tests
43-
- Vendor
44-
- Scripts
45-
- fastlane
46-
- "DerivedData/**/*"
47-
- "**/.build"
4818
- "**/Package.swift"
49-
50-
function_body_length: 120
51-
type_name:
52-
min_length: 3
53-
max_length: 60
54-
identifier_name:
55-
min_length: 3
56-
max_length: 60
57-
cyclomatic_complexity: 30
58-
large_tuple:
59-
warning: 4
60-
error: 5
61-
implicitly_unwrapped_optional:
62-
mode: all_except_iboutlets
19+
- "**/.build"
20+
- "Tests"
21+
- "Example"
6322

6423
colon:
65-
flexible_right_spacing: false
66-
apply_to_dictionaries: true
24+
apply_to_dictionaries: false
25+
26+
indentation: 2
27+
28+
custom_rules:
29+
no_objcMembers:
30+
name: "@objcMembers"
31+
regex: "@objcMembers"
32+
message: "Explicitly use @objc on each member you want to expose to Objective-C"
33+
severity: error
34+
no_direct_standard_out_logs:
35+
name: "Writing log messages directly to standard out is disallowed"
36+
regex: "(\\bprint|\\bdebugPrint|\\bdump|Swift\\.print|Swift\\.debugPrint|Swift\\.dump)\\s*\\("
37+
match_kinds:
38+
- identifier
39+
message: "Don't commit `print(…)`, `debugPrint(…)`, or `dump(…)` as they write to standard out in release. Either log to a dedicated logging system or silence this warning in debug-only scenarios explicitly using `// swiftlint:disable:next no_direct_standard_out_logs`"
40+
severity: warning

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa
44

55
## Future release
66

7+
### Added
8+
9+
- Swiftformat and Swiftlint SwiftPM plugins used for linting and formatting the codebase [#1729](https://github.com/MessageKit/MessageKit/pull/1729) by [@martinpucik](https://github.com/martinpucik)
10+
711
## 4.0.0
812

913
Version 4.0.0 comes with couple of breaking changes, please refer to [MIGRATION_GUIDE.md](https://github.com/MessageKit/MessageKit/blob/main/Documentation/MIGRATION_GUIDE.md) for easy transition from V3 to V4.

Example/Sources/AppDelegate.swift

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
1-
/*
2-
MIT License
3-
4-
Copyright (c) 2017-2019 MessageKit
5-
6-
Permission is hereby granted, free of charge, to any person obtaining a copy
7-
of this software and associated documentation files (the "Software"), to deal
8-
in the Software without restriction, including without limitation the rights
9-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10-
copies of the Software, and to permit persons to whom the Software is
11-
furnished to do so, subject to the following conditions:
12-
13-
The above copyright notice and this permission notice shall be included in all
14-
copies or substantial portions of the Software.
15-
16-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22-
SOFTWARE.
23-
*/
1+
// MIT License
2+
//
3+
// Copyright (c) 2017-2019 MessageKit
4+
//
5+
// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
// of this software and associated documentation files (the "Software"), to deal
7+
// in the Software without restriction, including without limitation the rights
8+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
// copies of the Software, and to permit persons to whom the Software is
10+
// furnished to do so, subject to the following conditions:
11+
//
12+
// The above copyright notice and this permission notice shall be included in all
13+
// copies or substantial portions of the Software.
14+
//
15+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
// SOFTWARE.
2422

2523
import UIKit
2624

2725
@UIApplicationMain
2826
final internal class AppDelegate: UIResponder, UIApplicationDelegate {
27+
var window: UIWindow?
2928

30-
var window: UIWindow?
29+
func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
30+
let masterViewController = UINavigationController(rootViewController: LaunchViewController())
31+
let splitViewController = UISplitViewController()
32+
splitViewController.viewControllers = UIDevice.current.userInterfaceIdiom == .pad
33+
? [
34+
masterViewController,
35+
UIViewController()
36+
]
37+
: [masterViewController]
38+
splitViewController.preferredDisplayMode = .allVisible
3139

32-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
40+
window = UIWindow(frame: UIScreen.main.bounds)
41+
window?.rootViewController = splitViewController
42+
window?.makeKeyAndVisible()
3343

34-
let masterViewController = UINavigationController(rootViewController: LaunchViewController())
35-
let splitViewController = UISplitViewController()
36-
splitViewController.viewControllers = UIDevice.current.userInterfaceIdiom == .pad ? [masterViewController, UIViewController()] : [masterViewController]
37-
splitViewController.preferredDisplayMode = .allVisible
38-
39-
window = UIWindow(frame: UIScreen.main.bounds)
40-
window?.rootViewController = splitViewController
41-
window?.makeKeyAndVisible()
42-
43-
if UserDefaults.isFirstLaunch() {
44-
// Enable Text Messages
45-
UserDefaults.standard.set(true, forKey: "Text Messages")
46-
}
47-
48-
return true
44+
if UserDefaults.isFirstLaunch() {
45+
// Enable Text Messages
46+
UserDefaults.standard.set(true, forKey: "Text Messages")
4947
}
5048

49+
return true
50+
}
5151
}

0 commit comments

Comments
 (0)