Re-enable SwiftLint/SwiftFormat and clean up all reported violations - #1341
Merged
timbms merged 2 commits intoSep 18, 2026
Merged
Conversation
Re-enables the SwiftLint/SwiftFormat build-phase plugin (BuildTools) and brings the whole codebase into compliance with its ruleset. This is a wide, mostly mechanical diff — read the PR description before merging. Highlights: - Fix real bugs surfaced by the cleanup, not just style: NotificationCenterDelegateImpl's didReceive(response:) was missing `async`, so it silently never matched UNUserNotificationCenterDelegate's bridged requirement (notification-tap handling was dead code); two XCTestCase tearDown() overrides mutated a @mainactor property from a nonisolated context and now use the async override. - Split oversized types/files (type_body_length, file_length) into same-file extensions or new files (e.g. OpenHABWebViewModel's injected JS moved to OpenHABWebViewInjectedJS.swift) without changing behavior. - Replace large tuples with small named structs (HomeAvatarView, AvatarColorPairTests). - Migrate HomeAvatarView's icon representation from raw SF Symbol name strings to SFSafeSymbols' SFSymbol type; AvatarMode's persisted storage stays String at the OpenHABCore boundary. - Rename files to satisfy file_name (NSNotification.Name.swift). - Assorted rule fixes: shorthand_operator, for_where, statement_position, unavailable_condition, multiple_closures_with_trailing_closure, async_without_await, orphaned_doc_comment, closure_end_indentation. Verified: full `xcodebuild build` succeeds; OpenHABCoreTests and openHABTestsSwift (including UI-test-target compilation) all pass. No intended functional changes other than the two bug fixes called out above. Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
Contributor
Author
|
@digitaldan @DigiH @TAKeanice I have reenabled swiftlint and swiftformat. All resulting errors and warnings are addressed. It would be great to push it asap unless you are working offsite on potentially conflicting contributions |
TAKeanice
reviewed
Sep 18, 2026
| max_length: | ||
| warning: 90 | ||
| error: 1000 | ||
| excluded: |
Contributor
There was a problem hiding this comment.
Too many exclusions make the rule ineffective. If it's superfluous we should deactivate it completely.
Contributor
There was a problem hiding this comment.
Or set the min length to 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR touches 62 files to bring the codebase into compliance after re-enabling the SwiftLint/SwiftFormat build-phase plugin (
BuildTools). Most of the diff is mechanical (formatting, indentation, rule-driven refactors) and should carry no functional change.Two spots are real bug fixes, called out explicitly below — please give those extra scrutiny.Given the size, a smoke test of notification handling and the home-avatar picker is more valuable than a full line-by-line read of every formatting hunk.
Real behavior change (but only in test set)
NotificationCenterDelegateImpl.swift —userNotificationCenter(_:didReceive:)was missingasync, so it never actually matchedUNUserNotificationCenterDelegate's compiler-bridged requirement fordidReceiveNotificationResponse:withCompletionHandler:. This means tapping a notification to open the app was silently not invoking this handler at all. Verified against the SDK header (withCompletionHandler:(void(^)(void))→ bridges toasyncwith no return value) and fixed. Worth a manual notification-tap test.XCTestCase.tearDown()overrides (MainUILayoutUITests,ToastUITests) mutated a@MainActor-isolated property from anonisolatedcontext (the synchronoustearDown()override doesn't inherit the class's@MainActorisolation). Switched to theasync throwsoverride, matching the pattern already used forsetUp().Mechanical cleanup
type_body_length,file_length) into same-fileextensions or new files — e.g.OpenHABWebViewModel's large injected-JS string constants moved to a newOpenHABWebViewInjectedJS.swift, with no behavior change.large_tuple) with small named structs inHomeAvatarViewandAvatarColorPairTests.HomeAvatarView's icon representation from raw SF Symbol name strings to SFSafeSymbols'SFSymboltype for compile-time safety at call sites.AvatarMode's persisted storage inOpenHABCoreintentionally stays a plainString— the mapping happens at the app-target boundary (AvatarImageHelper), so persistence format is unchanged.file_name(e.g.AppLifecycle.swift→NSNotification.Name.swift, matching the type it actually declares).shorthand_operator,for_where,statement_position,unavailable_condition,multiple_closures_with_trailing_closure,async_without_await(with scopedswiftlint:disablewhere the rule is a false positive against a protocol-required signature),orphaned_doc_comment,closure_end_indentation(plus a scopedswiftformat:disable indentwhere SwiftFormat has a known--ifdef no-indent+ closure indentation quirk).Test plan
xcodebuild buildfor theopenHABscheme succeeds cleanxcodebuild build-for-testingsucceeds (compiles all test targets, including UI tests)OpenHABCoreTests+openHABTestsSwiftsuites passComment generated with help of Claude Code](https://claude.com/claude-code)