Skip to content

Commit 850ffeb

Browse files
committed
Fixlint
1 parent c1f63bd commit 850ffeb

File tree

6 files changed

+15
-9
lines changed

6 files changed

+15
-9
lines changed

SwiftUI/Model/DirectoryMonitor.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,16 @@ class DirectoryMonitor {
9898
}
9999

100100
private func directoryDidReachStasis() {
101-
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + Double(Int64(NSEC_PER_SEC/10)) / Double(NSEC_PER_SEC) , execute: { () -> Void in
102-
self.delegate?.directoryContentDidChange(url: self.url)
103-
self.onChange?(self.url)
101+
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + Double(Int64(NSEC_PER_SEC/10)) / Double(NSEC_PER_SEC), execute: { [weak self] in
102+
guard let url = self?.url else { return }
103+
self?.delegate?.directoryContentDidChange(url: url)
104+
self?.onChange?(url)
104105
})
105106
}
106107

107108
private func waitAndCheckAgain() {
108-
queue.asyncAfter(deadline: DispatchTime.now() + Double(Int64(NSEC_PER_SEC/2)) / Double(NSEC_PER_SEC) , execute: { () -> Void in
109-
self.checkDirectoryChanges()
109+
queue.asyncAfter(deadline: DispatchTime.now() + Double(Int64(NSEC_PER_SEC/2)) / Double(NSEC_PER_SEC), execute: { [weak self] in
110+
self?.checkDirectoryChanges()
110111
})
111112
}
112113

SwiftUI/Model/SearchOperation/SearchOperation.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ extension SearchOperation {
4545
// start sorting search results
4646
let searchText = searchText.lowercased()
4747

48+
// swiftlint:disable compiler_protocol_init
4849
// calculate score for all results
4950
for result in results {
5051
guard !isCancelled else { return }
@@ -55,6 +56,7 @@ extension SearchOperation {
5556
result.score = NSNumber(integerLiteral: distance)
5657
}
5758
}
59+
// swiftlint:enable compiler_protocol_init
5860

5961
// sort the results
6062
guard !isCancelled else { return }

Tests/BookmarkMigrationTests.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import XCTest
2121
@testable import Kiwix
2222

23+
// swiftlint:disable force_cast
2324
final class BookmarkMigrationTests: XCTestCase {
2425

2526
func testURLHostChange() throws {
@@ -35,7 +36,7 @@ final class BookmarkMigrationTests: XCTestCase {
3536
let testString = "\0\0\0\u{02}bplist00�\u{01}\u{02}\u{03}\u{04}\u{05}\u{06}^RenderTreeSize^IsAppInitiated^SessionHistory\u{10}\u{03}\t\u{07}\u{08}\t\n\u{1C}\u{1C}_\u{10}\u{15}SessionHistoryEntries_\u{10}\u{1A}SessionHistoryCurrentIndex_\u{10}\u{15}SessionHistoryVersion�\u{0B}\u{16}\u{0C}\r\u{0E}\u{0F}\u{10}\u{11}\u{12}\u{13}\u{14}\u{15}_\u{10}\u{17}SessionHistoryEntryData_\u{10}\u{18}SessionHistoryEntryTitle_\u{10}2SessionHistoryEntryShouldOpenExternalURLsPolicyKey_\u{10}\u{16}SessionHistoryEntryURL_\u{10}\u{1E}SessionHistoryEntryOriginalURLO\u{10}P\0\0\0\0\0\0\0\0\u{02}\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\u{07}�@�\u{13}\u{06}\0\0\0\0\0\0\0\0\0����\0\0\0\0\u{07}�@�\u{13}\u{06}\0����\0\0\0\0\u{03}\0\0\0\0�?\0\0\0\0����TDWDS\u{10}\u{01}_\u{10}2kiwix://64C3EA1A-5161-2B94-1F50-606DA5EC0035/index_\u{10}2kiwix://64C3EA1A-5161-2B94-1F50-606DA5EC0035/index�\u{0C}\r\u{0E}\u{0F}\u{10}\u{17}\u{18}\u{19}\u{1A}\u{1B}O\u{10}P\0\0\0\0\0\0\0\0\u{02}\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0V<�A�\u{13}\u{06}\0\0\0\0\0\0\0\0\0����\0\0\0\0U<�A�\u{13}\u{06}\0����\0\0\0\0\0\0\0\0\0\0�?\0\0\0\0����[hier und da\u{10}\u{02}_\u{10}<kiwix://64C3EA1A-5161-2B94-1F50-606DA5EC0035/wb/hie_.und_.da_\u{10}<kiwix://64C3EA1A-5161-2B94-1F50-606DA5EC0035/wb/hie_.und_.da\u{10}\u{01}\0\u{08}\0\u{0F}\0\u{1E}\0-\0<\0>\0?\0F\0^\0{\0\0\0\0\0\u{01}\u{0B}\u{01}$\u{01}E\u{01}\u{01}\u{01}\u{01}\u{02}\t\u{02}\u{14}\u{02}g\u{02}s\u{02}u\u{02}\u{02}\0\0\0\0\0\0\u{02}\u{01}\0\0\0\0\0\0\0\u{1D}\0\0\0\0\0\0\0\0\0\0\0\0\0\0\u{02}"
3637
let data = Data(testString.utf8)
3738
let newData = data.updateHost(to: newHost)
38-
let outString = String(decoding: newData, as: UTF8.self)
39+
let outString = String(bytes: newData, encoding: .utf8)!
3940
XCTAssertFalse(outString.contains("64C3EA1A-5161-2B94-1F50-606DA5EC0035"))
4041
XCTAssertTrue(outString.contains(newHost))
4142
// swiftlint:disable:next line_length
@@ -48,3 +49,4 @@ final class BookmarkMigrationTests: XCTestCase {
4849
XCTAssertEqual(url.updatedToZIMSheme(), URL(string: "zim://64C3EA1A-5161-2B94-1F50-606DA5EC0035/wb/Saftladen")!)
4950
}
5051
}
52+
// swiftlint:enable force_cast

Tests/DataStreamTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ final class DataStreamTests: XCTestCase {
2929
}
3030

3131
func test_small_data() async throws {
32-
let data = "small test data".data(using: .utf8)!
32+
let data = Data("small test data".utf8)
3333
let dataStream = DataStream(
3434
dataProvider: MockDataProvider(data: data),
3535
ranges: ByteRanges.rangesFor(contentLength: UInt(data.count),
@@ -43,7 +43,7 @@ final class DataStreamTests: XCTestCase {
4343
}
4444

4545
func test_small_data_with_large_rangeSize_returns_in_one_chunk() async throws {
46-
let data = "small test data".data(using: .utf8)!
46+
let data = Data("small test data".utf8)
4747
let dataStream = DataStream(
4848
dataProvider: MockDataProvider(data: data),
4949
ranges: ByteRanges.rangesFor(contentLength: UInt(data.count),

Views/Settings/Settings.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct ReadingSettings: View {
4343
}
4444
}
4545
if FeatureFlags.showExternalLinkOptionInSettings {
46-
SettingSection(name: LocalString.reading_settings_external_link_title.localized) {
46+
SettingSection(name: LocalString.reading_settings_external_link_title) {
4747
Picker(selection: $externalLinkLoadingPolicy) {
4848
ForEach(ExternalLinkLoadingPolicy.allCases) { loadingPolicy in
4949
Text(loadingPolicy.name).tag(loadingPolicy)

Views/ViewModifiers/SaveContentHandler.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ struct SaveContentHandler: ViewModifier {
2424
@State private var urlAndContent: (URL, URLContent)?
2525
#endif
2626

27+
// swiftlint:disable:next function_body_length
2728
func body(content: Content) -> some View {
2829
content.onReceive(saveContentToFile) { notification in
2930
guard let url = notification.userInfo?["url"] as? URL,

0 commit comments

Comments
 (0)