diff --git a/.swiftlint.yml b/.swiftlint.yml index 97edbdbcf..cec9a4f51 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -10,3 +10,9 @@ opt_in_rules: - opening_brace - trailing_semicolon - file_header +cyclomatic_complexity: 15 +line_length: 135 +file_length: + warning: 450 +function_body_length: + warning: 60 diff --git a/Lockbox.xcodeproj/project.pbxproj b/Lockbox.xcodeproj/project.pbxproj index 4eb4c363d..0aa327b5d 100644 --- a/Lockbox.xcodeproj/project.pbxproj +++ b/Lockbox.xcodeproj/project.pbxproj @@ -12,7 +12,6 @@ 2C2EC56220ADAB1D00AF8C44 /* LockBoxScreenGraph.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C2EC56120ADAB1D00AF8C44 /* LockBoxScreenGraph.swift */; }; 2C2EC56420ADAB5400AF8C44 /* BaseTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C2EC56320ADAB5400AF8C44 /* BaseTestCase.swift */; }; 391233682090E52800CB0233 /* Account.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 39DB3677208E2A800026DA92 /* Account.framework */; }; - 3912336A2090E52800CB0233 /* Deferred.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 39B1508820878E42007497E5 /* Deferred.framework */; }; 3912336E2090E52800CB0233 /* FxA.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 39DB367D208E2F8F0026DA92 /* FxA.framework */; }; 391233732090E56F00CB0233 /* SwiftyJSON.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 391233712090E56E00CB0233 /* SwiftyJSON.framework */; }; 391233752090E56F00CB0233 /* SwiftKeychainWrapper.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 391233722090E56E00CB0233 /* SwiftKeychainWrapper.framework */; }; @@ -477,7 +476,6 @@ 391233812090E60A00CB0233 /* XCGLogger.framework in Frameworks */, 39DB366D208E25710026DA92 /* FxAUtils.framework in Frameworks */, 391233782090E5A300CB0233 /* Shared.framework in Frameworks */, - 3912336A2090E52800CB0233 /* Deferred.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -913,7 +911,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0930; - LastUpgradeCheck = 0930; + LastUpgradeCheck = 0940; ORGANIZATIONNAME = Mozilla; TargetAttributes = { 2C2EC55120ADA85A00AF8C44 = { diff --git a/Lockbox.xcodeproj/xcshareddata/xcschemes/lockbox.xcscheme b/Lockbox.xcodeproj/xcshareddata/xcschemes/lockbox.xcscheme index e68603b38..8059f72a8 100644 --- a/Lockbox.xcodeproj/xcshareddata/xcschemes/lockbox.xcscheme +++ b/Lockbox.xcodeproj/xcshareddata/xcschemes/lockbox.xcscheme @@ -1,6 +1,6 @@ #import + +#endif diff --git a/lockbox-ios/Presenter/ItemListPresenter.swift b/lockbox-ios/Presenter/ItemListPresenter.swift index 69a7c1190..6ea021704 100644 --- a/lockbox-ios/Presenter/ItemListPresenter.swift +++ b/lockbox-ios/Presenter/ItemListPresenter.swift @@ -266,7 +266,7 @@ extension ItemListPresenter { filterTextObservable: Observable, itemSortObservable: Observable, syncStateObservable: Observable, - storageStateObservable: Observable) -> Driver<[ItemSectionModel]> { // swiftlint:disable:this line_length + storageStateObservable: Observable) -> Driver<[ItemSectionModel]> { let throttledListObservable = loginListObservable .throttle(1.0, scheduler: ConcurrentMainScheduler.instance) let throttledSyncStateObservable = syncStateObservable @@ -281,7 +281,7 @@ extension ItemListPresenter { throttledSyncStateObservable, throttledStorageStateObservable ) - .map { (latest: ([Login], ItemListFilterAction, ItemListSortSetting, SyncState, LoginStoreState)) -> LoginListTextSort in // swiftlint:disable:this line_length + .map { (latest: ([Login], ItemListFilterAction, ItemListSortSetting, SyncState, LoginStoreState)) -> LoginListTextSort in return LoginListTextSort( logins: latest.0, text: latest.1.filteringText, diff --git a/lockbox-ios/Presenter/WelcomePresenter.swift b/lockbox-ios/Presenter/WelcomePresenter.swift index 6d301678b..e43c1b1b5 100644 --- a/lockbox-ios/Presenter/WelcomePresenter.swift +++ b/lockbox-ios/Presenter/WelcomePresenter.swift @@ -165,7 +165,7 @@ extension WelcomePresenter { return Single.just(()) } - return target.biometryManager.authenticateWithMessage(latest?.email ?? Constant.string.unlockPlaceholder) // swiftlint:disable:this line_length + return target.biometryManager.authenticateWithMessage(latest?.email ?? Constant.string.unlockPlaceholder) .catchError { _ in // ignore errors from local authentication return Observable.never().asSingle() diff --git a/lockbox-ios/Store/DataStore.swift b/lockbox-ios/Store/DataStore.swift index ed500093a..f1ff2bee8 100644 --- a/lockbox-ios/Store/DataStore.swift +++ b/lockbox-ios/Store/DataStore.swift @@ -110,7 +110,7 @@ class DataStore { return self.storageStateSubject.asObservable() } - init(dispatcher: Dispatcher = Dispatcher.shared, // swiftlint:disable:this function_body_length + init(dispatcher: Dispatcher = Dispatcher.shared, profileFactory: @escaping ProfileFactory = defaultProfileFactory, fxaLoginHelper: FxALoginHelper = FxALoginHelper.sharedInstance, keychainWrapper: KeychainWrapper = KeychainWrapper.standard) { diff --git a/lockbox-ios/View/ItemDetailView.swift b/lockbox-ios/View/ItemDetailView.swift index 5cd9cb3ed..55e147c40 100644 --- a/lockbox-ios/View/ItemDetailView.swift +++ b/lockbox-ios/View/ItemDetailView.swift @@ -126,7 +126,7 @@ extension ItemDetailView: UIGestureRecognizerDelegate { fileprivate func setupDataSource() { self.dataSource = RxTableViewSectionedReloadDataSource( configureCell: { _, tableView, _, cellConfiguration in - guard let cell = tableView.dequeueReusableCell(withIdentifier: "itemdetailcell") as? ItemDetailCell else { // swiftlint:disable:this line_length + guard let cell = tableView.dequeueReusableCell(withIdentifier: "itemdetailcell") as? ItemDetailCell else { fatalError("couldn't find the right cell!") } diff --git a/lockbox-ios/View/ItemListView.swift b/lockbox-ios/View/ItemListView.swift index e37425d5c..4c2ccb210 100644 --- a/lockbox-ios/View/ItemListView.swift +++ b/lockbox-ios/View/ItemListView.swift @@ -172,7 +172,7 @@ extension ItemListView { retCell = cell case .Item(let title, let username, _): - guard let cell = tableView.dequeueReusableCell(withIdentifier: "itemlistcell") as? ItemListCell else { // swiftlint:disable:this line_length + guard let cell = tableView.dequeueReusableCell(withIdentifier: "itemlistcell") as? ItemListCell else { fatalError("couldn't find the right cell!") } diff --git a/lockbox-ios/View/RootView.swift b/lockbox-ios/View/RootView.swift index 89739aff7..2c6308b55 100644 --- a/lockbox-ios/View/RootView.swift +++ b/lockbox-ios/View/RootView.swift @@ -1,6 +1,7 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + // swiftlint:disable line_length import UIKit @@ -78,7 +79,7 @@ class RootView: UIViewController, RootViewProtocol { case .fxa: self.currentViewController?.pushViewController(FxAView(), animated: true) case .onboardingConfirmation: - if let onboardingConfirmationView = UIStoryboard(name: "OnboardingConfirmation", bundle: nil).instantiateViewController(withIdentifier: "onboardingconfirmation") as? OnboardingConfirmationView { // swiftlint:disable:this line_length + if let onboardingConfirmationView = UIStoryboard(name: "OnboardingConfirmation", bundle: nil).instantiateViewController(withIdentifier: "onboardingconfirmation") as? OnboardingConfirmationView { self.currentViewController?.pushViewController(onboardingConfirmationView, animated: true) } } @@ -89,7 +90,7 @@ class RootView: UIViewController, RootViewProtocol { case .list: self.currentViewController?.popToRootViewController(animated: true) case .detail(let id): - if let itemDetailView = UIStoryboard(name: "ItemDetail", bundle: nil).instantiateViewController(withIdentifier: "itemdetailview") as? ItemDetailView { // swiftlint:disable:this line_length + if let itemDetailView = UIStoryboard(name: "ItemDetail", bundle: nil).instantiateViewController(withIdentifier: "itemdetailview") as? ItemDetailView { itemDetailView.itemId = id self.currentViewController?.pushViewController(itemDetailView, animated: true) } @@ -101,7 +102,7 @@ class RootView: UIViewController, RootViewProtocol { case .list: self.currentViewController?.popToRootViewController(animated: true) case .account: - if let accountSettingView = UIStoryboard(name: "AccountSetting", bundle: nil).instantiateViewController(withIdentifier: "accountsetting") as? AccountSettingView { // swiftlint:disable:this line_length + if let accountSettingView = UIStoryboard(name: "AccountSetting", bundle: nil).instantiateViewController(withIdentifier: "accountsetting") as? AccountSettingView { self.currentViewController?.pushViewController(accountSettingView, animated: true) } case .autoLock: diff --git a/lockbox-ios/View/WelcomeView.swift b/lockbox-ios/View/WelcomeView.swift index 09c79387f..7cda7c46c 100644 --- a/lockbox-ios/View/WelcomeView.swift +++ b/lockbox-ios/View/WelcomeView.swift @@ -77,7 +77,7 @@ extension WelcomeView: WelcomeViewProtocol { public var firstTimeLearnMoreHidden: AnyObserver { return self.learnMore.rx.isHidden.asObserver() } - + public var firstTimeLearnMoreArrowHidden: AnyObserver { return self.learnMoreImage.rx.isHidden.asObserver() } diff --git a/lockbox-iosTests/SettingListPresenterSpec.swift b/lockbox-iosTests/SettingListPresenterSpec.swift index f4305056f..73ce714ee 100644 --- a/lockbox-iosTests/SettingListPresenterSpec.swift +++ b/lockbox-iosTests/SettingListPresenterSpec.swift @@ -90,7 +90,7 @@ class SettingsPresenterSpec: QuickSpec { beforeEach { self.view = FakeSettingsView() self.view.itemsObserver = self.scheduler.createObserver([SettingSectionModel].self) - + self.routeActionHandler = FakeRouteActionHandler() self.settingActionHandler = FakeSettingActionHandler() self.dataStoreActionHandler = FakeDataStoreActionHandler()