From 767f5a5ff500ebc416e8c60fdc6f5200d6b6ecd7 Mon Sep 17 00:00:00 2001 From: Lukas Pistrol Date: Wed, 12 Apr 2023 16:33:24 +0200 Subject: [PATCH] updates SwiftLintPlugin to the latest version - also fixes warnings introduced in the latest swiftlint version --- .../xcshareddata/swiftpm/Package.resolved | 4 ++-- .../AccountPreferencesView.swift | 9 +++------ .../Documents/WorkspaceDocument+Search.swift | 4 ++-- CodeEdit/Features/Feedback/FeedbackView.swift | 2 +- .../Accounts/GitHub/Model/GitHubRepositories.swift | 13 ++++++++++--- CodeEdit/Features/Git/Clone/GitCloneView.swift | 3 ++- CodeEdit/Features/SplitView/Variadic.swift | 2 +- CodeEdit/Utils/WorkspaceClient/Interface.swift | 1 - CodeEdit/Utils/WorkspaceClient/Model/FileIcon.swift | 6 +++--- 9 files changed, 24 insertions(+), 20 deletions(-) diff --git a/CodeEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/CodeEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 7f9703e91f..37deb6d4d2 100644 --- a/CodeEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/CodeEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -86,8 +86,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/lukepistrol/SwiftLintPlugin", "state" : { - "revision" : "f69b412a765396d44dc9f4788a5b79919c1ca9e3", - "version" : "0.2.2" + "revision" : "f3586ed424d7bf5d94628332fbd0edebf1f5147f", + "version" : "0.2.3" } }, { diff --git a/CodeEdit/Features/AppPreferences/Sections/AccountsPreferences/AccountPreferencesView.swift b/CodeEdit/Features/AppPreferences/Sections/AccountsPreferences/AccountPreferencesView.swift index f70e0996b0..bff531bb6b 100644 --- a/CodeEdit/Features/AppPreferences/Sections/AccountsPreferences/AccountPreferencesView.swift +++ b/CodeEdit/Features/AppPreferences/Sections/AccountsPreferences/AccountPreferencesView.swift @@ -7,7 +7,6 @@ import SwiftUI -// swiftlint:disable for_where struct AccountPreferencesView: View { @StateObject private var prefs: AppPreferencesModel = .shared @@ -167,11 +166,9 @@ struct AccountPreferencesView: View { private func removeSourceControlAccount(selectedAccountId: String) { var gitAccounts = prefs.preferences.accounts.sourceControlAccounts.gitAccount - for account in gitAccounts { - if account.id == selectedAccountId { - let index = gitAccounts.firstIndex(of: account) - gitAccounts.remove(at: index ?? 0) - } + for account in gitAccounts where account.id == selectedAccountId { + let index = gitAccounts.firstIndex(of: account) + gitAccounts.remove(at: index ?? 0) } } diff --git a/CodeEdit/Features/Documents/WorkspaceDocument+Search.swift b/CodeEdit/Features/Documents/WorkspaceDocument+Search.swift index 6852826479..c0b250be1b 100644 --- a/CodeEdit/Features/Documents/WorkspaceDocument+Search.swift +++ b/CodeEdit/Features/Documents/WorkspaceDocument+Search.swift @@ -122,7 +122,7 @@ extension WorkspaceDocument { } // see if the line contains search term, obeying selectedMode - // swiftlint:disable cyclomatic_complexity + // swiftlint:disable:next cyclomatic_complexity func lineContainsSearchTerm(line rawLine: String, term searchterm: String) -> Bool { var line = rawLine if line.hasSuffix(" ") { line.removeLast() } @@ -170,7 +170,7 @@ extension WorkspaceDocument { return foundMatch } else if findMode == .RegularExpression { guard let regex = try? NSRegularExpression(pattern: searchterm) else { return false } - // swiftlint:disable legacy_constructor + // swiftlint:disable:next legacy_constructor return regex.firstMatch(in: String(line), range: NSMakeRange(0, line.utf16.count)) != nil } diff --git a/CodeEdit/Features/Feedback/FeedbackView.swift b/CodeEdit/Features/Feedback/FeedbackView.swift index ba7c47de27..1c4d7af8cc 100644 --- a/CodeEdit/Features/Feedback/FeedbackView.swift +++ b/CodeEdit/Features/Feedback/FeedbackView.swift @@ -202,12 +202,12 @@ struct FeedbackView: View { } .padding(.top) - // swiftlint:disable line_length VStack(alignment: .leading) { Text("What actually happened?") TextEditor(text: $feedbackModel.whatHappenedDescription) .frame(minHeight: 60, alignment: .leading) .border(Color(NSColor.separatorColor)) + // swiftlint:disable:next line_length Text("Example: The autocomplete window flickered on screen and CodeEdit crashed. See attached crashlog.") .font(.system(size: 10)) .foregroundColor(.secondary) diff --git a/CodeEdit/Features/Git/Accounts/GitHub/Model/GitHubRepositories.swift b/CodeEdit/Features/Git/Accounts/GitHub/Model/GitHubRepositories.swift index 211cd52ddb..e771bab31f 100644 --- a/CodeEdit/Features/Git/Accounts/GitHub/Model/GitHubRepositories.swift +++ b/CodeEdit/Features/Git/Accounts/GitHub/Model/GitHubRepositories.swift @@ -44,7 +44,6 @@ class GitHubRepositories: Codable { } } -// swiftlint:disable line_length extension GitHubAccount { /** @@ -68,7 +67,11 @@ extension GitHubAccount { ? GitHubRepositoryRouter.readRepositories(configuration, owner!, page, perPage) : GitHubRepositoryRouter.readAuthenticatedRepositories(configuration, page, perPage) - return router.load(session, dateDecodingStrategy: .formatted(GitTime.rfc3339DateFormatter), expectedResultType: [GitHubRepositories].self) { repos, error in + return router.load( + session, + dateDecodingStrategy: .formatted(GitTime.rfc3339DateFormatter), + expectedResultType: [GitHubRepositories].self + ) { repos, error in if let error { completion(.failure(error)) } @@ -95,7 +98,11 @@ extension GitHubAccount { ) -> GitURLSessionDataTaskProtocol? { let router = GitHubRepositoryRouter.readRepository(configuration, owner, name) - return router.load(session, dateDecodingStrategy: .formatted(GitTime.rfc3339DateFormatter), expectedResultType: GitHubRepositories.self) { repo, error in + return router.load( + session, + dateDecodingStrategy: .formatted(GitTime.rfc3339DateFormatter), + expectedResultType: GitHubRepositories.self + ) { repo, error in if let error { completion(.failure(error)) } else { diff --git a/CodeEdit/Features/Git/Clone/GitCloneView.swift b/CodeEdit/Features/Git/Clone/GitCloneView.swift index a0b0ddb00a..27efd1d856 100644 --- a/CodeEdit/Features/Git/Clone/GitCloneView.swift +++ b/CodeEdit/Features/Git/Clone/GitCloneView.swift @@ -134,7 +134,8 @@ extension GitCloneView { } } } - // swiftlint:disable function_body_length cyclomatic_complexity + + // swiftlint:disable:next function_body_length cyclomatic_complexity private func cloneRepository() { do { if repoUrlStr == "" { diff --git a/CodeEdit/Features/SplitView/Variadic.swift b/CodeEdit/Features/SplitView/Variadic.swift index d3b7f94a1b..0253b4f9e1 100644 --- a/CodeEdit/Features/SplitView/Variadic.swift +++ b/CodeEdit/Features/SplitView/Variadic.swift @@ -7,8 +7,8 @@ import SwiftUI -// swiftlint:disable identifier_name struct Helper: _VariadicView_UnaryViewRoot { + // swiftlint:disable:next identifier_name var _body: (_VariadicView.Children) -> Result func body(children: _VariadicView.Children) -> some View { diff --git a/CodeEdit/Utils/WorkspaceClient/Interface.swift b/CodeEdit/Utils/WorkspaceClient/Interface.swift index e10b098dc1..c1c8032732 100644 --- a/CodeEdit/Utils/WorkspaceClient/Interface.swift +++ b/CodeEdit/Utils/WorkspaceClient/Interface.swift @@ -31,7 +31,6 @@ struct WorkspaceClient { self.getFiles = getFiles self.getFileItem = getFileItem } - // swiftlint:enable vertical_parameter_alignment enum WorkspaceClientError: Error { case fileNotExist diff --git a/CodeEdit/Utils/WorkspaceClient/Model/FileIcon.swift b/CodeEdit/Utils/WorkspaceClient/Model/FileIcon.swift index 299459d33e..7b670913b0 100644 --- a/CodeEdit/Utils/WorkspaceClient/Model/FileIcon.swift +++ b/CodeEdit/Utils/WorkspaceClient/Model/FileIcon.swift @@ -8,7 +8,6 @@ import SwiftUI // TODO: DOCS (Nanashi Li) -// swiftlint:disable cyclomatic_complexity enum FileIcon { // swiftlint:disable identifier_name @@ -45,10 +44,11 @@ enum FileIcon { case Makefile case ts } + // swiftlint:enable identifier_name /// Returns a string describing a SFSymbol for files /// If not specified otherwise this will return `"doc"` - static func fileIcon(fileType: FileType) -> String { + static func fileIcon(fileType: FileType) -> String { // swiftlint:disable:this cyclomatic_complexity switch fileType { case .json, .js: return "curlybraces" @@ -99,7 +99,7 @@ enum FileIcon { /// Returns a `Color` for a specific `fileType` /// If not specified otherwise this will return `Color.accentColor` - static func iconColor(fileType: FileType) -> Color { + static func iconColor(fileType: FileType) -> Color { // swiftlint:disable:this cyclomatic_complexity switch fileType { case .swift, .html: return .orange