Skip to content

Commit 5e9e245

Browse files
committed
🎨 Run SwiftLint.
1 parent c16e183 commit 5e9e245

21 files changed

+217
-39
lines changed

‎.swiftlint.yml‎

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# SwiftLint configuration file for the Storybook repository.
2+
# Run `swiftlint --fix` at the root of the repository to format all code.
3+
4+
# MARK: - Settings
5+
6+
#included:
7+
# - *.swift
8+
excluded:
9+
- "**/.build"
10+
11+
# If true, SwiftLint will not fail if no lintable files are found.
12+
allow_zero_lintable_files: false
13+
14+
# If true, SwiftLint will treat all warnings as errors.
15+
strict: true
16+
17+
# If true, SwiftLint will check for updates after linting or analyzing.
18+
check_for_updates: true
19+
20+
# reporter type (xcode, json, csv, checkstyle, codeclimate, junit, html, emoji, sonarqube, markdown, github-actions-logging, summary)
21+
reporter: "xcode"
22+
23+
# MARK: - Rules
24+
25+
disabled_rules:
26+
- class_delegate_protocol
27+
- cyclomatic_complexity
28+
- discouraged_direct_init
29+
- duplicate_enum_cases
30+
- function_parameter_count
31+
- inclusive_language
32+
- large_tuple
33+
- line_length
34+
- multiple_closures_with_trailing_closure
35+
- nesting
36+
- non_optional_string_data_conversion
37+
- notification_center_detachment
38+
- shorthand_operator
39+
- todo
40+
- type_body_length
41+
- type_name
42+
- void_function_in_ternary
43+
44+
opt_in_rules:
45+
- closure_end_indentation
46+
- closure_spacing
47+
- collection_alignment
48+
- comma_inheritance
49+
- contains_over_filter_count
50+
- contains_over_filter_is_empty
51+
- contains_over_first_not_nil
52+
- contains_over_range_nil_comparison
53+
- convenience_type
54+
- discarded_notification_center_observer
55+
- discouraged_none_name
56+
- discouraged_object_literal
57+
- discouraged_optional_boolean
58+
- discouraged_optional_collection
59+
- empty_collection_literal
60+
- empty_count
61+
- empty_string
62+
- explicit_init
63+
- fatal_error_message
64+
- file_name_no_space
65+
- first_where
66+
- identical_operands
67+
- implicit_return
68+
- indentation_width
69+
- joined_default_parameter
70+
- last_where
71+
- legacy_multiple
72+
- literal_expression_end_indentation
73+
- lower_acl_than_parent
74+
- modifier_order
75+
- multiline_arguments
76+
- multiline_arguments_brackets
77+
- multiline_literal_brackets
78+
- multiline_parameters
79+
- multiline_parameters_brackets
80+
- number_separator
81+
- operator_usage_whitespace
82+
- optional_enum_case_matching
83+
- overridden_super_call
84+
- override_in_extension
85+
- prefer_self_type_over_type_of_self
86+
- prefer_zero_over_explicit_init
87+
- private_swiftui_state
88+
- raw_value_for_camel_cased_codable_enum
89+
- redundant_nil_coalescing
90+
- return_value_from_void_function
91+
- shorthand_optional_binding
92+
- sorted_enum_cases
93+
- sorted_first_last
94+
- sorted_imports
95+
- toggle_bool
96+
- unhandled_throwing_task
97+
- unneeded_parentheses_in_closure_argument
98+
- unowned_variable_capture
99+
- vertical_parameter_alignment_on_call
100+
- vertical_whitespace_closing_braces
101+
- yoda_condition
102+
103+
analyzer_rules:
104+
- unused_declaration
105+
- unused_import
106+
107+
# MARK: - Config
108+
109+
file_length:
110+
warning: 750
111+
error: 1500
112+
ignore_comment_only_lines: true
113+
force_cast:
114+
severity: warning
115+
force_try:
116+
severity: warning
117+
function_body_length:
118+
warning: 100
119+
error: 200
120+
identifier_name:
121+
min_length: 0
122+
opening_brace:
123+
- ignore_multiline_statement_conditions
124+
trailing_comma:
125+
mandatory_comma: true
126+
unused_declaration:
127+
severity: warning

