Skip to content

Commit 46154d9

Browse files
authored
No Bug - Reenable swiftlint. Fix a small number of linting errors. (#3278)
1 parent c17db92 commit 46154d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+108
-100
lines changed

.swiftlint.yml

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
disabled_rules: # rule identifiers to exclude from running
22
- variable_name
3-
- legacy_cggeometry_functions
43
- todo
54
- trailing_newline
65
- type_name
76
- function_body_length
8-
- force_try
9-
- force_cast
107
- missing_docs
118
- valid_docs
129
- cyclomatic_complexity
1310
- type_body_length
1411
- function_parameter_count
15-
- trailing_whitespace
16-
- leading_whitespace
17-
- operator_whitespace
1812
- file_length
1913
- mark
2014
- unused_closure_parameter
@@ -28,6 +22,21 @@ disabled_rules: # rule identifiers to exclude from running
2822
- shorthand_operator
2923
- trailing_comma
3024
- unused_optional_binding
25+
- private_over_fileprivate
26+
- empty_enum_arguments
27+
- discarded_notification_center_observer
28+
- block_based_kvo
29+
- nesting
30+
- is_disjoint
31+
- multiple_closures_with_trailing_closure
32+
- fallthrough
33+
- switch_case_alignment
34+
- trailing_whitespace
35+
- leading_whitespace
36+
- operator_whitespace
37+
- legacy_cggeometry_functions
38+
- unneeded_break_in_switch
39+
- closure_parameter_position
3140
opt_in_rules: # some rules are only opt-in
3241
- closing_brace
3342
- opening_brace

Account/FxAClient10.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ open class FxAClient10 {
146146
if kB.count != 32 {
147147
return nil
148148
}
149-
return kB.sha256.subdata(in: 0..<16).hexEncodedString
149+
return kB.sha256.subdata(in: 0..<16).hexEncodedString
150150
}
151151

152152
open class func quickStretchPW(_ email: Data, password: Data) -> Data {

Account/FxAState.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ func state(fromJSON json: JSON) -> FxAState? {
4747
}
4848
if let version = json["version"].int {
4949
if version == StateSchemaVersion {
50-
return stateV1(fromJSON:json)
50+
return stateV1(fromJSON: json)
5151
}
5252
}
5353
return nil
5454
}
5555

5656
func stateV1(fromJSON json: JSON) -> FxAState? {
5757
if let labelString = json["label"].string {
58-
if let label = FxAStateLabel(rawValue: labelString) {
58+
if let label = FxAStateLabel(rawValue: labelString) {
5959
switch label {
6060
case .engagedBeforeVerified:
6161
if let

Client/Application/AppDelegate.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ extension AppDelegate {
737737
FxALoginHelper.sharedInstance.apnsRegisterDidFail()
738738
}
739739

740-
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
740+
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
741741
if Logger.logPII && log.isEnabledFor(level: .info) {
742742
NSLog("APNS NOTIFICATION \(userInfo)")
743743
}
@@ -808,7 +808,7 @@ extension AppDelegate {
808808
}
809809
}
810810

811-
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
811+
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
812812
let completionHandler: (UIBackgroundFetchResult) -> Void = { _ in }
813813
self.application(application, didReceiveRemoteNotification: userInfo, fetchCompletionHandler: completionHandler)
814814
}

Client/Application/LeanplumIntegration.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ class LeanplumIntegration {
225225
return true
226226
}
227227

228-
func setUserAttributes(attributes: [AnyHashable : Any]) {
228+
func setUserAttributes(attributes: [AnyHashable: Any]) {
229229
DispatchQueue.main.async(execute: {
230230
if self.shouldSendToLP() {
231231
Leanplum.setUserAttributes(attributes)

Client/Application/QuickActions.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class QuickActions: NSObject {
102102
return true
103103
}
104104

105-
fileprivate func handleShortCutItemOfType(_ type: ShortcutType, userData: [String : NSSecureCoding]?, browserViewController: BrowserViewController) {
105+
fileprivate func handleShortCutItemOfType(_ type: ShortcutType, userData: [String: NSSecureCoding]?, browserViewController: BrowserViewController) {
106106
switch type {
107107
case .newTab:
108108
handleOpenNewTab(withBrowserViewController: browserViewController, isPrivate: false)

Client/Frontend/Browser/BackForwardTableViewCell.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class BackForwardTableViewCell: UITableViewCell {
4343
var isCurrentTab = false {
4444
didSet {
4545
if isCurrentTab {
46-
label.font = UIFont(name:"HelveticaNeue-Bold", size: BackForwardViewCellUX.fontSize)
46+
label.font = UIFont(name: "HelveticaNeue-Bold", size: BackForwardViewCellUX.fontSize)
4747
}
4848
}
4949
}
@@ -137,6 +137,6 @@ class BackForwardTableViewCell: UITableViewCell {
137137
connectingForwards = true
138138
connectingBackwards = true
139139
isCurrentTab = false
140-
label.font = UIFont(name:"HelveticaNeue", size: BackForwardViewCellUX.fontSize)
140+
label.font = UIFont(name: "HelveticaNeue", size: BackForwardViewCellUX.fontSize)
141141
}
142142
}

Client/Frontend/Browser/BrowserViewController.swift

+9-9
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ class BrowserViewController: UIViewController {
923923
webView.evaluateJavaScript("__firefox__.metadata.extractMetadata()", completionHandler: nil)
924924

925925
if #available(iOS 11, *) {
926-
if (NoImageModeHelper.isActivated(profile.prefs)) {
926+
if NoImageModeHelper.isActivated(profile.prefs) {
927927
webView.evaluateJavaScript("__firefox__.NoImageMode.setEnabled(true)", completionHandler: nil)
928928
}
929929
}
@@ -1308,7 +1308,7 @@ extension BrowserViewController: URLBarDelegate {
13081308
}
13091309

13101310
let successCallback: (String) -> Void = { (successMessage) in
1311-
SimpleToast().showAlertWithText(successMessage, bottomContainer:self.webViewContainer)
1311+
SimpleToast().showAlertWithText(successMessage, bottomContainer: self.webViewContainer)
13121312
}
13131313

13141314
guard let tab = tabManager.selectedTab, tab.url != nil else { return }
@@ -1459,7 +1459,7 @@ extension BrowserViewController: URLBarDelegate {
14591459

14601460
profile.bookmarks.getURLForKeywordSearch(possibleKeyword).uponQueue(DispatchQueue.main) { result in
14611461
if var urlString = result.successValue,
1462-
let escapedQuery = possibleQuery.addingPercentEncoding(withAllowedCharacters:NSCharacterSet.urlQueryAllowed),
1462+
let escapedQuery = possibleQuery.addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlQueryAllowed),
14631463
let range = urlString.range(of: "%s") {
14641464
urlString.replaceSubrange(range, with: escapedQuery)
14651465

@@ -1533,7 +1533,7 @@ extension BrowserViewController: TabToolbarDelegate, PhotonActionSheetProtocol {
15331533

15341534
let controller = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
15351535
controller.addAction(UIAlertAction(title: toggleActionTitle, style: .default, handler: { _ in tab.toggleDesktopSite() }))
1536-
controller.addAction(UIAlertAction(title: NSLocalizedString("Cancel", comment:"Label for Cancel button"), style: .cancel, handler: nil))
1536+
controller.addAction(UIAlertAction(title: NSLocalizedString("Cancel", comment: "Label for Cancel button"), style: .cancel, handler: nil))
15371537
controller.popoverPresentationController?.sourceView = toolbar ?? urlBar
15381538
controller.popoverPresentationController?.sourceRect = button.frame
15391539
present(controller, animated: true, completion: nil)
@@ -1553,7 +1553,7 @@ extension BrowserViewController: TabToolbarDelegate, PhotonActionSheetProtocol {
15531553

15541554
func tabToolbarDidPressMenu(_ tabToolbar: TabToolbarProtocol, button: UIButton) {
15551555
// ensure that any keyboards or spinners are dismissed before presenting the menu
1556-
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to:nil, from:nil, for:nil)
1556+
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
15571557
var actions: [[PhotonActionSheetItem]] = []
15581558

15591559
actions.append(getHomePanelActions())
@@ -2208,7 +2208,7 @@ extension BrowserViewController: UIAdaptivePresentationControllerDelegate {
22082208
extension BrowserViewController: ReaderModeStyleViewControllerDelegate {
22092209
func readerModeStyleViewController(_ readerModeStyleViewController: ReaderModeStyleViewController, didConfigureStyle style: ReaderModeStyle) {
22102210
// Persist the new style to the profile
2211-
let encodedStyle: [String:Any] = style.encodeAsDictionary()
2211+
let encodedStyle: [String: Any] = style.encodeAsDictionary()
22122212
profile.prefs.setObject(encodedStyle, forKey: ReaderModeProfileKeyStyle)
22132213
// Change the reader mode style on all tabs that have reader mode active
22142214
for tabIndex in 0..<tabManager.count {
@@ -2332,7 +2332,7 @@ extension BrowserViewController {
23322332

23332333
var readerModeStyle = DefaultReaderModeStyle
23342334
if let dict = profile.prefs.dictionaryForKey(ReaderModeProfileKeyStyle) {
2335-
if let style = ReaderModeStyle(dict: dict as [String : AnyObject]) {
2335+
if let style = ReaderModeStyle(dict: dict as [String: AnyObject]) {
23362336
readerModeStyle = style
23372337
}
23382338
}
@@ -2348,7 +2348,7 @@ extension BrowserViewController: ReaderModeBarViewDelegate {
23482348
if let readerMode = tabManager.selectedTab?.getHelper(name: "ReaderMode") as? ReaderMode, readerMode.state == ReaderModeState.active {
23492349
var readerModeStyle = DefaultReaderModeStyle
23502350
if let dict = profile.prefs.dictionaryForKey(ReaderModeProfileKeyStyle) {
2351-
if let style = ReaderModeStyle(dict: dict as [String : AnyObject]) {
2351+
if let style = ReaderModeStyle(dict: dict as [String: AnyObject]) {
23522352
readerModeStyle = style
23532353
}
23542354
}
@@ -2773,7 +2773,7 @@ extension BrowserViewController {
27732773

27742774
self.profile.searchEngines.addSearchEngine(OpenSearchEngine(engineID: nil, shortName: shortName, image: image, searchTemplate: searchQuery, suggestTemplate: nil, isCustomEngine: true))
27752775
let Toast = SimpleToast()
2776-
Toast.showAlertWithText(Strings.ThirdPartySearchEngineAdded, bottomContainer:self.webViewContainer)
2776+
Toast.showAlertWithText(Strings.ThirdPartySearchEngineAdded, bottomContainer: self.webViewContainer)
27772777
}
27782778
}
27792779

Client/Frontend/Browser/ButtonToast.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class ButtonToast: UIView {
8585
button.titleLabel?.adjustsFontSizeToFitWidth = true
8686
button.titleLabel?.minimumScaleFactor = 0.1
8787

88-
let recognizer = UITapGestureRecognizer(target: self, action:#selector(ButtonToast.buttonPressed(_:)))
88+
let recognizer = UITapGestureRecognizer(target: self, action: #selector(ButtonToast.buttonPressed(_:)))
8989
button.addGestureRecognizer(recognizer)
9090
toast.addSubview(button)
9191
var descriptionLabel: UILabel?

Client/Frontend/Browser/ContextMenuHelper.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ extension ContextMenuHelper: TabHelper {
7171
}
7272

7373
func userContentController(_ userContentController: WKUserContentController, didReceiveScriptMessage message: WKScriptMessage) {
74-
guard let data = message.body as? [String : AnyObject] else {
74+
guard let data = message.body as? [String: AnyObject] else {
7575
return
7676
}
7777

Client/Frontend/Browser/MailtoLinkHandler.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import UIKit
77

88
open class MailtoLinkHandler {
99

10-
lazy var mailSchemeProviders: [String:MailProvider] = self.fetchMailSchemeProviders()
10+
lazy var mailSchemeProviders: [String: MailProvider] = self.fetchMailSchemeProviders()
1111

1212
func launchMailClientForScheme(_ scheme: String, metadata: MailToMetadata, defaultMailtoURL: URL) {
1313
guard let provider = mailSchemeProviders[scheme], let mailURL = provider.newEmailURLFromMetadata(metadata) else {
@@ -22,7 +22,7 @@ open class MailtoLinkHandler {
2222
}
2323
}
2424

25-
func fetchMailSchemeProviders() -> [String:MailProvider] {
25+
func fetchMailSchemeProviders() -> [String: MailProvider] {
2626
var providerDict = [String: MailProvider]()
2727
if let path = Bundle.main.path(forResource: "MailSchemes", ofType: "plist"), let dictRoot = NSArray(contentsOfFile: path) {
2828
dictRoot.forEach({ dict in

Client/Frontend/Browser/QRCodeViewController.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class QRCodeViewController: UIViewController, AVCaptureMetadataOutputObjectsDele
5656
// Setup the NavigationBar
5757
self.navigationController?.navigationBar.barTintColor = QRCodeViewControllerUX.navigationBarBackgroundColor
5858
let navigationTitleAttribute: NSDictionary = NSDictionary(object: QRCodeViewControllerUX.navigationBarTitleColor, forKey: NSForegroundColorAttributeName as NSCopying)
59-
self.navigationController?.navigationBar.titleTextAttributes = (navigationTitleAttribute as! [String : AnyObject])
59+
self.navigationController?.navigationBar.titleTextAttributes = (navigationTitleAttribute as! [String: AnyObject])
6060

6161
// Setup the NavigationItem
6262
self.navigationItem.leftBarButtonItem = UIBarButtonItem(image: UIImage(named: "qrcode-goBack"), style: UIBarButtonItemStyle.plain, target: self, action: #selector(goBack))
@@ -85,7 +85,7 @@ class QRCodeViewController: UIViewController, AVCaptureMetadataOutputObjectsDele
8585
self.view.addSubview(scanLine)
8686
self.view.addSubview(instructionsLabel)
8787

88-
scanRange = UIDevice.current.userInterfaceIdiom == .pad ? CGRect(x: 0, y: 0, width: view.frame.width / 2, height: view.frame.width / 2) : CGRect(x: 0, y: 0, width: view.frame.width / 3 * 2, height: view.frame.width / 3 * 2)
88+
scanRange = UIDevice.current.userInterfaceIdiom == .pad ? CGRect(x: 0, y: 0, width: view.frame.width / 2, height: view.frame.width / 2) : CGRect(x: 0, y: 0, width: view.frame.width / 3 * 2, height: view.frame.width / 3 * 2)
8989

9090
scanRange.center = UIScreen.main.bounds.center
9191
scanBorderHeight = UIDevice.current.userInterfaceIdiom == .pad ? view.frame.width / 2 : view.frame.width / 3 * 2

Client/Frontend/Browser/TabManager.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ extension TabManager {
809809
}
810810
}
811811

812-
extension TabManager : WKNavigationDelegate {
812+
extension TabManager: WKNavigationDelegate {
813813
func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
814814
UIApplication.shared.isNetworkActivityIndicatorVisible = true
815815
}

Client/Frontend/Browser/TabPeekViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class TabPeekViewController: UIViewController, WKNavigationDelegate {
6363
actions.append(UIPreviewAction(title: TabPeekViewController.PreviewActionCopyURL, style: .default) { previewAction, viewController in
6464
guard let url = self.tab?.canonicalURL else { return }
6565
UIPasteboard.general.url = url
66-
SimpleToast().showAlertWithText(Strings.AppMenuCopyURLConfirmMessage, bottomContainer:self.view)
66+
SimpleToast().showAlertWithText(Strings.AppMenuCopyURLConfirmMessage, bottomContainer: self.view)
6767
})
6868
}
6969
}

Client/Frontend/Browser/TabScrollController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class TabScrollingController: NSObject {
116116
completion: completion)
117117
}
118118

119-
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
119+
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey: Any]?, context: UnsafeMutableRawPointer?) {
120120
if keyPath == "contentSize" {
121121
if !checkScrollHeightIsLargeEnoughForScrolling() && !toolbarsShowing {
122122
showToolbars(animated: true, completion: nil)

Client/Frontend/Browser/TabTrayController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ extension TabTrayController: PhotonActionSheetProtocol {
686686
func didTapDelete(_ sender: UIButton) {
687687
let controller = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
688688
controller.addAction(UIAlertAction(title: Strings.AppMenuCloseAllTabsTitleString, style: .default, handler: { _ in self.closeTabsForCurrentTray() }))
689-
controller.addAction(UIAlertAction(title: NSLocalizedString("Cancel", comment:"Label for Cancel button"), style: .cancel, handler: nil))
689+
controller.addAction(UIAlertAction(title: NSLocalizedString("Cancel", comment: "Label for Cancel button"), style: .cancel, handler: nil))
690690
controller.popoverPresentationController?.sourceView = sender
691691
controller.popoverPresentationController?.sourceRect = sender.bounds
692692
present(controller, animated: true, completion: nil)

Client/Frontend/Browser/TopTabsLayout.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class TopTabsLayoutDelegate: NSObject, UICollectionViewDelegateFlowLayout {
3838
}
3939

4040
class TopTabsViewLayout: UICollectionViewFlowLayout {
41-
var decorationAttributeArr: [Int : UICollectionViewLayoutAttributes?] = [:]
41+
var decorationAttributeArr: [Int: UICollectionViewLayoutAttributes?] = [:]
4242
let separatorYOffset = TopTabsUX.SeparatorYOffset
4343
let separatorSize = TopTabsUX.SeparatorHeight
4444
let SeparatorZIndex = -2 ///Prevent the header/footer from appearing above the Tabs

Client/Frontend/Browser/TopTabsViews.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ class TopTabCell: UICollectionViewCell {
7474

7575
var selectedTab = false {
7676
didSet {
77-
backgroundColor = selectedTab ? UIColor(rgb:0xf9f9fa) : UIColor(rgb: 0x272727)
78-
titleText.textColor = selectedTab ? UIColor(rgb:0x0c0c0d) : UIColor(rgb: 0xb1b1b3)
77+
backgroundColor = selectedTab ? UIColor(rgb: 0xf9f9fa) : UIColor(rgb: 0x272727)
78+
titleText.textColor = selectedTab ? UIColor(rgb: 0x0c0c0d) : UIColor(rgb: 0xb1b1b3)
7979
highlightLine.isHidden = !selectedTab
8080
closeButton.tintColor = selectedTab ? UIColor(rgb: 0x272727) : UIColor(rgb: 0xb1b1b3)
8181
// restyle if we are in PBM
@@ -122,7 +122,7 @@ class TopTabCell: UICollectionViewCell {
122122

123123
let highlightLine: UIView = {
124124
let line = UIView()
125-
line.backgroundColor = UIColor(rgb:0x0066DC)
125+
line.backgroundColor = UIColor(rgb: 0x0066DC)
126126
line.isHidden = true
127127
return line
128128
}()
@@ -173,7 +173,7 @@ class TopTabCell: UICollectionViewCell {
173173
case Style.light:
174174
titleText.textColor = UIColor.darkText
175175
backgroundColor = UIConstants.AppBackgroundColor
176-
highlightLine.backgroundColor = UIColor(rgb:0x0066DC)
176+
highlightLine.backgroundColor = UIColor(rgb: 0x0066DC)
177177
case Style.dark:
178178
titleText.textColor = UIColor.lightText
179179
backgroundColor = UIColor(rgb: 0x38383D)

Client/Frontend/Browser/URLBarView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ extension URLBarView: Themeable {
673673

674674
let isPrivate = themeName == Theme.PrivateMode
675675

676-
progressBar.setGradientColors(startColor: UIConstants.LoadingStartColor.color(isPBM: isPrivate), endColor:UIConstants.LoadingEndColor.color(isPBM: isPrivate))
676+
progressBar.setGradientColors(startColor: UIConstants.LoadingStartColor.color(isPBM: isPrivate), endColor: UIConstants.LoadingEndColor.color(isPBM: isPrivate))
677677
currentTheme = themeName
678678
locationBorderColor = theme.borderColor!
679679
locationActiveBorderColor = theme.activeBorderColor!

Client/Frontend/ContentBlocker/ContentBlockerHelper.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ContentBlockerHelper {
1818
fileprivate weak var tab: Tab?
1919
fileprivate weak var profile: Profile?
2020

21-
static var blockImagesRule: WKContentRuleList? = nil
21+
static var blockImagesRule: WKContentRuleList?
2222

2323
// Raw values are stored to prefs, be careful changing them.
2424
enum EnabledState: String {
@@ -92,7 +92,7 @@ class ContentBlockerHelper {
9292
}
9393
}
9494

95-
let blockImages = "[{'trigger':{'url-filter':'.*','resource-type':['image']},'action':{'type':'block'}}]".replacingOccurrences(of: "'", with:"\"")
95+
let blockImages = "[{'trigger':{'url-filter':'.*','resource-type':['image']},'action':{'type':'block'}}]".replacingOccurrences(of: "'", with: "\"")
9696
ruleStore.compileContentRuleList(forIdentifier: "images", encodedContentRuleList: blockImages) {
9797
rule, error in
9898
assert(rule != nil && error == nil)

0 commit comments

Comments
 (0)