Skip to content

Commit

Permalink
Update formatting rules
Browse files Browse the repository at this point in the history
Update SwiftLint and SwiftFormat rules to indent `case` in `switch` statements.
  • Loading branch information
samuelmeuli committed Apr 19, 2020
1 parent b4c0470 commit ba81d10
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 28 deletions.
1 change: 1 addition & 0 deletions .swiftformat
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
--swiftversion 5.1

--indent tab
--indentcase true
--maxwidth 100
--tabwidth 4
6 changes: 1 addition & 5 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Source: https://github.com/sindresorhus/swiftlint-sindre (with modifications)

# Added
excluded:
- .build # Ignore Swift Package Manager dependencies

# Rules covered by SwiftFormat are commented out
whitelist_rules:
- anyobject_protocol
Expand Down Expand Up @@ -109,7 +105,7 @@ whitelist_rules:
- static_operator
- strong_iboutlet
- superfluous_disable_command
- switch_case_alignment
# - switch_case_alignment
- switch_case_on_newline
- syntactic_sugar
- todo
Expand Down
4 changes: 2 additions & 2 deletions QLPlugin/MainVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ enum PreviewError: Error {
extension PreviewError: LocalizedError {
public var errorDescription: String? {
switch self {
case let .fileSizeError(path):
return NSLocalizedString("File \(path) is too large to preview", comment: "")
case let .fileSizeError(path):
return NSLocalizedString("File \(path) is too large to preview", comment: "")
}
}
}
Expand Down
20 changes: 12 additions & 8 deletions QLPlugin/Utils/File.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ enum FileError: Error {
extension FileError: LocalizedError {
public var errorDescription: String? {
switch self {
case let .fileAttributeError(path, message):
return NSLocalizedString(
"Could not get attributes for file at path \(path): \(message)", comment: ""
)
case let .fileNotFoundError(path):
return NSLocalizedString("Could not find file at path \(path)", comment: "")
case let .fileReadError(path, message):
return NSLocalizedString("Could not read file at path \(path): \(message)", comment: "")
case let .fileAttributeError(path, message):
return NSLocalizedString(
"Could not get attributes for file at path \(path): \(message)",
comment: ""
)
case let .fileNotFoundError(path):
return NSLocalizedString("Could not find file at path \(path)", comment: "")
case let .fileReadError(path, message):
return NSLocalizedString(
"Could not read file at path \(path): \(message)",
comment: ""
)
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions QLPlugin/Views/PreviewVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ enum PreviewVCError {
extension PreviewVCError: LocalizedError {
public var errorDescription: String? {
switch self {
case let .resourceNotFoundError(resourceName):
return NSLocalizedString(
"Could not find preview resource \"\(resourceName)\"",
comment: ""
)
case let .resourceNotFoundError(resourceName):
return NSLocalizedString(
"Could not find preview resource \"\(resourceName)\"",
comment: ""
)
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions QLPlugin/Views/PreviewVCFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import Foundation
class PreviewVCFactory {
static func getView(fileExtension: String) -> PreviewVC.Type {
switch fileExtension {
case "csv", "tab", "tsv":
return CSVPreviewVC.self
case "md", "markdown", "mdown", "mkdn", "mkd":
return MarkdownPreviewVC.self
case "ipynb":
return JupyterPreviewVC.self
default:
return CodePreviewVC.self
case "csv", "tab", "tsv":
return CSVPreviewVC.self
case "md", "markdown", "mdown", "mkdn", "mkd":
return MarkdownPreviewVC.self
case "ipynb":
return JupyterPreviewVC.self
default:
return CodePreviewVC.self
}
}
}

0 comments on commit ba81d10

Please sign in to comment.