Skip to content

Commit 0f5e42c

Browse files
committed
fix linting issues
1 parent d7f05cb commit 0f5e42c

File tree

12 files changed

+42
-106
lines changed

12 files changed

+42
-106
lines changed

Diff for: .swiftlint.yml

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
included: # paths to include during linting. `--path` is ignored if present.
2-
- megazords
3-
- components/places/ios
4-
- components/support/ios
5-
- components/logins/ios
6-
- components/fxa-client/ios
7-
- components/nimbus/ios
2+
- "megazords/ios-rust/Sources"
3+
84
excluded:
95
# We no longer use carthage. However, some developers might still
106
# have the Carthage directory in their local environment. It will
117
# create linting noise if we don't exclude it.
128
- Carthage
139
- "**/*/ios/Generated"
14-
- "megazords/ios/MozillaAppServicesTests"
15-
- "megazords/ios-rust/MozillaTestServices/MozillaTestServicesTests"
16-
- "megazords/ios-rust/MozillaTestServices/MozillaTestServices/Generated"
10+
- "megazords/ios-rust/tests"
11+
- "megazords/ios-rust/Sources/MozillaRustComponentsWrapper/Generated"
12+
# Sync manager wasn't added to the swiftlint checks before and didn't want to
13+
# break APIs during the xcodeproj migration, so ignoring for now but we should
14+
# eventually fix
15+
- "megazords/ios-rust/Sources/MozillaRustComponentsWrapper/SyncManager"
1716

1817
disabled_rules:
1918
- file_length
@@ -38,3 +37,5 @@ identifier_name:
3837
min_length:
3938
warning: 0
4039
error: 0
40+
# Turn off complaining about having _ in variable names
41+
allowed_symbols: "_"

Diff for: Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: automation/run_ios_tests.sh

+7-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ for arg in "$@"; do
2121
done
2222

2323

24-
export SOURCE_ROOT=$(pwd)
24+
SOURCE_ROOT=$(pwd)
25+
export SOURCE_ROOT
2526
export PROJECT=MozillaRustComponentsWrapper
2627

2728
# Conditionally generate the UniFFi bindings with rust binaries and bundle it into an XCFramework
@@ -31,9 +32,9 @@ if [ "$SKIP_BUILDING" != true ]; then
3132
./components/external/glean/glean-core/ios/sdk_generator.sh \
3233
-g Glean \
3334
-o ./megazords/ios-rust/Sources/MozillaRustComponentsWrapper/Generated/Glean \
34-
${SOURCE_ROOT}/components/nimbus/metrics.yaml \
35-
${SOURCE_ROOT}/components/sync_manager/metrics.yaml \
36-
${SOURCE_ROOT}/components/sync_manager/pings.yaml
35+
"${SOURCE_ROOT}"/components/nimbus/metrics.yaml \
36+
"${SOURCE_ROOT}"/components/sync_manager/metrics.yaml \
37+
"${SOURCE_ROOT}"/components/sync_manager/pings.yaml
3738

3839
# Build the XCFramework
3940
./megazords/ios-rust/build-xcframework.sh --build-profile release
@@ -51,7 +52,7 @@ set -o pipefail
5152
xcodebuild \
5253
-scheme MozillaRustComponents \
5354
-sdk iphonesimulator \
54-
-destination 'platform=iOS Simulator,name=iPhone 16e' \
55+
-destination 'platform=iOS Simulator,name=iPhone 15' \
5556
test | tee raw_xcodetest.log | xcpretty
5657
result=${PIPESTATUS[0]}
5758
set -e
@@ -60,7 +61,7 @@ set -e
6061
popd > /dev/null
6162

6263
# Provide clear messaging based on test results
63-
if [ $result -eq 0 ]; then
64+
if [ "$result" -eq 0 ]; then
6465
echo "✅ Swift tests pass!"
6566
else
6667
echo "❌ Swift tests failed!"

Diff for: automation/tests.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -445,11 +445,10 @@ def cargo_fmt(package=None, fix_issues=False):
445445
def swift_format():
446446
swift_format_args = [
447447
"megazords",
448-
"components/*/ios",
449448
"--exclude",
450449
"**/Generated",
451450
"--exclude",
452-
"components/nimbus/ios/Nimbus/Utils",
451+
"megazords/ios-rust/Sources/MozillaRustComponentsWrapper/Nimbus/Utils",
453452
"--lint",
454453
"--swiftversion",
455454
"5",

Diff for: megazords/ios-rust/Package.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ let package = Package(
88
.library(name: "MozillaRustComponents", targets: ["MozillaRustComponentsWrapper"]),
99
],
1010
dependencies: [
11-
.package(url: "https://github.com/mozilla/glean-swift", from: "64.0.0")
11+
.package(url: "https://github.com/mozilla/glean-swift", from: "64.0.0"),
1212
],
1313
targets: [
1414
// Binary target XCFramework, contains our rust binaries and headers
@@ -30,4 +30,4 @@ let package = Package(
3030
dependencies: ["MozillaRustComponentsWrapper"]
3131
),
3232
]
33-
)
33+
)

