Conversation
also allow TODOs
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly improves the project's code quality and maintainability by integrating SwiftLint directly into the Xcode build process. It addresses a multitude of existing linting issues, standardizes code style across the application, and explicitly allows Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
The pull request includes several changes across multiple Swift files, primarily focusing on code cleanup and improvements to type safety and readability. Specifically, it introduces a dedicated HSBA struct in Color+Extensions.swift to improve code readability and type safety when dealing with color components. Also, in WebView.swift, Void is used instead of () to denote functions that return nothing, and a guard let statement is used to prevent crashes when a resource file is not found.
| private let downloadCompleted: (URL) -> Void | ||
|
|
||
| init(url: URL?, reload: Binding<Bool>, downloadCompleted: @escaping(URL) -> ()) { | ||
| init(url: URL?, reload: Binding<Bool>, downloadCompleted: @escaping (URL) -> Void) { | ||
| self.url = url |
There was a problem hiding this comment.
Using Void instead of () is the preferred and more explicit way to denote a function that returns nothing in Swift, improving clarity. Additionally, replacing the force unwrap (htmlPath!) with guard let makes the code more robust by preventing a crash if the resource file is not found.
| private let downloadCompleted: (URL) -> Void | |
| init(url: URL?, reload: Binding<Bool>, downloadCompleted: @escaping(URL) -> ()) { | |
| init(url: URL?, reload: Binding<Bool>, downloadCompleted: @escaping (URL) -> Void) { | |
| self.url = url | |
| private let downloadCompleted: (URL) -> Void | |
| init(url: URL?, reload: Binding<Bool>, downloadCompleted: @escaping (URL) -> Void) { |
| private struct HSBA { | ||
| var h: CGFloat | ||
| var s: CGFloat | ||
| var b: CGFloat | ||
| var a: CGFloat | ||
| } | ||
|
|
||
| private var hsbaComponents: HSBA? { | ||
| let uiColor = UIColor(self) | ||
| var h = CGFloat(0), s = CGFloat(0), b = CGFloat(0), a = CGFloat(0) | ||
|
|
||
| guard uiColor.getHue(&h, saturation: &s, brightness: &b, alpha: &a) else { | ||
| return nil | ||
| } | ||
| return (h, s, b, a) | ||
| return HSBA(h: h, s: s, b: b, a: a) |
There was a problem hiding this comment.
Introducing a dedicated HSBA struct instead of a tuple for color components significantly improves code readability and type safety. This makes the code easier to understand and maintain by providing meaningful names for the color components.
| private struct HSBA { | |
| var h: CGFloat | |
| var s: CGFloat | |
| var b: CGFloat | |
| var a: CGFloat | |
| } | |
| private var hsbaComponents: HSBA? { | |
| let uiColor = UIColor(self) | |
| var h = CGFloat(0), s = CGFloat(0), b = CGFloat(0), a = CGFloat(0) | |
| guard uiColor.getHue(&h, saturation: &s, brightness: &b, alpha: &a) else { | |
| return nil | |
| } | |
| return (h, s, b, a) | |
| return HSBA(h: h, s: s, b: b, a: a) | |
| private struct HSBA { | |
| var h: CGFloat | |
| var s: CGFloat | |
| var b: CGFloat | |
| var a: CGFloat | |
| } | |
| private var hsbaComponents: HSBA? { | |
| let uiColor = UIColor(self) | |
| var h = CGFloat(0), s = CGFloat(0), b = CGFloat(0), a = CGFloat(0) | |
| guard uiColor.getHue(&h, saturation: &s, brightness: &b, alpha: &a) else { | |
| return nil | |
| } | |
| return HSBA(h: h, s: s, b: b, a: a) | |
| } |
Add -skipPackagePluginValidation and -skipMacroValidation to the xcodebuild command in .github/workflows/check.yml. This prevents package plugin/macro validation from causing the simulator build to fail in CI (for the wled.xcodeproj wled scheme).
also allow TODOs