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

[SwiftLint] Upgrade SwiftLint and new rules #164

Merged
merged 3 commits into from
Apr 29, 2019
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
25 changes: 23 additions & 2 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,42 @@ opt_in_rules:
- first_where
- sorted_first_last
- contains_over_first_not_nil
- last_where


# idiomatic
- fatal_error_message
- xctfail_message
- legacy_random
- no_extension_access_modifier
- redundant_type_annotation
- toggle_bool

# style
- number_separator
- operator_usage_whitespace
- sorted_imports
- redundant_type_annotation
- redundant_objc_attribute
- closure_spacing
- collection_alignment
- toggle_bool
- modifier_order
- vertical_whitespace_closing_braces
- multiline_arguments
- multiline_parameters
- unneeded_parentheses_in_closure_argument
- explicit_self

# lint
- overridden_super_call
- yoda_condition
- weak_computed_property
- anyobject_protocol
- array_init
- empty_xctest_method
- identical_operands
- prohibited_super_call
- unused_import
- unused_private_declaration

file_length: 650
line_length: 200
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ NEXT
----

### Changed
- Upgrades SwiftLint to 0.31.0 and add several new rules. ([#164](https://github.com/plangrid/ReactiveLists/pull/164), [@anayini](https://github.com/anayini))
- Upgrade Travis to Xcode 10.2, SDK 12.2

0.5.1
Expand Down
3 changes: 1 addition & 2 deletions Example/Models.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct Tool {
let uuid = UUID()

static func randomTool() -> Tool {
let randomNumber = arc4random_uniform((UInt32(ToolType.allValues.count)))
let randomNumber = UInt32.random(in: 0..<UInt32(ToolType.allValues.count))
return Tool(type: ToolType(rawValue: randomNumber)!)
}
}
Expand Down Expand Up @@ -68,6 +68,5 @@ enum ToolType: UInt32 {
case .crane:
return "🏗️"
}

}
}
1 change: 0 additions & 1 deletion Example/ToolTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@
import UIKit

final class ToolTableViewCell: UITableViewCell {

}
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ target 'ReactiveLists' do
project 'ReactiveLists.xcodeproj'

pod 'DifferenceKit', '1.1.0'
pod 'SwiftLint', '0.30.1'
pod 'SwiftLint', '0.31.0'

target 'ReactiveListsExample' do
project 'ReactiveLists.xcodeproj'
Expand Down
10 changes: 5 additions & 5 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ PODS:
- DifferenceKit/Core (1.1.0)
- DifferenceKit/UIKitExtension (1.1.0):
- DifferenceKit/Core
- SwiftLint (0.30.1)
- SwiftLint (0.31.0)

DEPENDENCIES:
- DifferenceKit (= 1.1.0)
- SwiftLint (= 0.30.1)
- SwiftLint (= 0.31.0)

SPEC REPOS:
https://github.com/cocoapods/specs.git:
Expand All @@ -18,8 +18,8 @@ SPEC REPOS:

SPEC CHECKSUMS:
DifferenceKit: 7726ceeff4ec3748788e4b01396861b283797440
SwiftLint: a54bf1fe12b55c68560eb2a7689dfc81458508f7
SwiftLint: 7a0227733d786395817373b2d0ca799fd0093ff3

PODFILE CHECKSUM: f4d525d7ba27317176274dd214708a367af86650
PODFILE CHECKSUM: 74334aebd16efb052743e4dd7a9876efeb76d4eb

COCOAPODS: 1.7.0.beta.3
COCOAPODS: 1.6.0
10 changes: 5 additions & 5 deletions Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

494 changes: 245 additions & 249 deletions Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file modified Pods/SwiftLint/swiftlint
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions Sources/CollectionViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ public protocol CollectionCellViewModel: ReusableCellViewModelProtocol, Diffable
}

