Skip to content

Commit 71c4216

Browse files
Hamza GhazouaniHamzaGhazouani
authored andcommitted
Fix codacy issues
1 parent 125fa3a commit 71c4216

File tree

10 files changed

+45
-25
lines changed

10 files changed

+45
-25
lines changed

Example/HGPlaceholders/AppDelegate/AppDelegate.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,4 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
4040
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
4141
}
4242

43-
4443
}
45-

Example/HGPlaceholders/CollectionViewExample/CollectionViewController.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ private let reuseIdentifier = "Cell"
1414
class CollectionViewController: UICollectionViewController, UICollectionViewDelegateFlowLayout {
1515

1616
var placeholderCollectionView: CollectionView? {
17-
get { return collectionView as? CollectionView }
17+
return collectionView as? CollectionView
1818
}
1919

2020
var data = [
@@ -119,6 +119,7 @@ class CollectionViewController: UICollectionViewController, UICollectionViewDele
119119
}
120120

121121
extension CollectionViewController: PlaceholderDelegate {
122+
122123
func view(_ view: Any, actionButtonTappedFor placeholder: Placeholder) {
123124
(view as? CollectionView)?.showDefault()
124125
}

Example/HGPlaceholders/TableViewExample/TableViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class ViewController: UITableViewController {
9999

100100
present(alertController, animated: true, completion: nil)
101101
}
102+
102103
}
103104

104105
extension ViewController: PlaceholderDelegate {

HGPlaceholders/Classes/Placeholder/PlaceholderKey.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,20 @@ public struct PlaceholderKey: Hashable {
4343
public static var noResultsKey = PlaceholderKey(value: "noResults")
4444

4545
/// Is used to add new keys
46-
public static func custom(key: String) -> PlaceholderKey { return PlaceholderKey(value: key) }
46+
public static func custom(key: String) -> PlaceholderKey {
47+
return PlaceholderKey(value: key)
48+
}
4749

4850
public var hashValue: Int {
4951
return value.hashValue
5052
}
5153
}
5254

5355
extension PlaceholderKey: Equatable {
56+
5457
/// To make PlaceholderKey hashable
5558
public static func == (lhs: PlaceholderKey, rhs: PlaceholderKey) -> Bool {
5659
return lhs.value == rhs.value
5760
}
61+
5862
}

HGPlaceholders/Classes/PlaceholdersProvider/PlaceholderDataSourceDelegate.swift

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class PlaceholderDataSourceDelegate: NSObject {
3636
/// - tintColor: the tint color to apply
3737
func fill(cell: CellPlaceholding, to placeholder: Placeholder, tintColor: UIColor?) {
3838

39-
/** if the the placeholder created by xib and data/style are nil, we should keep the xib data/style **/
39+
/* if the the placeholder created by xib and data/style are nil, we should keep the xib data/style */
4040

4141
// apply style
4242
if let style = placeholder.style {
@@ -85,6 +85,7 @@ class PlaceholderDataSourceDelegate: NSObject {
8585
}
8686
return height
8787
}
88+
8889
}
8990

9091
// MARK: table view data source methods
@@ -110,7 +111,7 @@ extension PlaceholderDataSourceDelegate: UITableViewDataSource {
110111

111112
cell.selectionStyle = .none
112113
// If the cell does not inherit from PlaceholderTableViewCell, the data and the style can't be applied
113-
guard let placeholderTableViewCell = (cell as? PlaceholderTableViewCell) else {
114+
guard let placeholderTableViewCell = cell as? PlaceholderTableViewCell else {
114115
return cell
115116
}
116117

@@ -157,7 +158,10 @@ extension PlaceholderDataSourceDelegate: UITableViewDelegate {
157158
// animate the cell
158159
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
159160

160-
if placeholder.style?.isAnimated == false { return }
161+
if placeholder.style?.isAnimated == false {
162+
return
163+
}
164+
161165
guard let placeholderTableViewCell = cell as? PlaceholderTableViewCell else { return }
162166
animate(cell: placeholderTableViewCell)
163167
}
@@ -177,15 +181,15 @@ extension PlaceholderDataSourceDelegate: UICollectionViewDataSource {
177181
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath)
178182

179183
// If the cell does not inherit from PlaceholderTableViewCell, the data and the style can't be applied
180-
guard let placeholderCollectionViewCell = (cell as? PlaceholderCollectionViewCell) else {
184+
guard let placeholderCollectionViewCell = cell as? PlaceholderCollectionViewCell else {
181185
return cell
182186
}
183187

184188
fill(cell: placeholderCollectionViewCell, to: placeholder, tintColor: collectionView.tintColor)
185189

186190
// forward action to placeholder delegate
187191
placeholderCollectionViewCell.onActionButtonTap = { [unowned self] in
188-
guard let placeholderCollectionView = (collectionView as? CollectionView) else { return }
192+
guard let placeholderCollectionView = collectionView as? CollectionView else { return }
189193
placeholderCollectionView.placeholderDelegate?.view(collectionView, actionButtonTappedFor: self.placeholder)
190194
}
191195
return cell

HGPlaceholders/Classes/PlaceholdersProvider/PlaceholdersProvider.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,25 @@ final public class PlaceholdersProvider {
7070

7171
/// Returns an instance of PlaceholderDataSourceDelegate of default loading key
7272
/// - Returns: returns PlaceholderDataSourceDelegate instance, nil of no placeholder found with this key
73-
func loadingDataSource() -> PlaceholderDataSourceDelegate? {
73+
func loadingDataSource() -> PlaceholderDataSourceDelegate? {
7474
return dataSourceAndDelegate(with: .loadingKey)
7575
}
7676

7777
/// Returns an instance of PlaceholderDataSourceDelegate of default error key
7878
/// - Returns: returns PlaceholderDataSourceDelegate instance, nil of no placeholder found with this key
79-
func errorDataSource() -> PlaceholderDataSourceDelegate? {
79+
func errorDataSource() -> PlaceholderDataSourceDelegate? {
8080
return dataSourceAndDelegate(with: .errorKey)!
8181
}
8282

8383
/// Returns an instance of PlaceholderDataSourceDelegate of default no results key
8484
/// - Returns: returns PlaceholderDataSourceDelegate instance, nil of no placeholder found with this key
85-
func noResultsDataSource() -> PlaceholderDataSourceDelegate? {
85+
func noResultsDataSource() -> PlaceholderDataSourceDelegate? {
8686
return dataSourceAndDelegate(with: .noResultsKey)!
8787
}
8888

8989
/// Returns an instance of PlaceholderDataSourceDelegate of default no connection key
9090
/// - Returns: returns PlaceholderDataSourceDelegate instance, nil of no placeholder found with this key
91-
func noConnectionDataSource() -> PlaceholderDataSourceDelegate? {
91+
func noConnectionDataSource() -> PlaceholderDataSourceDelegate? {
9292
return dataSourceAndDelegate(with: .noConnectionKey)
9393
}
9494
}

HGPlaceholders/Classes/Protocols/NibLoadable.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ import UIKit
1010

1111
// MARK: Protocol Definition
1212

13-
/// Make your UIView subclasses conform to this protocol when:
14-
/// * they *are* NIB-based, and
15-
/// * this class is used as the XIB's root view
16-
///
17-
/// to be able to instantiate them from the NIB in a type-safe manner
13+
/** Make your UIView subclasses conform to this protocol when:
14+
* they *are* NIB-based, and
15+
* this class is used as the XIB's root view
16+
*
17+
* to be able to instantiate them from the NIB in a type-safe manner
18+
*/
1819
protocol NibLoadable: class {
1920
/// The nib file to use to load a new instance of the View designed in a XIB
2021
static var nib: UINib { get }
@@ -23,8 +24,8 @@ protocol NibLoadable: class {
2324
// MARK: Default implementation
2425

2526
extension NibLoadable {
26-
/// By default, use the nib which have the same name as the name of the class,
27-
/// and located in the bundle of that class
27+
/* By default, use the nib which have the same name as the name of the class,
28+
and located in the bundle of that class */
2829
static var nib: UINib {
2930
return UINib(nibName: String(describing: self), bundle: Bundle(for: self))
3031
}

HGPlaceholders/Classes/Views/CollectionView.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ open class CollectionView: UICollectionView {
1919
*/
2020
open override var collectionViewLayout: UICollectionViewLayout {
2121
didSet {
22-
if collectionViewLayout === placeholderLayout { return }
22+
if collectionViewLayout === placeholderLayout {
23+
return
24+
}
2325
defaultLayout = collectionViewLayout
2426
}
2527
}
@@ -57,7 +59,9 @@ open class CollectionView: UICollectionView {
5759
open override weak var delegate: UICollectionViewDelegate? {
5860
didSet {
5961
/* we save only the initial delegate (and not the placeholder delegate) to allow to go back to the initial one */
60-
if delegate is PlaceholderDataSourceDelegate { return }
62+
if delegate is PlaceholderDataSourceDelegate {
63+
return
64+
}
6165
defaultDelegate = delegate
6266
}
6367
}

HGPlaceholders/Classes/Views/TableView+Switcher.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,5 @@ extension TableView: PlaceholdersSwitcher {
5454
public func showDefault() {
5555
self.switchTo(dataSource: defaultDataSource, delegate: defaultDelegate)
5656
}
57+
5758
}

HGPlaceholders/Classes/Views/TableView.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ open class TableView: UITableView {
4646
weak open override var dataSource: UITableViewDataSource? {
4747
didSet {
4848
/* we save only the initial data source (and not a placeholder datasource) to allow to go back to the initial data */
49-
if dataSource is PlaceholderDataSourceDelegate { return }
49+
if dataSource is PlaceholderDataSourceDelegate {
50+
return
51+
}
5052
defaultDataSource = dataSource
5153
}
5254
}
@@ -58,7 +60,9 @@ open class TableView: UITableView {
5860
open override weak var delegate: UITableViewDelegate? {
5961
didSet {
6062
/* we save only the initial delegate (and not the placeholder delegate) to allow to go back to the initial one */
61-
if delegate is PlaceholderDataSourceDelegate { return }
63+
if delegate is PlaceholderDataSourceDelegate {
64+
return
65+
}
6266
defaultDelegate = delegate
6367
}
6468
}
@@ -69,7 +73,9 @@ open class TableView: UITableView {
6973
*/
7074
open override var tableHeaderView: UIView? {
7175
didSet {
72-
if tableHeaderView == nil { return }
76+
if tableHeaderView == nil {
77+
return
78+
}
7379

7480
defaultTableHeaderView = tableHeaderView
7581
}

0 commit comments

Comments
 (0)