Skip to content

Commit

Permalink
Fix SwiftFormat issues (#19)
Browse files Browse the repository at this point in the history
* Remove trailing commas

* Fix indentation

* Move inline try to start of expression

* Remove trailing white spaces

* Use opaque generic parameters instead of generic parameters with constraints

* Replace consecutive blank lines with a single blank line
  • Loading branch information
pereBohigas authored May 29, 2024
1 parent afeff86 commit b52b313
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 34 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import PackageDescription
let package = Package(
name: "SwiftPolyglot",
platforms: [
.macOS(.v10_15)
.macOS(.v10_15),
],
products: [
.executable(name: "swiftpolyglot", targets: ["SwiftPolyglot"]),
Expand All @@ -19,7 +19,7 @@ let package = Package(
name: "SwiftPolyglot",
dependencies: [
"SwiftPolyglotCore",
.product(name: "ArgumentParser", package: "swift-argument-parser")
.product(name: "ArgumentParser", package: "swift-argument-parser"),
]
),
.target(name: "SwiftPolyglotCore"),
Expand Down
8 changes: 4 additions & 4 deletions Sources/SwiftPolyglot/RuntimeError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ enum RuntimeError: Error {
extension RuntimeError: CustomStringConvertible {
var description: String {
switch self {
case let .coreError(description):
return description
case .fileListingNotPossible:
return "It was not possible to list all files to be checked"
case let .coreError(description):
return description
case .fileListingNotPossible:
return "It was not possible to list all files to be checked"
}
}
}
20 changes: 10 additions & 10 deletions Sources/SwiftPolyglotCore/MissingTranslation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ struct MissingTranslation {
extension MissingTranslation {
var message: String {
switch category {
case let .deviceMissingOrNotTranslated(device, language):
return "'\(originalString)' device '\(device)' is missing or not translated in '\(language)' in file: \(filePath)"
case let .missingOrNotTranslated(language):
return "'\(originalString)' is missing or not translated in '\(language)' in file: \(filePath)"
case let .missingTranslation(language):
return "'\(originalString)' is missing translations for language '\(language)' in file: \(filePath)"
case .missingTranslationForAllLanguages:
return "'\(originalString)' is not translated in any language in file: \(filePath)"
case let .pluralMissingOrNotTranslated(pluralForm, language):
return "'\(originalString)' plural form '\(pluralForm)' is missing or not translated in '\(language)' in file: \(filePath)"
case let .deviceMissingOrNotTranslated(device, language):
return "'\(originalString)' device '\(device)' is missing or not translated in '\(language)' in file: \(filePath)"
case let .missingOrNotTranslated(language):
return "'\(originalString)' is missing or not translated in '\(language)' in file: \(filePath)"
case let .missingTranslation(language):
return "'\(originalString)' is missing translations for language '\(language)' in file: \(filePath)"
case .missingTranslationForAllLanguages:
return "'\(originalString)' is not translated in any language in file: \(filePath)"
case let .pluralMissingOrNotTranslated(pluralForm, language):
return "'\(originalString)' plural form '\(pluralForm)' is missing or not translated in '\(language)' in file: \(filePath)"
}
}
}
18 changes: 9 additions & 9 deletions Sources/SwiftPolyglotCore/SwiftPolyglotCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ public struct SwiftPolyglotCore {
}

if let variations = languageDict["variations"] as? [String: [String: [String: Any]]] {
missingTranslations.append(
try missingTranslations.append(
contentsOf:
try getMissingTranslationsFromVariations(
variations,
originalString: originalString,
lang: lang,
filePath: filePath
)
getMissingTranslationsFromVariations(
variations,
originalString: originalString,
lang: lang,
filePath: filePath
)
)
} else if
let stringUnit = languageDict["stringUnit"] as? [String: Any],
Expand Down Expand Up @@ -153,7 +153,7 @@ public struct SwiftPolyglotCore {
for (variationKey, variationDict) in variations {
if variationKey == "plural" {
for (pluralForm, value) in variationDict {
guard
guard
let stringUnit = value["stringUnit"] as? [String: Any],
let state = stringUnit["state"] as? String,
state == "translated"
Expand All @@ -171,7 +171,7 @@ public struct SwiftPolyglotCore {
}
} else if variationKey == "device" {
for (device, value) in variationDict {
guard
guard
let stringUnit = value["stringUnit"] as? [String: Any],
let state = stringUnit["state"] as? String,
state == "translated"
Expand Down
8 changes: 4 additions & 4 deletions Sources/SwiftPolyglotCore/SwiftPolyglotError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ enum SwiftPolyglotError: Error {
extension SwiftPolyglotError: LocalizedError {
public var errorDescription: String? {
switch self {
case .missingTranslations:
return "Error: One or more translations are missing."
case let .unsupportedVariation(variation):
return "Variation type '\(variation)' is not supported. Please create an issue in GitHub"
case .missingTranslations:
return "Error: One or more translations are missing."
case let .unsupportedVariation(variation):
return "Variation type '\(variation)' is not supported. Please create an issue in GitHub"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import XCTest
/// - message: An optional description of a failure.
/// - file: The file where the failure occurs. The default is the file path of the test case where this function is being called.
/// - line: The line number where the failure occurs. The default is the line number where this function is being called.
public func XCTAssertNoThrowAsync<T>(
_ expression: @autoclosure () async throws -> T,
public func XCTAssertNoThrowAsync(
_ expression: @autoclosure () async throws -> some Any,
_ message: @autoclosure () -> String = "",
file: StaticString = #filePath,
line: UInt = #line
Expand Down Expand Up @@ -54,8 +54,8 @@ public func XCTAssertNoThrowAsync<T>(
/// - errorHandler: An optional handler for errors that `expression` throws.
///
/// from: https://gitlab.com/-/snippets/2567566
public func XCTAssertThrowsErrorAsync<T>(
_ expression: @autoclosure () async throws -> T,
public func XCTAssertThrowsErrorAsync(
_ expression: @autoclosure () async throws -> some Any,
_ message: @autoclosure () -> String = "",
file: StaticString = #filePath,
line: UInt = #line,
Expand All @@ -74,4 +74,3 @@ public func XCTAssertThrowsErrorAsync<T>(
errorHandler(error)
}
}

0 comments on commit b52b313

Please sign in to comment.