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

CONFIG: Update swift-format rules #217

Merged
merged 9 commits into from
Nov 19, 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
24 changes: 12 additions & 12 deletions .swift-format
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"lineBreakBeforeEachGenericRequirement": false,
"lineLength": 100,
"maximumBlankLines": 1,
"multiElementCollectionTrailingCommas": true,
"multiElementCollectionTrailingCommas": false,
"noAssignmentInExpressions": {
"allowedFunctions": [
"XCTAssertNoThrow"
Expand All @@ -22,49 +22,49 @@
"prioritizeKeepingFunctionOutputTogether": false,
"respectsExistingLineBreaks": true,
"rules": {
"AllPublicDeclarationsHaveDocumentation": false,
"AlwaysUseLiteralForEmptyCollectionInit": false,
"AllPublicDeclarationsHaveDocumentation": true,
"AlwaysUseLiteralForEmptyCollectionInit": true,
"AlwaysUseLowerCamelCase": true,
"AmbiguousTrailingClosureOverload": true,
"BeginDocumentationCommentWithOneLineSummary": false,
"BeginDocumentationCommentWithOneLineSummary": true,
"DoNotUseSemicolons": true,
"DontRepeatTypeInStaticProperties": true,
"FileScopedDeclarationPrivacy": true,
"FullyIndirectEnum": true,
"GroupNumericLiterals": true,
"IdentifiersMustBeASCII": true,
"NeverForceUnwrap": false,
"NeverUseForceTry": false,
"NeverForceUnwrap": true,
"NeverUseForceTry": true,
"NeverUseImplicitlyUnwrappedOptionals": false,
"NoAccessLevelOnExtensionDeclaration": true,
"NoAssignmentInExpressions": true,
"NoBlockComments": true,
"NoCasesWithOnlyFallthrough": true,
"NoEmptyTrailingClosureParentheses": true,
"NoLabelsInCasePatterns": true,
"NoLeadingUnderscores": false,
"NoLeadingUnderscores": true,
"NoParensAroundConditions": true,
"NoPlaygroundLiterals": true,
"NoVoidReturnOnFunctionSignature": true,
"OmitExplicitReturns": false,
"OmitExplicitReturns": true,
"OneCasePerLine": true,
"OneVariableDeclarationPerLine": true,
"OnlyOneTrailingClosureArgument": true,
"OrderedImports": true,
"ReplaceForEachWithForLoop": true,
"ReturnVoidInsteadOfEmptyTuple": true,
"TypeNamesShouldBeCapitalized": true,
"UseEarlyExits": false,
"UseEarlyExits": true,
"UseExplicitNilCheckInConditions": true,
"UseLetInEveryBoundCaseVariable": true,
"UseShorthandTypeNames": true,
"UseSingleLinePropertyGetter": true,
"UseSynthesizedInitializer": true,
"UseTripleSlashForDocumentationComments": true,
"UseWhereClausesInForLoops": false,
"ValidateDocumentationComments": false
"UseWhereClausesInForLoops": true,
"ValidateDocumentationComments": true
},
"spacesAroundRangeFormationOperators": false,
"tabWidth": 8,
"tabWidth": 4,
"version": 1
}
24 changes: 24 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"originHash" : "30be1a8795d91fbccb4a904ab667609855569d33f57038fec1ba246343472f40",
"pins" : [
{
"identity" : "swift-docc-plugin",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-docc-plugin.git",
"state" : {
"revision" : "85e4bb4e1cd62cec64a4b8e769dcefdf0c5b9d64",
"version" : "1.4.3"
}
},
{
"identity" : "swift-docc-symbolkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swiftlang/swift-docc-symbolkit",
"state" : {
"revision" : "b45d1f2ed151d057b54504d653e0da5552844e34",
"version" : "1.0.0"
}
}
],
"version" : 3
}
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let package = Package(
.iOS(.v16),
.watchOS(.v9),
.tvOS(.v16),
.visionOS(.v1),
.visionOS(.v1)
],

products: [
Expand All @@ -36,7 +36,7 @@ let package = Package(
.testTarget(
name: "TMDbIntegrationTests",
dependencies: ["TMDb"]
),
)
]
)

Expand Down
12 changes: 12 additions & 0 deletions Sources/TMDb/Domain/Models/Company.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,18 @@ extension Company {
case parentCompany
}

