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 file_length and type_body_length adjusted #659

Merged
merged 7 commits into from
Aug 6, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
6 changes: 5 additions & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ disabled_rules:
- block_based_kvo
- compiler_protocol_init
- unused_setter_value
- line_length

opt_in_rules:
- file_header
Expand Down Expand Up @@ -37,8 +38,11 @@ type_name:
warning: 80
error: 100
file_length:
warning: 700
warning: 1200
error: 1200
type_body_length:
warning: 500
error: 500
nesting:
type_level: 2
file_header:
Expand Down
2 changes: 0 additions & 2 deletions DuckDuckGo/Bookmarks/Services/BookmarkStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ protocol BookmarkStore {

}

// swiftlint:disable type_body_length
final class LocalBookmarkStore: BookmarkStore {

init() {}
Expand Down Expand Up @@ -582,4 +581,3 @@ fileprivate extension BookmarkManagedObject {
}

}
// swiftlint:enable type_body_length
1 change: 0 additions & 1 deletion DuckDuckGo/Browser Tab/Model/Tab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ protocol TabDelegate: FileDownloadManagerDelegate, ContentOverlayUserScriptDeleg
func tab(_ tab: Tab, promptUserForCookieConsent result: @escaping (Bool) -> Void)
}

// swiftlint:disable type_body_length
// swiftlint:disable file_length
final class Tab: NSObject, Identifiable, ObservableObject {

Expand Down
4 changes: 0 additions & 4 deletions DuckDuckGo/Browser Tab/View/BrowserTabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ protocol BrowserTabViewControllerClickDelegate: AnyObject {
func browserTabViewController(_ browserTabViewController: BrowserTabViewController, didClickAtPoint: CGPoint)
}

// swiftlint:disable file_length
// swiftlint:disable:next type_body_length
final class BrowserTabViewController: NSViewController {

@IBOutlet weak var errorView: NSView!
Expand Down Expand Up @@ -1197,5 +1195,3 @@ extension BrowserTabViewController {
}
}
}

// swiftlint:enable file_length
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ protocol FirefoxEncryptionKeyReading {

}

