Skip to content

[CM-995] Add new linter rules and fix warnings #35

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

Merged
merged 1 commit into from
Dec 13, 2022
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
2 changes: 2 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ opt_in_rules: # some rules are turned off by default, so you need to opt-in
- empty_count
- first_where
- force_unwrapping
- implicit_return
- missing_docs
- multiline_arguments
- multiline_arguments_brackets
- multiline_function_chains
Expand Down
4 changes: 4 additions & 0 deletions Sources/YCoreUI/Extensions/UIKit/UIColor+rgbComponents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

import UIKit

// This relatively simple tuple (four float values representing the color channels)
// is already a released public api.
// swiftlint: disable large_tuple

/// Tuple representing Red, Green, Blue, and Alpha color channel components
public typealias RGBAComponents = (red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat)

Expand Down
12 changes: 6 additions & 6 deletions Sources/YCoreUI/Extensions/UIKit/UIView+constrainEdges.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ import UIKit

extension NSDirectionalRectEdge {
/// Horizontal edges only (consisting of `.leading` and `.trailing`)
public static var horizontal: NSDirectionalRectEdge { return [.leading, .trailing] }
public static var horizontal: NSDirectionalRectEdge { [.leading, .trailing] }

/// Vertical edges only (consisting of `.top` and `.bottom`)
public static var vertical: NSDirectionalRectEdge { return [.top, .bottom] }
public static var vertical: NSDirectionalRectEdge { [.top, .bottom] }

/// All edges except `.top`
public static var notTop: NSDirectionalRectEdge { return [.leading, .bottom, .trailing] }
public static var notTop: NSDirectionalRectEdge { [.leading, .bottom, .trailing] }

/// All edges except `.leading`
public static var notLeading: NSDirectionalRectEdge { return [.top, .bottom, .trailing] }
public static var notLeading: NSDirectionalRectEdge { [.top, .bottom, .trailing] }

/// All edges except `.bottom`
public static var notBottom: NSDirectionalRectEdge { return [.top, .leading, .trailing] }
public static var notBottom: NSDirectionalRectEdge { [.top, .leading, .trailing] }

/// All edges except `.trailing`
public static var notTrailing: NSDirectionalRectEdge { return [.top, .leading, .bottom] }
public static var notTrailing: NSDirectionalRectEdge { [.top, .leading, .bottom] }
}

extension UIView {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import XCTest
@testable import YCoreUI

// Large tuples help us build unit test expectations concisely
// swiftlint:disable large_tuple

final class CGFloatRoundedTests: XCTestCase {
typealias ScalingInputs = (
value: CGFloat,
Expand Down
3 changes: 3 additions & 0 deletions Tests/YCoreUITests/Extensions/UIKit/UIColor+WCAGTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import XCTest
@testable import YCoreUI

// Large tuples help us build unit test expectations concisely
// swiftlint:disable large_tuple

final class UIColorWCAGTests: XCTestCase {
typealias ColorInputs = (foreground: UIColor, background: UIColor, context: WCAGContext)

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

import XCTest

// Large tuples help us build unit test expectations concisely
// swiftlint:disable large_tuple

final class UIColorRgbValueTests: XCTestCase {
typealias ColorTest = (color: UIColor, prefix: String?, isUppercase: Bool, output: String)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
import XCTest
@testable import YCoreUI

// It's not a problem having too many tests!
// swiftlint:disable type_body_length

final class UIViewConstrainAnchorTests: XCTestCase {
func testXAxisConstraints() {
let (sut, relations) = makeSUT()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

import XCTest

// It's not a problem having too many tests!
// swiftlint:disable function_body_length

final class UIViewConstrainEdgesTests: XCTestCase {
func testSimple() {
let (sut, insets) = makeSUT()
Expand Down
30 changes: 0 additions & 30 deletions Tests/YCoreUITests/Foundations/UIColor+TestHarness.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ extension UIColor {
}

extension UIColor {
/// 0x0067B1
static let brand = UIColor(rgb: 0x0067B1)

/// 0x0050AC
static let interactive = UIColor(rgb: 0x0050AC)

Expand All @@ -57,9 +54,6 @@ extension UIColor {

/// 0xE7F3FE
static let shade2 = UIColor(rgb: 0xE7F3FE)

/// 0x6390BC
static let shade3 = UIColor(rgb: 0x6390BC)
}

extension UIColor {
Expand Down Expand Up @@ -113,17 +107,6 @@ extension UIColor {
}
}

static let separatorSecondary: UIColor =
UIColor { (traitCollection: UITraitCollection) -> UIColor in
switch(traitCollection.userInterfaceStyle,
traitCollection.accessibilityContrast) {
case (.dark, .high): return .gray600
case (.dark, _): return .gray500
case (_, .high): return .gray600
default: return .white
}
}

static let backgroundPrimaryCTA: UIColor =
UIColor { (traitCollection: UITraitCollection) -> UIColor in
switch(traitCollection.userInterfaceStyle,
Expand All @@ -143,17 +126,4 @@ extension UIColor {
default: return .white
}
}

static let backgroundAccent: UIColor =
UIColor { (traitCollection: UITraitCollection) -> UIColor in
switch(traitCollection.userInterfaceStyle,
traitCollection.accessibilityContrast) {
case (.dark, .high): return .gray400
case (.dark, _): return .gray300
case (_, .high): return .accent.darkened(by: 0.25)
default: return .accent
}
}

public static let contentAccent: UIColor = .white
}