Skip to content

Commit 6be2ff6

Browse files
committed
swiftlint
1 parent 09df392 commit 6be2ff6

File tree

8 files changed

+25
-15
lines changed

8 files changed

+25
-15
lines changed

CodeEdit/Features/About/Views/AboutDefaultView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ struct AboutDefaultView: View {
2626
@Environment(\.colorScheme)
2727
var colorScheme
2828

29+
// swiftlint:disable:next force_unwrapping
2930
private static var licenseURL = URL(string: "https://github.com/CodeEditApp/CodeEdit/blob/main/LICENSE.md")!
3031

3132
let smallTitlebarHeight: CGFloat = 28

CodeEdit/Features/Documents/Indexer/AsyncFileIterator.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ struct AsyncFileIterator: AsyncSequence, AsyncIteratorProtocol {
3939
currentIdx += 1
4040
}
4141
}
42+
43+
// swiftlint:disable:next force_unwrapping
4244
return (foundContent!, currentIdx)
4345
}
4446

CodeEdit/Features/Documents/Indexer/SearchIndexer+AsyncController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,12 @@ extension SearchIndexer {
165165
let dispatchGroup = DispatchGroup()
166166

167167
let fileManager = FileManager.default
168-
let enumerator = fileManager.enumerator(
168+
guard let enumerator = fileManager.enumerator(
169169
at: url,
170170
includingPropertiesForKeys: [.isRegularFileKey],
171171
options: [.skipsHiddenFiles],
172172
errorHandler: nil
173-
)!
173+
) else { return }
174174

175175
for case let fileURL as URL in enumerator {
176176
dispatchGroup.enter()

CodeEdit/Features/Documents/WorkspaceDocument+Find.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ extension WorkspaceDocument.SearchState {
3232
}
3333

3434
func stripSpecialCharacters(from string: String) -> String {
35-
let regex = try? NSRegularExpression(pattern: "[^a-zA-Z0-9]+", options: .caseInsensitive)
36-
return regex!.stringByReplacingMatches(
35+
guard let regex = try? NSRegularExpression(pattern: "[^a-zA-Z0-9]+", options: .caseInsensitive) else {
36+
return string
37+
}
38+
return regex.stringByReplacingMatches(
3739
in: string,
3840
options: [],
3941
range: NSRange(location: 0, length: string.utf16.count),

CodeEditTests/Features/Documents/Indexer/MemoryIndexingTests.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,16 @@ final class MemoryIndexingTests: XCTestCase {
130130

131131
// Save the current index.
132132
let savedIndex = index.getAsData()
133-
XCTAssertNotNil(savedIndex, "Failed to save the index.")
133+
guard let savedIndex = savedIndex else {
134+
XCTFail("Failed to save the index.")
135+
return
136+
}
134137

135138
// Close the index, i.e. the index gets deallocated form memory.
136139
index.close()
137140

138141
// Load the saved index
139-
guard let loadedIndex = SearchIndexer.Memory(data: savedIndex!) else {
142+
guard let loadedIndex = SearchIndexer.Memory(data: savedIndex) else {
140143
XCTFail("Failed to create an index")
141144
return
142145
}

CodeEditTests/Features/Documents/Indexer/TemporaryFile.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class TemporaryFile {
2424
let folder = NSTemporaryDirectory()
2525
let name = UUID().uuidString
2626

27+
// swiftlint:disable:next force_unwrapping
2728
return NSURL.fileURL(withPathComponents: [folder, name])! as URL
2829
}()
2930

CodeEditTests/Features/Search/FuzzySearch/FuzzySearchTests.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ final class FuzzySearchTests: XCTestCase {
3939

4040
func testFuzzySearch() async {
4141
let urls = [
42-
URL(string: "FuzzySearchable.swift")!,
43-
URL(string: "ContentView.swift")!,
44-
URL(string: "FuzzyMatch.swift")!
45-
]
42+
URL(string: "FuzzySearchable.swift"),
43+
URL(string: "ContentView.swift"),
44+
URL(string: "FuzzyMatch.swift")
45+
].compactMap { $0 }
46+
4647
let fuzzyMatchResult = await urls.fuzzySearch(query: "mch").map {
4748
$0.item
4849
}

CodeEditTests/Utils/CEWorkspaceFileManager/CEWorkspaceFileManagerTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ final class CEWorkspaceFileManagerUnitTests: XCTestCase {
4646
let randomCount = Int.random(in: 1 ... 100)
4747
let files = generateRandomFiles(amount: randomCount)
4848
try files.forEach {
49-
let fakeData = "fake string".data(using: .utf8)
49+
let fakeData = Data("fake string".utf8)
5050
let fileUrl = directory
5151
.appendingPathComponent($0)
52-
try fakeData!.write(to: fileUrl)
52+
try fakeData.write(to: fileUrl)
5353
}
5454
let client = CEWorkspaceFileManager(
5555
folderUrl: directory,
@@ -83,10 +83,10 @@ final class CEWorkspaceFileManagerUnitTests: XCTestCase {
8383
var files = client.flattenedFileItems.map { $0.value.name }
8484
files.append(newFile)
8585
try files.forEach {
86-
let fakeData = "fake string".data(using: .utf8)
86+
let fakeData = Data("fake string".utf8)
8787
let fileUrl = directory
8888
.appendingPathComponent($0)
89-
try fakeData!.write(to: fileUrl)
89+
try fakeData.write(to: fileUrl)
9090
}
9191

9292
wait(for: [expectation])
@@ -106,7 +106,7 @@ final class CEWorkspaceFileManagerUnitTests: XCTestCase {
106106

107107
func randomString(length: Int) -> String {
108108
let letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
109-
return String((0 ..< length).map { _ in letters.randomElement()! })
109+
return String((0 ..< length).compactMap { _ in letters.randomElement() })
110110
}
111111

112112
func testGetFile() throws {

0 commit comments

Comments
 (0)