/// Default implementations for `CollectionCellViewModel`.
public extension CollectionCellViewModel {
extension CollectionCellViewModel {

/// Default implementation, returns `true`.
var shouldHighlight: Bool { return true }
public var shouldHighlight: Bool { return true }

/// Default implementation, returns `nil`.
var didSelect: DidSelectClosure? { return nil }
public var didSelect: DidSelectClosure? { return nil }

/// Default implementation, returns `nil`.
var didDeselect: DidDeselectClosure? { return nil }
public var didDeselect: DidDeselectClosure? { return nil }
}

/// View model for supplementary views in collection views.
Expand All @@ -66,13 +66,13 @@ public protocol CollectionSupplementaryViewModel: ReusableSupplementaryViewModel
}

/// Default implementations for `CollectionViewSupplementaryViewModel`.
public extension CollectionSupplementaryViewModel {
extension CollectionSupplementaryViewModel {

/// Default implementation, returns `nil`.
var viewInfo: SupplementaryViewInfo? { return nil }
public var viewInfo: SupplementaryViewInfo? { return nil }

/// Default implementation, returns `nil`.
var height: CGFloat? { return nil }
public var height: CGFloat? { return nil }
}

/// The view model that describes a `UICollectionView`.
Expand Down
4 changes: 2 additions & 2 deletions Sources/Diffing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public protocol DiffableViewModel {
public typealias DiffingKey = String

/// Default value for diffingKey
public extension DiffableViewModel {
extension DiffableViewModel {

/// Default implementation. Uses class name.
var diffingKey: DiffingKey {
public var diffingKey: DiffingKey {
return String(describing: Self.self)
}
}
Expand Down
20 changes: 10 additions & 10 deletions Sources/TableViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,38 +56,38 @@ public protocol TableCellViewModel: ReusableCellViewModelProtocol, DiffableViewM
}

/// Default implementations for `TableCellViewModel`.
public extension TableCellViewModel {
extension TableCellViewModel {

/// Default implementation, returns `nil`.
/// - Note: If `nil`, the `TableViewDriver` will fallback to `TableViewModel.defaultRowHeight`.
/// - See also: TableViewModel
var rowHeight: CGFloat? {
public var rowHeight: CGFloat? {
return nil
}

/// Default implementation, returns `.none`.
var editingStyle: UITableViewCell.EditingStyle { return .none }
public var editingStyle: UITableViewCell.EditingStyle { return .none }

/// Default implementation, returns `true`.
var shouldHighlight: Bool { return true }
public var shouldHighlight: Bool { return true }

/// Default implementation, returns `false`.
var shouldIndentWhileEditing: Bool { return false }
public var shouldIndentWhileEditing: Bool { return false }

/// Default implementation, returns `nil`.
var willBeginEditing: WillBeginEditingClosure? { return nil }
public var willBeginEditing: WillBeginEditingClosure? { return nil }

/// Default implementation, returns `nil`.
var didEndEditing: DidEndEditingClosure? { return nil }
public var didEndEditing: DidEndEditingClosure? { return nil }

/// Default implementation, returns `nil`.
var commitEditingStyle: CommitEditingStyleClosure? { return nil }
public var commitEditingStyle: CommitEditingStyleClosure? { return nil }

/// Default implementation, returns `nil`.
var didSelect: DidSelectClosure? { return nil }
public var didSelect: DidSelectClosure? { return nil }

/// Default implementation, returns `nil`.
var accessoryButtonTapped: AccessoryButtonTappedClosure? { return nil }
public var accessoryButtonTapped: AccessoryButtonTappedClosure? { return nil }
}

/// Protocol that needs to be implemented by table view cell view models
Expand Down
2 changes: 1 addition & 1 deletion Tests/TableView/TableViewMocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class TestTableView: UITableView {
}

override var indexPathsForVisibleRows: [IndexPath]? {
return (0..<self.numberOfSections).flatMap { (section) -> [IndexPath] in
return (0..<self.numberOfSections).flatMap { section -> [IndexPath] in
(0..<self.numberOfRows(inSection: section)).map { IndexPath(row: $0, section: section) }
}
}
Expand Down