///
/// Creates a new instance by decoding from the given decoder.
///
/// This initializer throws an error if reading from the decoder fails, or
/// if the data read is corrupted or otherwise invalid.
///
/// - Parameter decoder: The decoder to read data from.
///
/// - Throws: `DecodingError.typeMismatch` if the encountered encoded value is not convertible to the requested type.
/// - Throws: `DecodingError.keyNotFound` if self does not have an entry for the given key.
/// - Throws: `DecodingError.valueNotFound` if self has a null entry for the given key.
///
public init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let container2 = try decoder.container(keyedBy: CodingKeys.self)
Expand Down
12 changes: 12 additions & 0 deletions Sources/TMDb/Domain/Models/Gender.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ public enum Gender: Int, Codable, Equatable, Hashable, Sendable {
///
case other = 3

///
/// Creates a new instance by decoding from the given decoder.
///
/// This initializer throws an error if reading from the decoder fails, or
/// if the data read is corrupted or otherwise invalid.
///
/// - Parameter decoder: The decoder to read data from.
///
/// - Throws: `DecodingError.typeMismatch` if the encountered encoded value is not convertible to the requested type.
/// - Throws: `DecodingError.keyNotFound` if self does not have an entry for the given key.
/// - Throws: `DecodingError.valueNotFound` if self has a null entry for the given key.
///
public init(from decoder: Decoder) throws {
self =
try Gender(rawValue: decoder.singleValueContainer().decode(RawValue.self)) ?? .unknown
Expand Down
2 changes: 1 addition & 1 deletion Sources/TMDb/Domain/Models/ImageMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ public struct ImageMetadata: Identifiable, Codable, Equatable, Hashable, Sendabl
/// - width: Image width.
/// - height: Image height.
/// - aspectRatio: Aspect ratio.
/// - languageCode: ISO 639-1 language code.
/// - voteAverage: The average of user votes on this image.
/// - voteCount: The number of user votes on this image.
/// - languageCode: ISO 639-1 language code.
///
public init(
filePath: URL,
Expand Down
26 changes: 26 additions & 0 deletions Sources/TMDb/Domain/Models/Media.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ extension Media {
case person
}

///
/// Creates a new instance by decoding from the given decoder.
///
/// This initializer throws an error if reading from the decoder fails, or
/// if the data read is corrupted or otherwise invalid.
///
/// - Parameter decoder: The decoder to read data from.
///
/// - Throws: `DecodingError.typeMismatch` if the encountered encoded value is not convertible to the requested type.
/// - Throws: `DecodingError.keyNotFound` if self does not have an entry for the given key.
/// - Throws: `DecodingError.valueNotFound` if self has a null entry for the given key.
///
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let mediaType = try container.decode(MediaType.self, forKey: .mediaType)
Expand All @@ -85,6 +97,20 @@ extension Media {
}
}

///
/// Encodes this value into the given encoder.
///
/// If the value fails to encode anything, `encoder` will encode an empty
/// keyed container in its place.
///
/// This function throws an error if any values are invalid for the given
/// encoder's format.
///
/// - Parameter encoder: The encoder to write data to.
///
/// - throws: `EncodingError.invalidValue` if the given value is invalid in
/// the current context for this format.
///
public func encode(to encoder: Encoder) throws {
var singleContainer = encoder.singleValueContainer()

Expand Down
12 changes: 12 additions & 0 deletions Sources/TMDb/Domain/Models/Movie.swift
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,18 @@ extension Movie {
case isAdultOnly = "adult"
}

///
/// Creates a new instance by decoding from the given decoder.
///
/// This initializer throws an error if reading from the decoder fails, or
/// if the data read is corrupted or otherwise invalid.
///
/// - Parameter decoder: The decoder to read data from.
///
/// - Throws: `DecodingError.typeMismatch` if the encountered encoded value is not convertible to the requested type.
/// - Throws: `DecodingError.keyNotFound` if self does not have an entry for the given key.
/// - Throws: `DecodingError.valueNotFound` if self has a null entry for the given key.
///
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let container2 = try decoder.container(keyedBy: CodingKeys.self)
Expand Down
26 changes: 26 additions & 0 deletions Sources/TMDb/Domain/Models/MovieExternalLinksCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@ extension MovieExternalLinksCollection {
case twitterID = "twitterId"
}

///
/// Creates a new instance by decoding from the given decoder.
///
/// This initializer throws an error if reading from the decoder fails, or
/// if the data read is corrupted or otherwise invalid.
///
/// - Parameter decoder: The decoder to read data from.
///
/// - Throws: `DecodingError.typeMismatch` if the encountered encoded value is not convertible to the requested type.
/// - Throws: `DecodingError.keyNotFound` if self does not have an entry for the given key.
/// - Throws: `DecodingError.valueNotFound` if self has a null entry for the given key.
///
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)

Expand Down Expand Up @@ -121,6 +133,20 @@ extension MovieExternalLinksCollection {
)
}

///
/// Encodes this value into the given encoder.
///
/// If the value fails to encode anything, `encoder` will encode an empty
/// keyed container in its place.
///
/// This function throws an error if any values are invalid for the given
/// encoder's format.
///
/// - Parameter encoder: The encoder to write data to.
///
/// - throws: `EncodingError.invalidValue` if the given value is invalid in
/// the current context for this format.
///
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)

