Skip to content

Commit

Permalink
Fixlint
Browse files Browse the repository at this point in the history
  • Loading branch information
BPerlakiH authored and kelson42 committed Jan 26, 2025
1 parent b10816f commit 31ed67b
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
11 changes: 6 additions & 5 deletions SwiftUI/Model/DirectoryMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,16 @@ class DirectoryMonitor {
}

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

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

Expand Down
2 changes: 2 additions & 0 deletions SwiftUI/Model/SearchOperation/SearchOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ extension SearchOperation {
// start sorting search results
let searchText = searchText.lowercased()

// swiftlint:disable compiler_protocol_init
// calculate score for all results
for result in results {
guard !isCancelled else { return }
Expand All @@ -55,6 +56,7 @@ extension SearchOperation {
result.score = NSNumber(integerLiteral: distance)
}
}
// swiftlint:enable compiler_protocol_init

// sort the results
guard !isCancelled else { return }
Expand Down
4 changes: 3 additions & 1 deletion Tests/BookmarkMigrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import XCTest
@testable import Kiwix

// swiftlint:disable force_cast
final class BookmarkMigrationTests: XCTestCase {

func testURLHostChange() throws {
Expand All @@ -35,7 +36,7 @@ final class BookmarkMigrationTests: XCTestCase {
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}"
let data = Data(testString.utf8)
let newData = data.updateHost(to: newHost)
let outString = String(decoding: newData, as: UTF8.self)
let outString = String(bytes: newData, encoding: .utf8)!
XCTAssertFalse(outString.contains("64C3EA1A-5161-2B94-1F50-606DA5EC0035"))
XCTAssertTrue(outString.contains(newHost))
// swiftlint:disable:next line_length
Expand All @@ -48,3 +49,4 @@ final class BookmarkMigrationTests: XCTestCase {
XCTAssertEqual(url.updatedToZIMSheme(), URL(string: "zim://64C3EA1A-5161-2B94-1F50-606DA5EC0035/wb/Saftladen")!)
}
}
// swiftlint:enable force_cast
4 changes: 2 additions & 2 deletions Tests/DataStreamTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class DataStreamTests: XCTestCase {
}

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

func test_small_data_with_large_rangeSize_returns_in_one_chunk() async throws {
let data = "small test data".data(using: .utf8)!
let data = Data("small test data".utf8)
let dataStream = DataStream(
dataProvider: MockDataProvider(data: data),
ranges: ByteRanges.rangesFor(contentLength: UInt(data.count),
Expand Down
2 changes: 1 addition & 1 deletion Views/Settings/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct ReadingSettings: View {
}
}
if FeatureFlags.showExternalLinkOptionInSettings {
SettingSection(name: LocalString.reading_settings_external_link_title.localized) {
SettingSection(name: LocalString.reading_settings_external_link_title) {
Picker(selection: $externalLinkLoadingPolicy) {
ForEach(ExternalLinkLoadingPolicy.allCases) { loadingPolicy in
Text(loadingPolicy.name).tag(loadingPolicy)
Expand Down
1 change: 1 addition & 0 deletions Views/ViewModifiers/SaveContentHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct SaveContentHandler: ViewModifier {
@State private var urlAndContent: (URL, URLContent)?
#endif

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

0 comments on commit 31ed67b

Please sign in to comment.