Skip to content

Commit 0af2796

Browse files
committed
fix strict linting issues
Signed-off-by: James Ranson <james@ranson.org>
1 parent d90f8bf commit 0af2796

5 files changed

Lines changed: 61 additions & 7 deletions

File tree

.swiftlint.yml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# SwiftLint: https://github.com/realm/SwiftLint
22
# Run `make lint` (requires SwiftLint: `brew install swiftlint`).
3+
# `make lint` passes `--strict` so warnings fail CI (avoid `swiftlint --fix` without review).
34

45
excluded:
56
- build
@@ -10,8 +11,34 @@ excluded:
1011
disabled_rules:
1112
# Short names are common in tight loops, parsers, and indices.
1213
- identifier_name
13-
# App has a few intentional `try!` sites; prefer fixing over silencing long-term.
14-
- force_try
14+
15+
# Curated opt-in rules (omit closure_end_indentation: very noisy for nested SwiftUI).
16+
opt_in_rules:
17+
- closure_spacing
18+
- empty_count
19+
- empty_enum_arguments
20+
- empty_string
21+
- explicit_init
22+
- fatal_error_message
23+
- first_where
24+
- identical_operands
25+
- legacy_multiple
26+
- literal_expression_end_indentation
27+
- operator_usage_whitespace
28+
- overridden_super_call
29+
- pattern_matching_keywords
30+
- private_action
31+
- private_outlet
32+
- prohibited_super_call
33+
- redundant_nil_coalescing
34+
- redundant_type_annotation
35+
- sorted_first_last
36+
- static_operator
37+
- toggle_bool
38+
- unavailable_function
39+
- unneeded_parentheses_in_closure_argument
40+
- weak_delegate
41+
- yoda_condition
1542

1643
line_length:
1744
# Match error so long literals in fixtures do not warn; errors still cap runaway lines.

ClipboardEnvy/ClipboardHelpers/CSV.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ extension ClipboardTransform {
488488
let headerRow = rows[0]
489489
let dataRows = Array(rows.dropFirst())
490490

491-
let sortedData = dataRows.enumerated().sorted { (a, b) in
491+
let sortedData = dataRows.enumerated().sorted { a, b in
492492
let valueA = columnIndex < a.element.count ? a.element[columnIndex] : ""
493493
let valueB = columnIndex < b.element.count ? b.element[columnIndex] : ""
494494

ClipboardEnvy/EditorWindowRoot.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,13 @@ struct EditorWindowRoot: View {
8080
}
8181

8282
#Preview {
83-
let container = try! ModelContainer(for: Snippet.self, configurations: .init(isStoredInMemoryOnly: true))
83+
let container: ModelContainer = {
84+
do {
85+
return try ModelContainer(for: Snippet.self, configurations: .init(isStoredInMemoryOnly: true))
86+
} catch {
87+
fatalError("Preview ModelContainer failed: \(error)")
88+
}
89+
}()
8490
EditorWindowRoot()
8591
.environmentObject(EditorStore())
8692
.environmentObject(SnippetsStore(container: container))

ClipboardEnvy/MenuBarView.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2183,7 +2183,13 @@ extension View {
21832183
}
21842184

21852185
#Preview {
2186-
let container = try! ModelContainer(for: Snippet.self, configurations: .init(isStoredInMemoryOnly: true))
2186+
let container: ModelContainer = {
2187+
do {
2188+
return try ModelContainer(for: Snippet.self, configurations: .init(isStoredInMemoryOnly: true))
2189+
} catch {
2190+
fatalError("Preview ModelContainer failed: \(error)")
2191+
}
2192+
}()
21872193
MenuBarView()
21882194
.environmentObject(EditorStore())
21892195
.environmentObject(SnippetsStore(container: container))

Makefile

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: build build-release-unsigned generate-appicons lint test clean generate-build-info
1+
.PHONY: build build-release-unsigned generate-appicons lint lint-fix-safe test clean generate-build-info
22

33
# SwiftLint: https://github.com/realm/SwiftLint — `brew install swiftlint`
44
SWIFTLINT ?= $(shell command -v swiftlint 2>/dev/null)
@@ -8,7 +8,22 @@ lint:
88
echo "SwiftLint not found. Install with: brew install swiftlint" >&2; \
99
exit 1; \
1010
fi
11-
@"$(SWIFTLINT)" lint
11+
@"$(SWIFTLINT)" lint --strict
12+
13+
# Autocorrect only low-risk rules (whitespace / file hygiene). Still review `git diff` and run tests.
14+
# Optional: pass paths, e.g. `make lint-fix-safe FIX_PATHS="ClipboardEnvy/Foo.swift"`
15+
FIX_PATHS ?= ClipboardEnvy ClipboardEnvyTests scripts
16+
lint-fix-safe:
17+
@if [ -z "$(SWIFTLINT)" ]; then \
18+
echo "SwiftLint not found. Install with: brew install swiftlint" >&2; \
19+
exit 1; \
20+
fi
21+
@"$(SWIFTLINT)" lint --fix \
22+
--only-rule trailing_whitespace \
23+
--only-rule trailing_newline \
24+
--only-rule leading_whitespace \
25+
--only-rule trailing_semicolon \
26+
$(FIX_PATHS)
1227

1328
clean:
1429
@rm -rf build dist ; rm -rf ~/Library/Developer/Xcode/DerivedData/ClipboardEnvy-*

0 commit comments

Comments
 (0)