‎Package.resolved‎

Lines changed: 28 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Package.swift‎

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,40 @@ let package = Package(
3333
.library(name: "VaporRouteBuilder", targets: ["VaporRouteBuilder"])
3434
],
3535
dependencies: [
36-
.package(url: "https://github.com/vapor/vapor.git", from: "4.105.2")
36+
.package(url: "https://github.com/vapor/vapor.git", from: "4.105.2"),
37+
// TODO: <Connor> This can probably be removed once Swift 6 is officially released.
38+
.package(url: "https://github.com/apple/swift-testing", from: "0.12.0"),
3739
],
3840
targets: [
3941
.target(name: "VaporRouteBuilder", dependencies: [.product(name: "Vapor", package: "vapor")]),
4042
.testTarget(
4143
name: "VaporRouteBuilderTests",
4244
dependencies: [
4345
"VaporRouteBuilder",
44-
.product(name: "XCTVapor", package: "vapor")
46+
.product(name: "XCTVapor", package: "vapor"),
4547
]
46-
)
48+
),
4749
]
4850
)
51+
52+
#if os(macOS) // Only add SwiftLint on supported platforms.
53+
package.dependencies.append(contentsOf: [
54+
.package(url: "https://github.com/SimplyDanny/SwiftLintPlugins", from: "0.56.2"),
55+
])
56+
#endif
57+
58+
for target in package.targets where target.type != .system {
59+
#if os(macOS) // Only add SwiftLint on supported platforms.
60+
target.plugins = target.plugins ?? []
61+
target.plugins?.append(contentsOf: [
62+
.plugin(name: "SwiftLintBuildToolPlugin", package: "SwiftLintPlugins")
63+
])
64+
#endif
65+
66+
if case .test = target.type {
67+
target.dependencies.append(contentsOf: [
68+
// TODO: <Connor> This can probably be removed once Swift 6 is officially released.
69+
.product(name: "Testing", package: "swift-testing"),
70+
])
71+
}
72+
}

‎Sources/VaporRouteBuilder/Route+Convenience.swift‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ extension Route {
6161
_ = try await request.eventLoop.flatSubmit {
6262
request.body.collect(max: max?.value ?? request.application.routes.defaultMaxBodySize.value)
6363
}.get()
64-
6564
}
6665
return try await closure(request).encodeResponse(for: request)
6766
}

‎Sources/VaporRouteBuilder/RouteBuilder.swift‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ public enum RouteBuilder {
5252
public static func buildEither<TrueContent: RouteComponent, FalseContent: RouteComponent>(
5353
first content: TrueContent
5454
) -> Conditional<TrueContent, FalseContent> {
55-
return Conditional.first(content)
55+
Conditional.first(content)
5656
}
5757

5858
@inlinable
5959
static func buildEither<TrueContent: RouteComponent, FalseContent: RouteComponent>(
6060
second content: FalseContent
6161
) -> Conditional<TrueContent, FalseContent> {
62-
return Conditional.second(content)
62+
Conditional.second(content)
6363
}
6464

6565
// MARK: buildOptional

‎Sources/VaporRouteBuilder/RouteComponents/Groups/Group.swift‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ public struct Group<Content: RouteComponent>: RouteComponent {
205205
public func boot(routes: any RoutesBuilder) throws {
206206
try content.boot(routes: routes)
207207
}
208-
209208
}
210209

211210
// MARK: - RouteComponents + Group

‎Tests/VaporRouteBuilderTests/Helpers/XCTApplicationTest+Testing.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
// SOFTWARE.
2222

23-
import XCTVapor
2423
import Testing
24+
import XCTVapor
2525

2626
// MARK: - XCTApplicationTester + Testing
2727

‎Tests/VaporRouteBuilderTests/RouteComponentBuilderTests.swift‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323
import Testing
2424
import Vapor
25-
import XCTVapor
2625
@testable import VaporRouteBuilder
26+
import XCTVapor
2727

2828
@Suite("RouteBuilder Tests") struct RouteComponentBuilderTests {
2929
@Test func test_resultBuilder_whenBuildBlockIsSingle_producesExpectedRoutes() async throws {
@@ -123,7 +123,7 @@ import XCTVapor
123123
Route.testing(name: "false")
124124
}
125125
}) { app in
126-
#expect(app.routes.all.count == 0)
126+
#expect(app.routes.all.isEmpty)
127127
}
128128
}
129129

