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

Swift-format #748

Merged
merged 3 commits into from
Dec 16, 2024
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
5 changes: 1 addition & 4 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ on:

jobs:
validate:
runs-on: macOS-latest
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install Dependencies
run: |
brew install mint
- name: run script
run: ./scripts/validate.sh
63 changes: 63 additions & 0 deletions .swift-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"version" : 1,
"indentation" : {
"spaces" : 4
},
"tabWidth" : 4,
"fileScopedDeclarationPrivacy" : {
"accessLevel" : "private"
},
"spacesAroundRangeFormationOperators" : false,
"indentConditionalCompilationBlocks" : false,
"indentSwitchCaseLabels" : false,
"lineBreakAroundMultilineExpressionChainComponents" : false,
"lineBreakBeforeControlFlowKeywords" : false,
"lineBreakBeforeEachArgument" : true,
"lineBreakBeforeEachGenericRequirement" : true,
"lineLength" : 150,
"maximumBlankLines" : 1,
"respectsExistingLineBreaks" : true,
"prioritizeKeepingFunctionOutputTogether" : true,
"multiElementCollectionTrailingCommas" : true,
"rules" : {
"AllPublicDeclarationsHaveDocumentation" : false,
"AlwaysUseLiteralForEmptyCollectionInit" : false,
"AlwaysUseLowerCamelCase" : false,
"AmbiguousTrailingClosureOverload" : true,
"BeginDocumentationCommentWithOneLineSummary" : false,
"DoNotUseSemicolons" : true,
"DontRepeatTypeInStaticProperties" : true,
"FileScopedDeclarationPrivacy" : true,
"FullyIndirectEnum" : true,
"GroupNumericLiterals" : true,
"IdentifiersMustBeASCII" : true,
"NeverForceUnwrap" : false,
"NeverUseForceTry" : false,
"NeverUseImplicitlyUnwrappedOptionals" : false,
"NoAccessLevelOnExtensionDeclaration" : true,
"NoAssignmentInExpressions" : true,
"NoBlockComments" : true,
"NoCasesWithOnlyFallthrough" : true,
"NoEmptyTrailingClosureParentheses" : true,
"NoLabelsInCasePatterns" : true,
"NoLeadingUnderscores" : false,
"NoParensAroundConditions" : true,
"NoVoidReturnOnFunctionSignature" : true,
"OmitExplicitReturns" : true,
"OneCasePerLine" : true,
"OneVariableDeclarationPerLine" : true,
"OnlyOneTrailingClosureArgument" : true,
"OrderedImports" : true,
"ReplaceForEachWithForLoop" : true,
"ReturnVoidInsteadOfEmptyTuple" : true,
"UseEarlyExits" : false,
"UseExplicitNilCheckInConditions" : false,
"UseLetInEveryBoundCaseVariable" : false,
"UseShorthandTypeNames" : true,
"UseSingleLinePropertyGetter" : false,
"UseSynthesizedInitializer" : false,
"UseTripleSlashForDocumentationComments" : true,
"UseWhereClausesInForLoops" : false,
"ValidateDocumentationComments" : false
}
}
24 changes: 0 additions & 24 deletions .swiftformat

This file was deleted.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Other environment variables that affect testing include

### Formatting

We use Nick Lockwood's SwiftFormat for formatting code. PRs will not be accepted if they haven't be formatted. The current version of SwiftFormat we are using is v0.48.17.
We use Apple's SwiftFormat for formatting code. PRs will not be accepted if they haven't be formatted.