Expand Down
12 changes: 12 additions & 0 deletions Sources/TMDb/Domain/Models/MovieListItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,18 @@ extension MovieListItem {
case isAdultOnly = "adult"
}

///
/// Creates a new instance by decoding from the given decoder.
///
/// This initializer throws an error if reading from the decoder fails, or
/// if the data read is corrupted or otherwise invalid.
///
/// - Parameter decoder: The decoder to read data from.
///
/// - Throws: `DecodingError.typeMismatch` if the encountered encoded value is not convertible to the requested type.
/// - Throws: `DecodingError.keyNotFound` if self does not have an entry for the given key.
/// - Throws: `DecodingError.valueNotFound` if self has a null entry for the given key.
///
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let container2 = try decoder.container(keyedBy: CodingKeys.self)
Expand Down
12 changes: 12 additions & 0 deletions Sources/TMDb/Domain/Models/Person.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,18 @@ extension Person {
case homepageURL = "homepage"
}

///
/// Creates a new instance by decoding from the given decoder.
///
/// This initializer throws an error if reading from the decoder fails, or
/// if the data read is corrupted or otherwise invalid.
///
/// - Parameter decoder: The decoder to read data from.
///
/// - Throws: `DecodingError.typeMismatch` if the encountered encoded value is not convertible to the requested type.
/// - Throws: `DecodingError.keyNotFound` if self does not have an entry for the given key.
/// - Throws: `DecodingError.valueNotFound` if self has a null entry for the given key.
///
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let container2 = try decoder.container(keyedBy: CodingKeys.self)
Expand Down
26 changes: 26 additions & 0 deletions Sources/TMDb/Domain/Models/PersonExternalLinksCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ extension PersonExternalLinksCollection {
case tikTokID = "tiktokId"
}

///
/// Creates a new instance by decoding from the given decoder.
///
/// This initializer throws an error if reading from the decoder fails, or
/// if the data read is corrupted or otherwise invalid.
///
/// - Parameter decoder: The decoder to read data from.
///
/// - Throws: `DecodingError.typeMismatch` if the encountered encoded value is not convertible to the requested type.
/// - Throws: `DecodingError.keyNotFound` if self does not have an entry for the given key.
/// - Throws: `DecodingError.valueNotFound` if self has a null entry for the given key.
///
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)

Expand Down Expand Up @@ -133,6 +145,20 @@ extension PersonExternalLinksCollection {
)
}

///
/// Encodes this value into the given encoder.
///
/// If the value fails to encode anything, `encoder` will encode an empty
/// keyed container in its place.
///
/// This function throws an error if any values are invalid for the given
/// encoder's format.
///
/// - Parameter encoder: The encoder to write data to.
///
/// - throws: `EncodingError.invalidValue` if the given value is invalid in
/// the current context for this format.
///
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)

Expand Down
26 changes: 26 additions & 0 deletions Sources/TMDb/Domain/Models/Show.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ extension Show {
case tvSeries = "tv"
}

///
/// Creates a new instance by decoding from the given decoder.
///
/// This initializer throws an error if reading from the decoder fails, or
/// if the data read is corrupted or otherwise invalid.
///
/// - Parameter decoder: The decoder to read data from.
///
/// - Throws: `DecodingError.typeMismatch` if the encountered encoded value is not convertible to the requested type.
/// - Throws: `DecodingError.keyNotFound` if self does not have an entry for the given key.
/// - Throws: `DecodingError.valueNotFound` if self has a null entry for the given key.
///
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let mediaType = try container.decode(MediaType.self, forKey: .mediaType)
Expand All @@ -99,6 +111,20 @@ extension Show {
}
}

///
/// Encodes this value into the given encoder.
///
/// If the value fails to encode anything, `encoder` will encode an empty
/// keyed container in its place.
///
/// This function throws an error if any values are invalid for the given
/// encoder's format.
///
/// - Parameter encoder: The encoder to write data to.
///
/// - throws: `EncodingError.invalidValue` if the given value is invalid in
/// the current context for this format.
///
public func encode(to encoder: Encoder) throws {
var singleContainer = encoder.singleValueContainer()

Expand Down
12 changes: 12 additions & 0 deletions Sources/TMDb/Domain/Models/TMDbError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ public enum TMDbError: Equatable, LocalizedError, Sendable {
/// An unknown error.
case unknown

///
/// Returns a Boolean value indicating whether two `TMDBError`s are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
/// - lhs: A value to compare.
/// - rhs: Another value to compare.
///
/// - Returns: `true` if equal, or `false` if not.
///
public static func == (lhs: TMDbError, rhs: TMDbError) -> Bool {
switch (lhs, rhs) {
case (.notFound, .notFound):
Expand Down
Loading