Skip to content

Commit

Permalink
chore: various syntaxt cleanins (SwiftLint warnings fixes)
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
  • Loading branch information
pylapp committed Aug 5, 2024
1 parent b95d8a8 commit 555001f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions OUDS/Core/Tokens/RawTokens/Sources/BorderRawTokens.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,18 @@ public typealias BorderRadiusRawToken = Double

/// Typealise for `String` so as to help users (developers) to see that raw tokens are needed and linked to `String` for **border style raw tokeb**.
/// `String` are used here to prevent to rely on _SwiftUI_ types which are not compatible with `@objc` and are heavier than primitive types.
/// In addition, if new styles are defined in design team side (such as kind of composite styles) and need to be processed differently (because not available with _SwiftUI_ because are composed of several styles),
/// such `String` values could be procesed later without nay API breaks.
/// In addition, if new styles are defined in design team side (such as kind of composite styles) and need to be processed differently
/// (because not available with _SwiftUI_ because are composed of several styles),
/// such `String` values could be procesed later without any API breaks.
public typealias BorderStyleRawToken = String

// MARK: - Raw tokens

/// This is the group of all **raw tokens** related to **borders**.
/// Primitive types such as `Double` and `String` must be used to as to allow to use `@objc` keywords in _Swift extensions_ for overriding.
/// Such tokens are packed in a _Swift struct_ so as to gather them in one object and avoid to have just constants in nothing else (i.e. publicly accessible from everywhere) or _Swift enum_ whch are too heavy
/// (no needs to iterate on them, no needs to make switch/cases, riskjs to have broken code if new values added breaking existing switch/cases).
/// Such tokens are packed in a _Swift struct_ so as to gather them in one object and avoid to have just constants in nothing else
/// (i.e. publicly accessible from everywhere) or _Swift enum_ which are too heavy (no needs to iterate on them, no needs to make switch/cases,
/// risks to have broken code if new values added breaking existing switch/cases).
///
/// In the future, generating tools like _Style Dictionary_ should either follow this file template and structure or just replace values or lines.
public struct BorderRawTokens {
Expand Down Expand Up @@ -66,7 +68,7 @@ public struct BorderRawTokens {
public static let borderRadius9999: BorderRadiusRawToken = 2000

// MARK: Primitive token - Border - Style

public static let borderStyleNone: BorderStyleRawToken = "none"
public static let borderStyleSolid: BorderStyleRawToken = "solid"
public static let borderStyleDashed: BorderStyleRawToken = "dashed"
Expand Down
4 changes: 2 additions & 2 deletions OUDS/Core/Tokens/RawTokens/Tests/BorderRawTokensTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class BorderRawTokensTests: XCTestCase {
XCTAssertLessThan(BorderRawTokens.borderWidth100, BorderRawTokens.borderWidth150)
XCTAssertLessThan(BorderRawTokens.borderWidth150, BorderRawTokens.borderWidth200)
}

/// Wathever the values are, border radius raw tokens must keep their order relationships
func testOrderRelationshipForRadius() throws {
XCTAssertLessThan(BorderRawTokens.borderRadius0, BorderRawTokens.borderRadius25)
Expand All @@ -46,7 +46,7 @@ final class BorderRawTokensTests: XCTestCase {
XCTAssertLessThan(BorderRawTokens.borderRadius600, BorderRawTokens.borderRadius800)
XCTAssertLessThan(BorderRawTokens.borderRadius800, BorderRawTokens.borderRadius9999)
}

/// Border styles raw tokens should be different
func testNonEqualityForStyles() throws {
XCTAssertNotEqual(BorderRawTokens.borderStyleNone, BorderRawTokens.borderStyleSolid)
Expand Down

0 comments on commit 555001f

Please sign in to comment.