All new files need to include the following file header at the top
```swift
Expand Down
2,857 changes: 2,446 additions & 411 deletions Package.swift

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
//===----------------------------------------------------------------------===//

import AsyncHTTPClient
import SotoCore

import struct Foundation.Date
import typealias Foundation.TimeInterval
import SotoCore

extension CognitoIdentity {
struct IdentityCredentialProvider: CredentialProvider {
Expand Down Expand Up @@ -43,10 +44,10 @@ extension CognitoIdentity {
let credentialsRequest = CognitoIdentity.GetCredentialsForIdentityInput(identityId: identity.id, logins: identity.logins)
let response = try await self.cognitoIdentity.getCredentialsForIdentity(credentialsRequest, logger: logger)
guard let credentials = response.credentials,
let accessKeyId = credentials.accessKeyId,
let secretAccessKey = credentials.secretKey,
let sessionToken = credentials.sessionToken,
let expiration = credentials.expiration
let accessKeyId = credentials.accessKeyId,
let secretAccessKey = credentials.secretKey,
let sessionToken = credentials.sessionToken,
let expiration = credentials.expiration
else {
throw CredentialProviderError.noProvider
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ extension IdentityProviderFactory {

/// Create `StaticIdentityProvider` which attempts to use the same `logins` map on each call to `getIdentity`.
public static func `static`(logins: [String: String]?) -> Self {
return Self { context in
return CognitoIdentity.StaticIdentityProvider(logins: logins, context: context)
Self { context in
CognitoIdentity.StaticIdentityProvider(logins: logins, context: context)
}
}

Expand Down Expand Up @@ -171,9 +171,9 @@ extension IdentityProviderFactory {
public static func externalIdentityProvider(
tokenProvider: @escaping @Sendable (CognitoIdentity.ExternalIdentityProvider.Context) async throws -> [String: String]
) -> Self {
return Self { context in
return CognitoIdentity.ExternalIdentityProvider(context: context) { context in
return try await tokenProvider(context)
Self { context in
CognitoIdentity.ExternalIdentityProvider(context: context) { context in
try await tokenProvider(context)
}
}
}
Expand Down
48 changes: 38 additions & 10 deletions Sources/Soto/Extensions/DynamoDB/DynamoDB+Codable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ extension DynamoDB {
_ input: UpdateItemCodableInput<some Encodable>,
logger: Logger = AWSClient.loggingDisabled
) async throws -> UpdateItemOutput {
return try await self.updateItem(input.createUpdateItemInput(), logger: logger)
try await self.updateItem(input.createUpdateItemInput(), logger: logger)
}

/// The `Query` operation finds items based on primary key values. You can query any table or secondary index that has a composite primary key (a partition key and a sort key).
Expand Down Expand Up @@ -136,7 +136,7 @@ extension DynamoDB {
type: T.Type,
logger: Logger = AWSClient.loggingDisabled
) -> AWSClient.PaginatorSequence<QueryInput, QueryCodableOutput<T>> {
return .init(
.init(
input: input,
command: { input, logger in try await self.query(input, type: T.self, logger: logger) },
inputKey: \QueryInput.exclusiveStartKey,
Expand All @@ -159,7 +159,7 @@ extension DynamoDB {
type: T.Type,
logger: Logger = AWSClient.loggingDisabled
) -> AWSClient.PaginatorSequence<ScanInput, ScanCodableOutput<T>> {
return .init(
.init(
input: input,
command: { input, logger in try await self.scan(input, type: T.self, logger: logger) },
inputKey: \ScanInput.exclusiveStartKey,
Expand Down Expand Up @@ -188,7 +188,16 @@ extension DynamoDB {
/// The name of the table to contain the item.
public let tableName: String

public init(conditionExpression: String? = nil, expressionAttributeNames: [String: String]? = nil, expressionAttributeValues: [String: AttributeValue]? = nil, item: T, returnConsumedCapacity: ReturnConsumedCapacity? = nil, returnItemCollectionMetrics: ReturnItemCollectionMetrics? = nil, returnValues: ReturnValue? = nil, tableName: String) {
public init(
conditionExpression: String? = nil,
expressionAttributeNames: [String: String]? = nil,
expressionAttributeValues: [String: AttributeValue]? = nil,
item: T,
returnConsumedCapacity: ReturnConsumedCapacity? = nil,
returnItemCollectionMetrics: ReturnItemCollectionMetrics? = nil,
returnValues: ReturnValue? = nil,
tableName: String
) {
self.conditionExpression = conditionExpression
self.expressionAttributeNames = expressionAttributeNames
self.expressionAttributeValues = expressionAttributeValues
Expand Down Expand Up @@ -235,7 +244,17 @@ extension DynamoDB {
/// Object containing item key and attributes to update
public let updateItem: T

public init(conditionExpression: String? = nil, expressionAttributeNames: [String: String]? = nil, key: [String], returnConsumedCapacity: ReturnConsumedCapacity? = nil, returnItemCollectionMetrics: ReturnItemCollectionMetrics? = nil, returnValues: ReturnValue? = nil, tableName: String, updateExpression: String? = nil, updateItem: T) {
public init(
conditionExpression: String? = nil,
expressionAttributeNames: [String: String]? = nil,
key: [String],
returnConsumedCapacity: ReturnConsumedCapacity? = nil,
returnItemCollectionMetrics: ReturnItemCollectionMetrics? = nil,
returnValues: ReturnValue? = nil,
tableName: String,
updateExpression: String? = nil,
updateItem: T
) {
self.additionalAttributeNames = nil
self.additionalAttributeValues = nil
self.conditionExpression = conditionExpression
Expand All @@ -249,10 +268,19 @@ extension DynamoDB {
self.updateItem = updateItem
}

public init(additionalAttributes: some Encodable, conditionExpression: String? = nil, key: [String], returnConsumedCapacity: ReturnConsumedCapacity? = nil, returnItemCollectionMetrics: ReturnItemCollectionMetrics? = nil, returnValues: ReturnValue? = nil, tableName: String, updateItem: T) throws {
public init(
additionalAttributes: some Encodable,
conditionExpression: String? = nil,
key: [String],
returnConsumedCapacity: ReturnConsumedCapacity? = nil,
returnItemCollectionMetrics: ReturnItemCollectionMetrics? = nil,
returnValues: ReturnValue? = nil,
tableName: String,
updateItem: T
) throws {
let attributes = try DynamoDBEncoder().encode(additionalAttributes)
self.additionalAttributeNames = .init(key.map { ("#\($0)", $0) }) { first, _ in return first }
self.additionalAttributeValues = .init(attributes.map { (":\($0.key)", $0.value) }) { first, _ in return first }
self.additionalAttributeNames = .init(key.map { ("#\($0)", $0) }) { first, _ in first }
self.additionalAttributeValues = .init(attributes.map { (":\($0.key)", $0.value) }) { first, _ in first }
self.conditionExpression = conditionExpression
self.expressionAttributeNames = nil
self.key = key
Expand Down Expand Up @@ -282,15 +310,15 @@ extension DynamoDB {
let tmpAttributeNames: [String: String] = .init(item.keys.map { ("#\($0)", $0) }) { first, _ in return first }
expressionAttributeNames = tmpAttributeNames.merging(additionalAttributeNames, uniquingKeysWith: { _, new in new })
} else {
expressionAttributeNames = .init(item.keys.map { ("#\($0)", $0) }) { first, _ in return first }
expressionAttributeNames = .init(item.keys.map { ("#\($0)", $0) }) { first, _ in first }
}

let expressionAttributeValues: [String: AttributeValue]
if let additionalAttributeValues {
let tmpExpressionAttributeValues: [String: AttributeValue] = .init(item.map { (":\($0.key)", $0.value) }) { first, _ in return first }
expressionAttributeValues = tmpExpressionAttributeValues.merging(additionalAttributeValues, uniquingKeysWith: { _, new in new })
} else {
expressionAttributeValues = .init(item.map { (":\($0.key)", $0.value) }) { first, _ in return first }
expressionAttributeValues = .init(item.map { (":\($0.key)", $0.value) }) { first, _ in first }
}
// construct update expression, if one if not already supplied
let updateExpression: String
Expand Down
Loading
Loading