Diff for: megazords/ios-rust/Sources/MozillaRustComponentsWrapper/Sync15/RustSyncTelemetryPing.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public class OutgoingInfo {
224224
static func fromJSONArray(jsonArray: [[String: Any]]) -> [OutgoingInfo] {
225225
var result = [OutgoingInfo]()
226226

227-
for (_, item) in jsonArray.enumerated() {
227+
for item in jsonArray {
228228
result.append(fromJSON(jsonObject: item))
229229
}
230230

@@ -288,7 +288,7 @@ public class ProblemInfo {
288288
static func fromJSONArray(jsonArray: [[String: Any]]) throws -> [ProblemInfo] {
289289
var result = [ProblemInfo]()
290290

291-
for (_, item) in jsonArray.enumerated() {
291+
for item in jsonArray {
292292
try result.append(fromJSON(jsonObject: item))
293293
}
294294

@@ -379,7 +379,7 @@ public class EventInfo {
379379
static func fromJSONArray(jsonArray: [[String: Any]]) throws -> [EventInfo] {
380380
var result = [EventInfo]()
381381

382-
for (_, item) in jsonArray.enumerated() {
382+
for item in jsonArray {
383383
try result.append(fromJSON(jsonObject: item))
384384
}
385385

Diff for: megazords/ios-rust/Sources/MozillaRustComponentsWrapper/Sync15/SyncUnlockInfo.swift

+8-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@ open class SyncUnlockInfo {
1414
public var loginEncryptionKey: String
1515
public var tabsLocalId: String?
1616

17-
public init(kid: String, fxaAccessToken: String, syncKey: String, tokenserverURL: String, loginEncryptionKey: String, tabsLocalId: String? = nil) {
17+
public init(
18+
kid: String,
19+
fxaAccessToken: String,
20+
syncKey: String,
21+
tokenserverURL: String,
22+
loginEncryptionKey: String,
23+
tabsLocalId: String? = nil
24+
) {
1825
self.kid = kid
1926
self.fxaAccessToken = fxaAccessToken
2027
self.syncKey = syncKey

Diff for: megazords/ios-rust/Sources/MozillaRustComponentsWrapper/SyncManager/SyncManagerTelemetry.swift

+6-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@ enum TelemetryReportingError: Error {
2828
func processSyncTelemetry(syncTelemetry: RustSyncTelemetryPing,
2929
submitGlobalPing: (NoReasonCodes?) -> Void = GleanMetrics.Pings.shared.sync.submit,
3030
submitHistoryPing: (NoReasonCodes?) -> Void = GleanMetrics.Pings.shared.historySync.submit,
31-
submitBookmarksPing: (NoReasonCodes?) -> Void = GleanMetrics.Pings.shared.bookmarksSync.submit,
32-
submitLoginsPing: (NoReasonCodes?) -> Void = GleanMetrics.Pings.shared.loginsSync.submit,
33-
submitCreditCardsPing: (NoReasonCodes?) -> Void = GleanMetrics.Pings.shared.creditcardsSync.submit,
31+
submitBookmarksPing: (NoReasonCodes?) -> Void
32+
= GleanMetrics.Pings.shared.bookmarksSync.submit,
33+
submitLoginsPing: (NoReasonCodes?) -> Void
34+
= GleanMetrics.Pings.shared.loginsSync.submit,
35+
submitCreditCardsPing: (NoReasonCodes?) -> Void
36+
= GleanMetrics.Pings.shared.creditcardsSync.submit,
3437
submitTabsPing: (NoReasonCodes?) -> Void = GleanMetrics.Pings.shared.tabsSync.submit) throws
3538
{
3639
for syncInfo in syncTelemetry.syncs {

Diff for: megazords/ios-rust/tests/MozillaRustComponentsTests/FxAccountMocks.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
@testable import MozillaRustComponentsWrapper
65
import Foundation
6+
@testable import MozillaRustComponentsWrapper
77

88
// Arrays are not thread-safe in Swift.
99
let queue = DispatchQueue(label: "InvocationsArrayQueue")

Diff for: megazords/ios-rust/tests/MozillaRustComponentsTests/NimbusTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
@testable import MozillaRustComponentsWrapper
65
import Glean
6+
@testable import MozillaRustComponentsWrapper
77
import UIKit
88
import XCTest
99

Diff for: taskcluster/scripts/build-and-test-swift.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# Repository root dir
1313
ROOT_DIR = pathlib.Path(__file__).parent.parent.parent
1414

15-
WRAPPER_DIR = "megazords/ios-rust/Sources/MozillaRustComponentsWrapper/"
15+
WRAPPER_DIR = pathlib.Path("megazords/ios-rust/Sources/MozillaRustComponentsWrapper/")
1616
# List of globs to copy the sources from
1717
SOURCE_TO_COPY = [
1818
WRAPPER_DIR / "ASOhttpClient",
@@ -191,7 +191,7 @@ def copy_sources(out_dir, sources):
191191
ensure_dir(out_dir)
192192
for source in sources:
193193
log(f"copying {source}")
194-
for path in ROOT_DIR.glob(source):
194+
for path in ROOT_DIR.glob(str(source)):
195195
subprocess.check_call(["cp", "-r", path, out_dir])
196196

197197

Diff for: xcconfig/common.xcconfig

-75
This file was deleted.

0 commit comments

Comments
 (0)