Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Commit 1422fe4

Browse files
authored
Turn SwiftLint back on (#738)
* Uncomment the SwiftLint script. * Ignore comments for line length warnings. Xcode’s font used for comments is not monospaced, so comments can hit this limit very easily even though they don’t take up much horizontal space. * Fix all SwiftLint warnings. * Introduce some deliberate SwiftLint violations. * Revert deliberate SwiftLint violations, CI failed successfully.
1 parent e002e0a commit 1422fe4

22 files changed

Lines changed: 55 additions & 50 deletions

‎.swiftlint.yml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ disabled_rules:
33
- trailing_whitespace
44

55
# Rule Config
6-
line_length: 150
6+
line_length:
7+
warning: 150
8+
ignores_comments: true
79
identifier_name:
810
min_length: 1
911
max_length:

‎Core/ContentBlockerRulesManager.swift‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
// limitations under the License.
1818
//
1919

20-
2120
import Foundation
2221
import WebKit
2322
import os.log
@@ -50,7 +49,8 @@ public class ContentBlockerRulesManager {
5049
}
5150

5251
if let store = WKContentRuleListStore.default() {
53-
store.compileContentRuleList(forIdentifier: "tds", encodedContentRuleList: String(data: data, encoding: .utf8)!) { [weak self] ruleList, error in
52+
let ruleList = String(data: data, encoding: .utf8)!
53+
store.compileContentRuleList(forIdentifier: "tds", encodedContentRuleList: ruleList) { [weak self] ruleList, error in
5454
self?.blockingRules = ruleList
5555
completion?(ruleList)
5656
if let error = error {

‎Core/ContentBlockerRulesUserScript.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class ContentBlockerRulesUserScript: NSObject, UserScript {
3434
+ (storageCache?.fileStore.loadAsString(forConfiguration: .temporaryUnprotectedSites) ?? "")
3535

3636
return loadJS("contentblockerrules", withReplacements: [
37-
"${unprotectedDomains}": unprotectedDomains,
37+
"${unprotectedDomains}": unprotectedDomains
3838
])
3939
}
4040

‎Core/DoNotSellUserScript.swift‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
//
2-
// DoNotSellUserScript.swift
3-
// DuckDuckGo
4-
//
5-
// Copyright © 2020 DuckDuckGo. All rights reserved.
6-
//
7-
// Licensed under the Apache License, Version 2.0 (the "License");
8-
// you may not use this file except in compliance with the License.
9-
// You may obtain a copy of the License at
10-
//
11-
// http://www.apache.org/licenses/LICENSE-2.0
12-
//
13-
// Unless required by applicable law or agreed to in writing, software
14-
// distributed under the License is distributed on an "AS IS" BASIS,
15-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16-
// See the License for the specific language governing permissions and
17-
// limitations under the License.
18-
//
1+
//
2+
// DoNotSellUserScript.swift
3+
// DuckDuckGo
4+
//
5+
// Copyright © 2020 DuckDuckGo. All rights reserved.
6+
//
7+
// Licensed under the Apache License, Version 2.0 (the "License");
8+
// you may not use this file except in compliance with the License.
9+
// You may obtain a copy of the License at
10+
//
11+
// http://www.apache.org/licenses/LICENSE-2.0
12+
//
13+
// Unless required by applicable law or agreed to in writing, software
14+
// distributed under the License is distributed on an "AS IS" BASIS,
15+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
// See the License for the specific language governing permissions and
17+
// limitations under the License.
18+
//
1919

2020
import UIKit
2121
import WebKit

‎Core/NavigatorSharePatchUserScript.swift‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,5 @@ public class NavigatorSharePatchUserScript: NSObject, UserScript {
3434
public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
3535

3636
}
37-
3837

3938
}

‎Core/Pixel.swift‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import Foundation
2121
import os.log
2222

23+
// swiftlint:disable identifier_name
2324
public enum PixelName: String {
2425

2526
case appLaunch = "ml"
@@ -237,6 +238,7 @@ public enum PixelName: String {
237238

238239
case backgroundTaskSubmissionFailed = "m_bt_rf"
239240
}
241+
// swiftlint:enable identifier_name
240242

241243
public struct PixelParameters {
242244
public static let url = "url"

‎Core/VariantManager.swift‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public struct Variant {
3535
static let notPadDevice = { return !Self.padDevice() }
3636

3737
static let inRequiredCountry = { return ["AU", "AT", "DK", "FI", "FR", "DE", "IT", "IE", "NZ", "NO", "ES", "SE", "GB"]
38-
.contains(where: { Locale.current.regionCode == $0 } ) }
38+
.contains(where: { Locale.current.regionCode == $0 }) }
3939
}
4040

4141
static let doNotAllocate = 0
@@ -46,7 +46,7 @@ public struct Variant {
4646
// SERP testing
4747
Variant(name: "sc", weight: 1, isIncluded: When.inRequiredCountry, features: []),
4848
Variant(name: "sd", weight: doNotAllocate, isIncluded: When.always, features: []),
49-
Variant(name: "se", weight: 1, isIncluded: When.inRequiredCountry, features: []),
49+
Variant(name: "se", weight: 1, isIncluded: When.inRequiredCountry, features: [])
5050

5151
]
5252

‎DuckDuckGo.xcodeproj/project.pbxproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3588,7 +3588,7 @@
35883588
);
35893589
runOnlyForDeploymentPostprocessing = 0;
35903590
shellPath = /bin/sh;
3591-
shellScript = "# if which swiftlint >/dev/null; then\n# if [ ! -z \"$BITRISE_PROJECT_PATH\" ] || [ \"$CONFIGURATION\" = \"Release\" ]; then\n# swiftlint lint --strict\n# if [ $? -ne 0 ]; then\n# echo \"error: SwiftLint validation failed.\"\n# exit 1\n# fi\n# else\n# swiftlint lint\n# fi\n# else\n# echo \"error: SwiftLint not installed. Install using \\`brew install swiftlint\\`\"\n# exit 1\n# fi\n";
3591+
shellScript = "if which swiftlint >/dev/null; then\n if [ ! -z \"$BITRISE_PROJECT_PATH\" ] || [ \"$CONFIGURATION\" = \"Release\" ]; then\n swiftlint lint --strict\n if [ $? -ne 0 ]; then\n echo \"error: SwiftLint validation failed.\"\n exit 1\n fi\n else\n swiftlint lint\n fi\nelse\n echo \"error: SwiftLint not installed. Install using \\`brew install swiftlint\\`\"\n exit 1\nfi\n";
35923592
};
35933593
85F4D03A1F44A7BE0018BFD5 /* Install Fonts */ = {
35943594
isa = PBXShellScriptBuildPhase;

‎DuckDuckGo/DaxDialogs.swift‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,9 @@ class DaxDialogs {
232232

233233
default:
234234
settings.browsingWithTrackersShown = true
235-
return BrowsingSpec.withMutipleTrackers.format(args: entitiesBlocked.count - 2, entitiesBlocked[0].displayName ?? "", entitiesBlocked[1].displayName ?? "")
235+
return BrowsingSpec.withMutipleTrackers.format(args: entitiesBlocked.count - 2,
236+
entitiesBlocked[0].displayName ?? "",
237+
entitiesBlocked[1].displayName ?? "")
236238
}
237239

238240
}

‎DuckDuckGo/DoNotSellSettingsViewController.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ extension DoNotSellSettingsViewController: Themable {
9292
attributes: [
9393
NSAttributedString.Key.link: "ddgQuickLink://duckduckgo.com/global-privacy-control-learn-more"
9494
]))
95-
let linkAttributes: [NSAttributedString.Key : Any] = [
95+
let linkAttributes: [NSAttributedString.Key: Any] = [
9696
NSAttributedString.Key.kern: -0.08,
9797
NSAttributedString.Key.paragraphStyle: paragraphStyle,
9898
NSAttributedString.Key.font: UIFont.systemFont(ofSize: 13),

0 commit comments

Comments
 (0)