Install: follow-up style cleanup for InstallSafeDITool + Xcode build plugin#277
Merged
Install: follow-up style cleanup for InstallSafeDITool + Xcode build plugin#277
Conversation
… build plugin Follow-up to #273 covering style-guide violations surfaced by the second-pass self review. CLAUDE.md bars bare \`if { throw|return }\` patterns with implicit fall-through — the non-returning path must sit in an explicit \`else\`. - **InstallSafeDITool.swift: HTTP-status check.** The \`if httpResponse...,!(200..<300).contains(...) { throw ... }\` block used fall-through when the status was 2xx. Restructured to \`if let httpResponse { guard (200..<300).contains(...) else { throw } }\`. - **SafeDIGenerateDependencyTree.swift: Xcode real-scan vs scanner split.** The \`if runsRealScan { do-return-catch } ... PluginScanner fallback\` block returned from inside the \`if\` and fell through on the \`SafeDIToolLaunchError\` catch. Extracted the two paths into \`buildCommandsUsingRealScan\` (nil on recoverable launch failure) and \`buildCommandsUsingPluginScanner\`; the caller is now an \`if ... let commands { return commands } else { return scanner }\` with both branches returning. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #277 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 41 41
Lines 6796 6796
=========================================
Hits 6796 6796 🚀 New features to boost your workflow:
|
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.
Summary
Style-guide follow-up to #273. CLAUDE.md bars bare `if { return|throw }` patterns with implicit fall-through — the non-returning path has to sit in an explicit `else`.
Changes
`Plugins/InstallSafeDITool/InstallSafeDITool.swift` — HTTP status check for the downloaded asset. The old
```swift
if let httpResponse = response as? HTTPURLResponse,
!(200..<300).contains(httpResponse.statusCode)
{
throw DownloadFailedError(...)
}
```
falls through on 2xx. Restructured to
```swift
if let httpResponse = response as? HTTPURLResponse {
guard (200..<300).contains(httpResponse.statusCode) else { throw ... }
}
```
Same runtime behavior.
`Plugins/SafeDIGenerator/SafeDIGenerateDependencyTree.swift` — Xcode variant's real-scan / `PluginScanner` split. The old `if runsRealScan { do-return-catch } ...` block returned from inside the `if` and fell through on `SafeDIToolLaunchError`. Extracted:
Caller is now
```swift
if runsRealScan, let commands = try buildCommandsUsingRealScan(...) {
return commands
} else {
return buildCommandsUsingPluginScanner(...)
}
```
Both branches return. Runtime behavior unchanged: `ProcessError` still surfaces, `LaunchError` still warns + falls to scanner.
What this doesn't do
Test plan
🤖 Generated with Claude Code