Skip to content

Fix most lint errors#76

Open
Moustachauve wants to merge 2 commits intomainfrom
fix-lint
Open

Fix most lint errors#76
Moustachauve wants to merge 2 commits intomainfrom
fix-lint

Conversation

@Moustachauve
Copy link
Owner

also allow TODOs

also allow TODOs
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 TODO comments, streamlining future development and ensuring a consistent codebase.

Highlights

  • SwiftLint Integration: Integrated SwiftLint as an Xcode build tool plugin by adding SwiftLintPlugins as a remote Swift Package Reference and a target dependency to the project.
  • Linting Rule Adjustments: Disabled the todo SwiftLint rule in .swiftlint.yml to allow TODO comments in the codebase, aligning with the PR description.
  • Codebase Formatting and Style Fixes: Applied numerous minor formatting and style fixes across various Swift files to adhere to SwiftLint conventions, including removing unnecessary blank lines, standardizing variable declarations, simplifying if conditions, and refining error handling syntax.
  • Robustness Improvements: Enhanced code robustness in several areas, such as updating optional chaining for Core Data persistent store descriptions, improving data decoding for network responses, and making DeviceStateInfo decoding in preview data more resilient with guard let.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +8 to 11
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

Suggested change
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) {

Comment on lines +5 to +19
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant