Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SwiftLint Plugin #7

Merged
merged 4 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .spi.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 1
builder:
configs:
- documentation_targets: [LambdaExtrasCore, LambdaExtras, LambdaMocks]
- documentation_targets: [LambdaExtras, LambdaExtrasCore, LambdaMocks]
58 changes: 58 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
excluded:
- .build

opt_in_rules:
- empty_count
- explicit_init
- closure_spacing
- overridden_super_call
- redundant_nil_coalescing
- private_outlet
- nimble_operator
- attributes
- operator_usage_whitespace
- closure_end_indentation
- first_where
- prohibited_super_call
- fatal_error_message
- vertical_parameter_alignment_on_call
- let_var_whitespace
- unneeded_parentheses_in_closure_argument
- extension_access_modifier
- pattern_matching_keywords
- array_init
- literal_expression_end_indentation

disabled_rules:
- void_return
- multiple_closures_with_trailing_closure
- vertical_parameter_alignment_on_call

identifier_name:
excluded:
- id

type_name:
excluded:
- ID

function_body_length: 50

line_length: 200

file_length:
warning: 500
error: 1000

nesting:
type_level:
warning: 2
function_level:
warning: 10

large_tuple:
warning: 6
error: 10

cyclomatic_complexity:
ignores_case_statements: true
81 changes: 81 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
{
"pins" : [
{
"identity" : "collectionconcurrencykit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/JohnSundell/CollectionConcurrencyKit.git",
"state" : {
"revision" : "b4f23e24b5a1bff301efc5e70871083ca029ff95",
"version" : "0.2.0"
}
},
{
"identity" : "cryptoswift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/krzyzanowskim/CryptoSwift.git",
"state" : {
"revision" : "db51c407d3be4a051484a141bf0bff36c43d3b1e",
"version" : "1.8.0"
}
},
{
"identity" : "sourcekitten",
"kind" : "remoteSourceControl",
"location" : "https://github.com/jpsim/SourceKitten.git",
"state" : {
"revision" : "b6dc09ee51dfb0c66e042d2328c017483a1a5d56",
"version" : "0.34.1"
}
},
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser.git",
"state" : {
"revision" : "8f4d2753f0e4778c76d5f05ad16c74f707390531",
"version" : "1.2.3"
}
},
{
"identity" : "swift-atomics",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -53,6 +89,51 @@
"revision" : "702cd7c56d5d44eeba73fdf83918339b26dc855c",
"version" : "2.62.0"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"state" : {
"revision" : "6ad4ea24b01559dde0773e3d091f1b9e36175036",
"version" : "509.0.2"
}
},
{
"identity" : "swiftlint",
"kind" : "remoteSourceControl",
"location" : "https://github.com/realm/SwiftLint.git",
"state" : {
"revision" : "f17a4f9dfb6a6afb0408426354e4180daaf49cee",
"version" : "0.54.0"
}
},
{
"identity" : "swiftytexttable",
"kind" : "remoteSourceControl",
"location" : "https://github.com/scottrhoyt/SwiftyTextTable.git",
"state" : {
"revision" : "c6df6cf533d120716bff38f8ff9885e1ce2a4ac3",
"version" : "0.9.0"
}
},
{
"identity" : "swxmlhash",
"kind" : "remoteSourceControl",
"location" : "https://github.com/drmohundro/SWXMLHash.git",
"state" : {
"revision" : "a853604c9e9a83ad9954c7e3d2a565273982471f",
"version" : "7.0.2"
}
},
{
"identity" : "yams",
"kind" : "remoteSourceControl",
"location" : "https://github.com/jpsim/Yams.git",
"state" : {
"revision" : "0d9ee7ea8c4ebd4a489ad7a73d5c6cad55d6fed3",
"version" : "5.0.6"
}
}
],
"version" : 2
Expand Down
54 changes: 33 additions & 21 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,6 @@ let package = Package(
.package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", branch: "main")
],
targets: [
.target(
name: "LambdaExtrasCore",
dependencies: [
.product(name: "Logging", package: "swift-log"),
.product(name: "NIOCore", package: "swift-nio")
]
),
.target(
name: "LambdaExtras",
dependencies: [
"LambdaExtrasCore",
.product(name: "AWSLambdaRuntime",package: "swift-aws-lambda-runtime"),
.product(name: "AWSLambdaEvents", package: "swift-aws-lambda-events")
]
),
.target(
name: "LambdaMocks",
dependencies: [
"LambdaExtrasCore"
]
),
.testTarget(
name: "LambdaExtrasTests",
dependencies: [
Expand All @@ -49,3 +28,36 @@ let package = Package(
)
]
)

let genericTargets: [Target] = [
.target(
name: "LambdaExtrasCore",
dependencies: [
.product(name: "Logging", package: "swift-log"),
.product(name: "NIOCore", package: "swift-nio")
]
),
.target(
name: "LambdaExtras",
dependencies: [
"LambdaExtrasCore",
.product(name: "AWSLambdaRuntime",package: "swift-aws-lambda-runtime"),
.product(name: "AWSLambdaEvents", package: "swift-aws-lambda-events")
]
),
.target(
name: "LambdaMocks",
dependencies: [
"LambdaExtrasCore"
]
)
]

#if os(macOS)
package.dependencies.append(.package(url: "https://github.com/realm/SwiftLint.git", exact: "0.54.0"))
for target in genericTargets {
target.plugins = [.plugin(name: "SwiftLintPlugin", package: "SwiftLint")]
}
#endif

package.targets.append(contentsOf: genericTargets)
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ public protocol InitializationContext: Sendable {
/// `ByteBufferAllocator` to allocate `ByteBuffer`.
var allocator: ByteBufferAllocator { get }

// TODO: Is there any point to allowing a name to be passed?

/// Register a closure to be performed on lambda shutdown.
///
/// - Parameter handler: A closure to execute when the lambda shuts down.
Expand Down