Skip to content

Commit 6f73df0

Browse files
authored
Add SwiftLint Plugin (#7)
* Add SwiftLint * Fix warning * Only use SwiftLint plugin on macOS * Specify LambdaExtras as the default docs
1 parent 059394a commit 6f73df0

File tree

5 files changed

+173
-24
lines changed

5 files changed

+173
-24
lines changed

.spi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
version: 1
22
builder:
33
configs:
4-
- documentation_targets: [LambdaExtrasCore, LambdaExtras, LambdaMocks]
4+
- documentation_targets: [LambdaExtras, LambdaExtrasCore, LambdaMocks]

.swiftlint.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
excluded:
2+
- .build
3+
4+
opt_in_rules:
5+
- empty_count
6+
- explicit_init
7+
- closure_spacing
8+
- overridden_super_call
9+
- redundant_nil_coalescing
10+
- private_outlet
11+
- nimble_operator
12+
- attributes
13+
- operator_usage_whitespace
14+
- closure_end_indentation
15+
- first_where
16+
- prohibited_super_call
17+
- fatal_error_message
18+
- vertical_parameter_alignment_on_call
19+
- let_var_whitespace
20+
- unneeded_parentheses_in_closure_argument
21+
- extension_access_modifier
22+
- pattern_matching_keywords
23+
- array_init
24+
- literal_expression_end_indentation
25+
26+
disabled_rules:
27+
- void_return
28+
- multiple_closures_with_trailing_closure
29+
- vertical_parameter_alignment_on_call
30+
31+
identifier_name:
32+
excluded:
33+
- id
34+
35+
type_name:
36+
excluded:
37+
- ID
38+
39+
function_body_length: 50
40+
41+
line_length: 200
42+
43+
file_length:
44+
warning: 500
45+
error: 1000
46+
47+
nesting:
48+
type_level:
49+
warning: 2
50+
function_level:
51+
warning: 10
52+
53+
large_tuple:
54+
warning: 6
55+
error: 10
56+
57+
cyclomatic_complexity:
58+
ignores_case_statements: true

Package.resolved

Lines changed: 81 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,6 @@ let package = Package(
2020
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", branch: "main")
2121
],
2222
targets: [
23-
.target(
24-
name: "LambdaExtrasCore",
25-
dependencies: [
26-
.product(name: "Logging", package: "swift-log"),
27-
.product(name: "NIOCore", package: "swift-nio")
28-
]
29-
),
30-
.target(
31-
name: "LambdaExtras",
32-
dependencies: [
33-
"LambdaExtrasCore",
34-
.product(name: "AWSLambdaRuntime",package: "swift-aws-lambda-runtime"),
35-
.product(name: "AWSLambdaEvents", package: "swift-aws-lambda-events")
36-
]
37-
),
38-
.target(
39-
name: "LambdaMocks",
40-
dependencies: [
41-
"LambdaExtrasCore"
42-
]
43-
),
4423
.testTarget(
4524
name: "LambdaExtrasTests",
4625
dependencies: [
@@ -49,3 +28,36 @@ let package = Package(
4928
)
5029
]
5130
)
31+
32+
let genericTargets: [Target] = [
33+
.target(
34+
name: "LambdaExtrasCore",
35+
dependencies: [
36+
.product(name: "Logging", package: "swift-log"),
37+
.product(name: "NIOCore", package: "swift-nio")
38+
]
39+
),
40+
.target(
41+
name: "LambdaExtras",
42+
dependencies: [
43+
"LambdaExtrasCore",
44+
.product(name: "AWSLambdaRuntime",package: "swift-aws-lambda-runtime"),
45+
.product(name: "AWSLambdaEvents", package: "swift-aws-lambda-events")
46+
]
47+
),
48+
.target(
49+
name: "LambdaMocks",
50+
dependencies: [
51+
"LambdaExtrasCore"
52+
]
53+
)
54+
]
55+
56+
#if os(macOS)
57+
package.dependencies.append(.package(url: "https://github.com/realm/SwiftLint.git", exact: "0.54.0"))
58+
for target in genericTargets {
59+
target.plugins = [.plugin(name: "SwiftLintPlugin", package: "SwiftLint")]
60+
}
61+
#endif
62+
63+
package.targets.append(contentsOf: genericTargets)

Sources/LambdaExtrasCore/Protocols/InitializationContext.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ public protocol InitializationContext: Sendable {
2323
/// `ByteBufferAllocator` to allocate `ByteBuffer`.
2424
var allocator: ByteBufferAllocator { get }
2525

26-
// TODO: Is there any point to allowing a name to be passed?
27-
2826
/// Register a closure to be performed on lambda shutdown.
2927
///
3028
/// - Parameter handler: A closure to execute when the lambda shuts down.

0 commit comments

Comments
 (0)