-
Notifications
You must be signed in to change notification settings - Fork 113
Update swiftformat #196
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
Update swiftformat #196
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,8 +146,8 @@ public enum AppSync { | |
} | ||
} | ||
|
||
public extension AppSync { | ||
enum Response<ResultType: Encodable>: Encodable { | ||
extension AppSync { | ||
public enum Response<ResultType: Encodable>: Encodable { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these are good actually 👍 |
||
public func encode(to encoder: Encoder) throws { | ||
var container = encoder.singleValueContainer() | ||
switch self { | ||
|
@@ -165,5 +165,5 @@ public extension AppSync { | |
case dictionary([String: ResultType]) | ||
} | ||
|
||
typealias JSONStringResponse = Response<String> | ||
public typealias JSONStringResponse = Response<String> | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
import struct Foundation.Date | ||
|
||
// https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html | ||
public struct DynamoDB { | ||
public enum DynamoDB { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that is honestly crazy... a formatter changing types just because it feels like it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea this is nasty imo - is there an option to turn this off? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually I think this pretty clever... It detect's that this is used as a namespace and makes it explicit:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's NOT up to a formatting tool to decide how I'm designing and using types. I.e. it's a struct because it will gain fields in the future etc. We really should not allow this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, its clever, but it should a human decision to change a type not a formatting tool There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I disabled the matching There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changing an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @weissi we go the other way though. struct -> enum. just out of curiosity: in which way would enum -> struct be source breaking, if it is just about a namespace? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
will break. No tool should ever switch |
||
public struct Event: Decodable { | ||
public let records: [EventRecord] | ||
|
||
|
@@ -311,14 +311,12 @@ extension DynamoDB { | |
public init() {} | ||
|
||
@inlinable public func decode<T: Decodable>(_ type: T.Type, from image: [String: AttributeValue]) | ||
throws -> T | ||
{ | ||
throws -> T { | ||
try self.decode(type, from: .map(image)) | ||
} | ||
|
||
@inlinable public func decode<T: Decodable>(_ type: T.Type, from value: AttributeValue) | ||
throws -> T | ||
{ | ||
throws -> T { | ||
let decoder = _DecoderImpl(userInfo: userInfo, from: value, codingPath: []) | ||
return try decoder.decode(T.self) | ||
} | ||
|
@@ -511,7 +509,7 @@ extension DynamoDB { | |
|
||
func nestedContainer<NestedKey>(keyedBy type: NestedKey.Type, forKey key: K) throws | ||
-> KeyedDecodingContainer<NestedKey> where NestedKey: CodingKey { | ||
return try self.decoderForKey(key).container(keyedBy: type) | ||
try self.decoderForKey(key).container(keyedBy: type) | ||
} | ||
|
||
func nestedUnkeyedContainer(forKey key: K) throws -> UnkeyedDecodingContainer { | ||
|
@@ -557,8 +555,7 @@ extension DynamoDB { | |
} | ||
|
||
@inline(__always) private func decodeFixedWidthInteger<T: FixedWidthInteger>(key: Self.Key) | ||
throws -> T | ||
{ | ||
throws -> T { | ||
let value = try getValue(forKey: key) | ||
|
||
guard case .number(let number) = value else { | ||
|
@@ -577,8 +574,7 @@ extension DynamoDB { | |
} | ||
|
||
@inline(__always) private func decodeLosslessStringConvertible<T: LosslessStringConvertible>( | ||
key: Self.Key) throws -> T | ||
{ | ||
key: Self.Key) throws -> T { | ||
let value = try getValue(forKey: key) | ||
|
||
guard case .number(let number) = value else { | ||
|
@@ -677,7 +673,7 @@ extension DynamoDB { | |
} | ||
|
||
func decode<T>(_: T.Type) throws -> T where T: Decodable { | ||
return try T(from: self.impl) | ||
try T(from: self.impl) | ||
} | ||
|
||
@inline(__always) private func createTypeMismatchError(type: Any.Type, value: AttributeValue) -> DecodingError { | ||
|
@@ -688,8 +684,7 @@ extension DynamoDB { | |
} | ||
|
||
@inline(__always) private func decodeFixedWidthInteger<T: FixedWidthInteger>() throws | ||
-> T | ||
{ | ||
-> T { | ||
guard case .number(let number) = self.value else { | ||
throw self.createTypeMismatchError(type: T.self, value: self.value) | ||
} | ||
|
@@ -705,8 +700,7 @@ extension DynamoDB { | |
} | ||
|
||
@inline(__always) private func decodeLosslessStringConvertible<T: LosslessStringConvertible>() | ||
throws -> T | ||
{ | ||
throws -> T { | ||
guard case .number(let number) = self.value else { | ||
throw self.createTypeMismatchError(type: T.self, value: self.value) | ||
} | ||
|
@@ -850,7 +844,7 @@ extension DynamoDB { | |
|
||
mutating func nestedContainer<NestedKey>(keyedBy type: NestedKey.Type) throws | ||
-> KeyedDecodingContainer<NestedKey> where NestedKey: CodingKey { | ||
return try self.impl.container(keyedBy: type) | ||
try self.impl.container(keyedBy: type) | ||
} | ||
|
||
mutating func nestedUnkeyedContainer() throws -> UnkeyedDecodingContainer { | ||
|
@@ -869,8 +863,7 @@ extension DynamoDB { | |
} | ||
|
||
@inline(__always) private mutating func decodeFixedWidthInteger<T: FixedWidthInteger>() throws | ||
-> T | ||
{ | ||
-> T { | ||
defer { | ||
currentIndex += 1 | ||
if currentIndex == count { | ||
|
@@ -891,8 +884,7 @@ extension DynamoDB { | |
} | ||
|
||
@inline(__always) private mutating func decodeLosslessStringConvertible<T: LosslessStringConvertible>() | ||
throws -> T | ||
{ | ||
throws -> T { | ||
defer { | ||
currentIndex += 1 | ||
if currentIndex == count { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please disable the enum namespaces