@@ -151,6 +151,7 @@ import XCTVapor
151151
}
152152
}
153153

154+
// swiftlint:disable duplicate_conditions
154155
@Test func test_resultBuilder_whenBuildBlockIsEitherIfElseIf_producesExpectedRoutes() async throws {
155156
// Only 'if' path should exist.
156157
try await Application.testing(content: {
@@ -202,7 +203,7 @@ import XCTVapor
202203
Route.testing(name: "elseIf")
203204
}
204205
}) { app in
205-
#expect(app.routes.all.count == 0)
206+
#expect(app.routes.all.isEmpty)
206207
}
207208

208209
// Only 'else' path should exist.
@@ -219,6 +220,7 @@ import XCTVapor
219220
#expect(app.routes.all.count == 1)
220221
}
221222
}
223+
// swiftlint:enable duplicate_conditions
222224

223225
@Test func test_resultBuilder_whenBuildBlockIsOptionalIf_producesExpectedRoutes() async throws {
224226
// Only 'if' path should exist.
@@ -237,7 +239,7 @@ import XCTVapor
237239
Route.testing(name: "true")
238240
}
239241
}) { app in
240-
#expect(app.routes.all.count == 0)
242+
#expect(app.routes.all.isEmpty)
241243
}
242244

243245
// Only 'if' path should exist.
@@ -258,7 +260,7 @@ import XCTVapor
258260
Route.testing(name: "\(optionalDoesNotExist)")
259261
}
260262
}) { app in
261-
#expect(app.routes.all.count == 0)
263+
#expect(app.routes.all.isEmpty)
262264
}
263265

264266
// Only 'if' path should exist.
@@ -280,7 +282,7 @@ import XCTVapor
280282
Route.testing(name: "one")
281283
}
282284
}) { app in
283-
#expect(app.routes.all.count == 0)
285+
#expect(app.routes.all.isEmpty)
284286
}
285287
}
286288

‎Tests/VaporRouteBuilderTests/RouteComponents/AnyRouteComponentTests.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323
import Testing
2424
import Vapor
25-
import XCTVapor
2625
@testable import VaporRouteBuilder
26+
import XCTVapor
2727

2828
@Suite("AnyRouteComponent Tests") struct AnyRouteComponentTests {
2929
@Test func test_anyRouteComponent_withSimpleComponent_producesExpectedRoutes() async throws {

‎Tests/VaporRouteBuilderTests/RouteComponents/ArrayTests.swift‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323
import Testing
2424
import Vapor
25-
import XCTVapor
2625
@testable import VaporRouteBuilder
26+
import XCTVapor
2727

2828
@Suite("Array Tests") struct ArrayTests {
2929
@Test func test_array_withOneComponent_producesExpectedRoutes() async throws {
@@ -40,7 +40,7 @@ import XCTVapor
4040
[
4141
Route.testing(name: "A"),
4242
Route.testing(name: "B"),
43-
Route.testing(name: "C")
43+
Route.testing(name: "C"),
4444
]
4545
}) { app in
4646
try await app.testing(.GET, "/A")

0 commit comments

Comments
 (0)