// swiftlint:disable:next type_body_length
final class FirefoxEncryptionKeyReader: FirefoxEncryptionKeyReading {

func getEncryptionKey(key3DatabaseURL: URL, primaryPassword: String) -> Result<Data, FirefoxLoginReader.ImportError> {
Expand Down
2 changes: 0 additions & 2 deletions DuckDuckGo/Data Import/View/DataImportViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import BrowserServicesKit
import Combine
import os.log

// swiftlint:disable type_body_length
final class DataImportViewController: NSViewController {

enum Constants {
Expand Down Expand Up @@ -453,7 +452,6 @@ final class DataImportViewController: NSViewController {
}

}
// swiftlint:enable type_body_length

extension DataImportViewController: FileImportViewControllerDelegate {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import Cocoa
import Combine

// swiftlint:disable type_body_length
final class FeedbackViewController: NSViewController {

enum Constants {
Expand Down Expand Up @@ -325,7 +324,6 @@ final class FeedbackViewController: NSViewController {
thankYouView.isHidden = false
}
}
// swiftlint:enable type_body_length

fileprivate extension WebsiteBreakage.Category {

Expand Down
1 change: 0 additions & 1 deletion DuckDuckGo/Main/View/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import Carbon.HIToolbox
import Combine
import os.log

// swiftlint:disable type_body_length
final class MainViewController: NSViewController {

@IBOutlet weak var tabBarContainerView: NSView!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ protocol AddressBarButtonsViewControllerDelegate: AnyObject {

}

// swiftlint:disable type_body_length
// swiftlint:disable file_length
// swiftlint:disable:next type_body_length
final class AddressBarButtonsViewController: NSViewController {

static let homeFaviconImage = NSImage(named: "Search")
Expand Down Expand Up @@ -914,7 +913,6 @@ final class AddressBarButtonsViewController: NSViewController {
}

}
// swiftlint:enable type_body_length

extension AddressBarButtonsViewController: PermissionContextMenuDelegate {

Expand Down Expand Up @@ -975,6 +973,3 @@ final class TrackerAnimationImageProvider: AnimationImageProvider {
}

}

// swiftlint:enable type_body_length
// swiftlint:enable file_length
6 changes: 0 additions & 6 deletions DuckDuckGo/Navigation Bar/View/AddressBarTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ import Combine
import os.log
import BrowserServicesKit

// swiftlint:disable file_length
// swiftlint:disable type_body_length

protocol AddressBarTextFieldDelegate: AnyObject {

func adressBarTextField(_ addressBarTextField: AddressBarTextField, didChangeValue value: AddressBarTextField.Value)
Expand Down Expand Up @@ -1079,6 +1076,3 @@ final class AddressBarTextFieldCell: NSTextFieldCell {
fileprivate extension NSStoryboard {
static let suggestion = NSStoryboard(name: "Suggestion", bundle: .main)
}

// swiftlint:enable type_body_length
// swiftlint:enable file_length
2 changes: 0 additions & 2 deletions DuckDuckGo/Navigation Bar/View/AddressBarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import os.log
import Combine
import Lottie

// swiftlint:disable type_body_length
final class AddressBarViewController: NSViewController {

@IBOutlet weak var addressBarTextField: AddressBarTextField!
Expand Down Expand Up @@ -354,7 +353,6 @@ final class AddressBarViewController: NSViewController {
}

}
// swiftlint:enable type_body_length

extension AddressBarViewController {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import Combine
import os.log
import BrowserServicesKit

// swiftlint:disable type_body_length file_length
final class NavigationBarViewController: NSViewController {

enum Constants {
Expand Down Expand Up @@ -625,7 +624,6 @@ final class NavigationBarViewController: NSViewController {
}

}
// swiftlint:enable type_body_length

extension NavigationBarViewController: OptionsButtonMenuDelegate {

Expand Down
1 change: 0 additions & 1 deletion DuckDuckGo/Permissions/Model/PermissionModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import WebKit
import AVFoundation
import CoreLocation

// swiftlint:disable:next type_body_length
final class PermissionModel {

@PublishedAfter var permissions = Permissions()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import Foundation

// swiftlint:disable line_length
extension UserText {

static let pmSaveCredentialsEditableTitle = NSLocalizedString("pm.save-credentials.editable.title", value: "Save Login?", comment: "Title for the editable Save Credentials popover")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,14 @@ import Combine
import SwiftUI
import BrowserServicesKit

// swiftlint:disable file_length

protocol PasswordManagementDelegate: AnyObject {

/// May not be called on main thread.
func shouldClosePasswordManagementViewController(_: PasswordManagementViewController)

}

// swiftlint:disable type_body_length
// swiftlint:disable:next type_body_length
final class PasswordManagementViewController: NSViewController {

static func create() -> Self {
Expand Down Expand Up @@ -926,5 +924,3 @@ extension PasswordManagementViewController: NSTextViewDelegate {
}

}

// swiftlint:enable file_length
3 changes: 0 additions & 3 deletions DuckDuckGo/Tab Bar/View/TabBarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ import Combine
import Lottie
import SwiftUI

// swiftlint:disable file_length
// swiftlint:disable type_body_length

final class TabBarViewController: NSViewController {

enum HorizontalSpace: CGFloat {
Expand Down
2 changes: 0 additions & 2 deletions DuckDuckGo/Tab Bar/ViewModel/TabCollectionViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ protocol TabCollectionViewModelDelegate: AnyObject {

}

// swiftlint:disable type_body_length
final class TabCollectionViewModel: NSObject {

weak var delegate: TabCollectionViewModelDelegate?
Expand Down Expand Up @@ -652,4 +651,3 @@ extension TabCollectionViewModel {
return history
}
}
// swiftlint:enable type_body_length
2 changes: 0 additions & 2 deletions Unit Tests/AutoconsentMessageProtocolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,9 @@ class AutoconsentMessageProtocolTests: XCTestCase {
userScript.handleMessage(
replyHandler: {(msg: Any?, _: String?) in
expect.fulfill()
// swiftlint:disable line_length
XCTAssertEqual(self.replyToJson(msg: msg!), """
{"config":{"autoAction":"optOut","detectRetries":20,"disabledCmps":[],"enabled":true,"enablePrehide":true},"rules":null,"type":"initResp"}
""")
// swiftlint:enable line_length
},
message: message
)
Expand Down
2 changes: 0 additions & 2 deletions Unit Tests/File Download/DownloadListCoordinatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import Foundation
import XCTest
@testable import DuckDuckGo_Privacy_Browser

// swiftlint:disable type_body_length
@available(macOS 11.3, *)
final class DownloadListCoordinatorTests: XCTestCase {
let store = DownloadListStoreMock()
Expand Down Expand Up @@ -437,7 +436,6 @@ final class DownloadListCoordinatorTests: XCTestCase {
}

}
// swiftlint:enable type_body_length

private struct TestError: Error, Equatable {}
private extension Data {
Expand Down
5 changes: 0 additions & 5 deletions Unit Tests/Geolocation/GeolocationProviderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import CoreLocation
import WebKit
@testable import DuckDuckGo_Privacy_Browser

// swiftlint:disable file_length
// swiftlint:disable type_body_length
// swiftlint:disable function_body_length
final class GeolocationProviderTests: XCTestCase {

Expand Down Expand Up @@ -659,7 +657,6 @@ final class GeolocationProviderTests: XCTestCase {
}

}
// swiftlint:enable type_body_length
// swiftlint:enable function_body_length

extension GeolocationProviderTests: WKUIDelegate {
Expand Down Expand Up @@ -769,5 +766,3 @@ extension CLLocation {
}
}
}

// swiftlint:enable file_length
6 changes: 1 addition & 5 deletions Unit Tests/Permissions/PermissionModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ import Combine
import AVFoundation
@testable import DuckDuckGo_Privacy_Browser

// swiftlint:disable file_length
// swiftlint:disable type_body_length
// swiftlint:disable:next type_body_length
final class PermissionModelTests: XCTestCase {

let permissionManagerMock = PermissionManagerMock()
Expand Down Expand Up @@ -1151,6 +1150,3 @@ extension PermissionModelTests: WebViewPermissionsDelegate {
}

}

// swiftlint:enable type_body_length
// swiftlint:enable file_length
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import XCTest
@testable import DuckDuckGo_Privacy_Browser

// MARK: - Tests for TabCollectionViewModel with PinnedTabsManager but without pinned tabs

// swiftlint:disable:next type_body_length
final class TabCollectionViewModelTests: XCTestCase {

// MARK: - TabViewModel
Expand Down