diff --git a/iOSBooks/.swiftlint.yml b/iOSBooks/.swiftlint.yml new file mode 100644 index 0000000..0e5584f --- /dev/null +++ b/iOSBooks/.swiftlint.yml @@ -0,0 +1,46 @@ +excluded: # paths to ignore during linting. Takes precedence over `included`. + - Pods + - iOSBooksTests +included: + - iOSBooks +whitelist_rules: + - colon + - implicitly_unwrapped_optional + - empty_count + - force_cast + - force_try + - force_unwrapping + - first_where + - last_where + - legacy_random + - nslocalizedstring_key + - overridden_super_call + - private_over_fileprivate + - redundant_nil_coalescing + - redundant_optional_initialization + - redundant_string_enum_value + - sorted_first_last + - sorted_imports + - statement_position +colon: warning +empty_count: warning +force_cast: error +force_try: error +force_unwrapping: error +first_where: warning +implicitly_unwrapped_optional: + severity: error +last_where: warning +legacy_random: warning +nslocalizedstring_key: warning +overridden_super_call: + severity: warning +private_over_fileprivate: + severity: warning +redundant_nil_coalescing: warning +redundant_optional_initialization: warning +redundant_string_enum_value: warning +sorted_first_last: warning +sorted_imports: warning +statement_position: + severity: warning diff --git a/iOSBooks/Podfile b/iOSBooks/Podfile index 4f3cc9d..98d6539 100644 --- a/iOSBooks/Podfile +++ b/iOSBooks/Podfile @@ -8,6 +8,7 @@ target 'iOSBooks' do # Pods for iOSBooks pod 'PromiseKit' pod 'Kingfisher', "~>5.1" + pod 'SwiftLint' target 'iOSBooksTests' do inherit! :search_paths diff --git a/iOSBooks/iOSBooks.xcodeproj/project.pbxproj b/iOSBooks/iOSBooks.xcodeproj/project.pbxproj index 3652d78..7ea6356 100644 --- a/iOSBooks/iOSBooks.xcodeproj/project.pbxproj +++ b/iOSBooks/iOSBooks.xcodeproj/project.pbxproj @@ -327,6 +327,7 @@ 0E3964D12314BB470093738B /* Frameworks */, 0E3964D22314BB470093738B /* Resources */, 29B8A3AC18D11FEF43C48244 /* [CP] Embed Pods Frameworks */, + 74B9187D231CBF9800ADDEA4 /* ShellScript */, ); buildRules = ( ); @@ -473,6 +474,23 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-iOSBooksTests/Pods-iOSBooksTests-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; + 74B9187D231CBF9800ADDEA4 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "if which swiftlint >/dev/null; then\nswiftlint\nelse\necho \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n"; + }; B1160ABF1429D7BD27416220 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; diff --git a/iOSBooks/iOSBooks/BookDetail/View/BookDetailViewController.swift b/iOSBooks/iOSBooks/BookDetail/View/BookDetailViewController.swift index 4a3b9c1..f1ccb35 100644 --- a/iOSBooks/iOSBooks/BookDetail/View/BookDetailViewController.swift +++ b/iOSBooks/iOSBooks/BookDetail/View/BookDetailViewController.swift @@ -31,7 +31,7 @@ class BookDetailViewController: UIViewController { override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) - descriptionTextView?.scrollRangeToVisible(NSRange(location:0, length:0)) + descriptionTextView?.scrollRangeToVisible(NSRange(location: 0, length: 0)) } @objc func dismissScreen() { diff --git a/iOSBooks/iOSBooks/BooksList/View/BooksListViewController.swift b/iOSBooks/iOSBooks/BooksList/View/BooksListViewController.swift index a528d44..e3c47c6 100644 --- a/iOSBooks/iOSBooks/BooksList/View/BooksListViewController.swift +++ b/iOSBooks/iOSBooks/BooksList/View/BooksListViewController.swift @@ -19,6 +19,7 @@ class BooksListViewController: UIViewController { // MARK: - View Life Cycle override func viewDidLoad() { + super.viewDidLoad() setupCollectionView() setupFavoritesFilterButton() } diff --git a/iOSBooks/iOSBooks/BooksList/ViewModel/BooksListViewModel.swift b/iOSBooks/iOSBooks/BooksList/ViewModel/BooksListViewModel.swift index 9fe2f68..19fbdef 100644 --- a/iOSBooks/iOSBooks/BooksList/ViewModel/BooksListViewModel.swift +++ b/iOSBooks/iOSBooks/BooksList/ViewModel/BooksListViewModel.swift @@ -41,7 +41,7 @@ class BooksListViewModel: BooksListViewModelProtocol { func cellForItem(inCollectionView collectionView: UICollectionView, atIndexPath indexPath: IndexPath) -> UICollectionViewCell { let cell: BooksCell = collectionView.dequeueReusableCell(for: indexPath) let book: Book? - var image: UIImage? = nil + var image: UIImage? if showFavorites { book = savedItems.books[indexPath.item].book image = savedItems.images[indexPath.item] diff --git a/iOSBooks/iOSBooks/Data/Endpoints/BooksAPI.swift b/iOSBooks/iOSBooks/Data/Endpoints/BooksAPI.swift index 70390e6..b88a4a7 100644 --- a/iOSBooks/iOSBooks/Data/Endpoints/BooksAPI.swift +++ b/iOSBooks/iOSBooks/Data/Endpoints/BooksAPI.swift @@ -26,7 +26,7 @@ enum BooksAPI: Endpoint { } } - var headers: [String : String]? { + var headers: [String: String]? { switch self { case .list: return nil diff --git a/iOSBooks/iOSBooks/Data/Models/BooksList.swift b/iOSBooks/iOSBooks/Data/Models/BooksList.swift index 2a2de78..d0fc590 100644 --- a/iOSBooks/iOSBooks/Data/Models/BooksList.swift +++ b/iOSBooks/iOSBooks/Data/Models/BooksList.swift @@ -10,7 +10,7 @@ import Foundation class BooksList: Codable { let items: [Item]? - let totalItems : Int? + let totalItems: Int? enum CodingKeys: String, CodingKey { case items, totalItems diff --git a/iOSBooks/iOSBooks/Data/Models/Item.swift b/iOSBooks/iOSBooks/Data/Models/Item.swift index cf2b625..b68e222 100644 --- a/iOSBooks/iOSBooks/Data/Models/Item.swift +++ b/iOSBooks/iOSBooks/Data/Models/Item.swift @@ -11,7 +11,7 @@ import Foundation class Item: Codable { var id: String? var book: Book? - var salesInfo : SalesInfo? + var salesInfo: SalesInfo? init() { id = nil