Skip to content

Commit

Permalink
Swiftlint all files.
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-zimmermann committed Jun 21, 2024
1 parent ca88d01 commit 35138af
Show file tree
Hide file tree
Showing 274 changed files with 806 additions and 873 deletions.
18 changes: 13 additions & 5 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
included:
- SparkCore
- SparkCoreTests
- Spark
- SparkTests
excluded:
- "**/*.generated.swift"

# Enabled rules for CI linting
# List of all the rules: https://realm.github.io/SwiftLint/rule-directory.html
only_rules:
- colon
- comment_spacing
Expand All @@ -18,6 +16,7 @@ only_rules:
- private_subject
- unneeded_parentheses_in_closure_argument
- multiline_arguments
- multiline_parameters
- lower_acl_than_parent
- syntactic_sugar
- unneeded_break_in_switch
Expand All @@ -27,10 +26,19 @@ only_rules:
- statement_position
- explicit_self
- empty_count
- empty_string
- force_cast
- force_try
- force_unwrapping
- empty_collection_literal
- vertical_whitespace
- direct_return
# - file_name
- file_name_no_space
# - file_header
# - missing_docs
- toggle_bool
- yoda_condition

# Rules triggering ERROR

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ extension Publisher where Failure == Never {
action: @escaping (Self.Output) -> Void ) where S: Scheduler {
self
.receive(on: scheduler)
.sink { value in
.sink(receiveValue: { value in
action(value)
}
})
.store(in: &subscriptions)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import SwiftUI
@testable import SparkCore

final class ControlPropertyStateTests: XCTestCase {

// MARK: - Tests

func test_default_value() {
// GIVEN / WHEN
let state = ControlPropertyState<String>(for: .normal)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ import SwiftUI
@testable import SparkCore

final class ControlPropertyStatesTests: XCTestCase {

// MARK: - Value for States - Tests

func test_value_for_all_states_when_value_is_set() {
// GIVEN
let expectedValue = "Value"

let states = ControlState.allCases

for state in states {
let states = ControlPropertyStates<String>()
states.setValue(expectedValue, for: state)

// WHEN
let value = states.value(for: state)

// THEN
XCTAssertEqual(
value,
Expand All @@ -35,28 +35,28 @@ final class ControlPropertyStatesTests: XCTestCase {
)
}
}

func test_value_for_all_states_when_value_is_nil() {
// GIVEN
let states = ControlState.allCases

for state in states {
let states = ControlPropertyStates<String>()
states.setValue(nil, for: state)

// WHEN
let value = states.value(for: state)

// THEN
XCTAssertNil(
value,
"The value should be nil for the .\(state) state"
)
}
}

// MARK: - Value for Status - Tests

func test_all_values_when_status_isHighlighted() {
// GIVEN
let normalStateValue = "normal"
Expand Down Expand Up @@ -116,7 +116,7 @@ final class ControlPropertyStatesTests: XCTestCase {
)
// **
}

func test_all_values_when_status_isDisabled() {
// GIVEN
let normalStateValue = "normal"
Expand Down
2 changes: 1 addition & 1 deletion core/Sources/Common/Control/SwiftUI/ControlStateText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ final class ControlStateText: ObservableObject {
/// Set the attributed text for a state.
/// - parameter text: new attributed text
/// - parameter state: state of the attributed text
/// - parameter status: the status of the parent control
/// - parameter status: the status of the parent control
func setAttributedText(
_ attributedText: AttributedString?,
for state: ControlState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ final class ControlStateTextTests: XCTestCase {
)

// WHEN

// Check when a text is nil for an another state,
// The text text for the normal state should be returned

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ final class UIControlStateImageView: UIImageView {
/// Set the image for a state.
/// - parameter image: new image
/// - parameter state: state of the image
/// - parameter control: the parent control
/// - parameter control: the parent control
func setImage(
_ image: UIImage?,
for state: ControlState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ final class DisplayedTextTypeTests: XCTestCase {
func test_containsText_when_type_is_none() {
// GIVEN
let type: DisplayedTextType = .none

// WHEN
let containsText = type.containsText

// THEN
XCTAssertFalse(containsText)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import XCTest
@testable import SparkCore

final class DisplayedTextTests: XCTestCase {

// MARK: - Optional Init

func test_optional_init_with_only_text() {
// GIVEN
let textMock = "My text"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ protocol GetDidDisplayedTextChangeUseCaseable {
func execute(currentText: String?,
newText: String?,
displayedTextType: DisplayedTextType) -> Bool

func execute(currentAttributedText: AttributedStringEither?,
newAttributedText: AttributedStringEither?,
displayedTextType: DisplayedTextType) -> Bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ final class GetDidDisplayedTextChangeUseCaseTests: XCTestCase {
// THEN
XCTAssertFalse(isChanged)
}

// MARK: - Tests Execute with attributed text

func test_execute_when_currentAttributedText_is_equal_to_newAttributedText_and_displayedTextType_is_none() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import XCTest
@testable import SparkCore

final class DisplayedTextViewModelTests: XCTestCase {

// MARK: - Tests Init

func test_properties_after_init() {
// GIVEN
let textMock = "Hello"
Expand All @@ -28,7 +28,7 @@ final class DisplayedTextViewModelTests: XCTestCase {
attributedText: attributedTextMock,
getDisplayedTextTypeUseCase: getDisplayedTextTypeUseCaseMock
)

// THEN
XCTAssertEqual(viewModel.displayedTextType,
displayedTextTypeMock,
Expand All @@ -42,7 +42,6 @@ final class DisplayedTextViewModelTests: XCTestCase {
XCTAssertEqual(viewModel.containsText,
displayedTextTypeMock.containsText,
"Wrong containsText value")


// **
// GetDisplayedTextTypeUseCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extension CGFloat {
/// we add this the scaled metric multiplier value.
/// This value must be multiplied with you want to make dynamic (width, height, padding, ...)
/// - note: - Please use this value only for @ScaledMetric on SwiftUI
///
///
/// **Example**
/// This example shows how to create view this multiplier on SwiftUI View
/// ```swift
Expand Down
4 changes: 2 additions & 2 deletions core/Sources/Common/Foundation/Extension/CGRect-Center.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import Foundation
extension CGRect {
/// Returns the center of the x-coordinate of the rect
var centerX: CGFloat {
return (self.minX + self.maxX)/2
return (self.minX + self.maxX) / 2
}

/// Returns the center of the y-coordinate of the rect
var centerY: CGFloat {
return (self.minY + self.maxY)/2
return (self.minY + self.maxY) / 2
}

/// The center point of the rect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ final class OptionalExtensionTests: XCTestCase {

func test_nil_array() {
// GIVEN
let array: Array<Int>? = nil
let array: [Int]? = nil

// WHEN
let isEmptyOrNil = array.isEmptyOrNil
Expand All @@ -61,7 +61,7 @@ final class OptionalExtensionTests: XCTestCase {

func test_empty_array() {
// GIVEN
let array: Array<Int>? = []
let array: [Int]? = []

// WHEN
let isEmptyOrNil = array.isEmptyOrNil
Expand All @@ -72,7 +72,7 @@ final class OptionalExtensionTests: XCTestCase {

func test_array() {
// GIVEN
let array: Array<Int>? = [10, 22, 3]
let array: [Int]? = [10, 22, 3]

// WHEN
let isEmptyOrNil = array.isEmptyOrNil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extension Array where Element == CGRect {
let distances = self.map{ rect in
rect.center.distance(to: location)
}
let nearest = distances.enumerated().min { (left, right) in
let nearest = distances.enumerated().min { left, right in
return left.element < right.element
}
return nearest?.offset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class UIViewClosestTests: XCTestCase {
let views = positions.map{ CGRect(x: $0, y: 10, width: 50, height: 50) }.map(UIView.init(frame:))

for (index, position) in positions.enumerated() {
let closestIndex = views.index(closestTo: CGPoint(x: position+50, y: 100))
let closestIndex = views.index(closestTo: CGPoint(x: position + 50, y: 100))
XCTAssertEqual(closestIndex, index, "Expected \(String(describing: closestIndex)) to be equal to \(index)")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import UIKit

extension NSLayoutConstraint {

/// There is no native possibility to update the multiplier
/// So we need to recreate the constraint with the new multiplier
static func updateMultiplier(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import UIKit


extension UITraitCollection {
func hasDifferentSizeCategory(comparedTo traitCollection: UITraitCollection?) -> Bool {
self.preferredContentSizeCategory != traitCollection?.preferredContentSizeCategory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import UIKit

extension UIView {

/// Insert or remove the trait on the current accessibilityTraits
func accessibilityTraits(manage trait: UIAccessibilityTraits, insert: Bool) {
if insert {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ extension NSLayoutConstraint {
constraints.append(from.trailingAnchor.constraint(equalTo: to.trailingAnchor, constant: -insets.right))
}


return constraints
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import Foundation


public enum BadgeAccessibilityIdentifier {

// MARK: - Properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protocol BadgeGetIntentColorsUseCaseable {
}

final class BadgeGetIntentColorsUseCase: BadgeGetIntentColorsUseCaseable {

// MARK: - Methods

func execute(intentType: BadgeIntentType,
Expand Down Expand Up @@ -77,7 +77,7 @@ final class BadgeGetIntentColorsUseCase: BadgeGetIntentColorsUseCaseable {
borderColor: surfaceColor,
foregroundColor: colors.feedback.onSuccess
)

}
}
}
2 changes: 1 addition & 1 deletion core/Sources/Components/Badge/View/SwiftUI/BadgeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import SwiftUI
/// This is SwiftUI badge view to show notifications count
///
/// Badge border and offsets of it's text are **@ScaledMetric** variables and alligned to user's **Accessibility**
///
///
/// **Example**
/// This example shows how to create view with horizontal alignment of Badge
/// ```swift
Expand Down
Loading

0 comments on commit 35138af

Please sign in to comment.