-
Notifications
You must be signed in to change notification settings - Fork 72
Apply spotless #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apply spotless #47
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @lethargicpanda, 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 introduces and configures the Spotless code formatter across the ai-catalog
project. This ensures consistent code style for Kotlin and Kotlin Gradle files by applying ktlint
rules and standardizing formatting, including license headers and trailing commas.
Highlights
- Integration of Spotless: The Spotless Gradle plugin has been successfully integrated into the
ai-catalog
project, enabling automated code formatting. - Code Formatting Configuration: Spotless is configured to use
ktlint
for both Kotlin (.kt
) and Kotlin Gradle (.kts
) files. This configuration enforces the Android Studio code style, allows trailing commas, and sets a maximum line length of 140 characters. - EditorConfig Definition: A new
.editorconfig
file has been added to theai-catalog
directory, providing granular control overktlint
rules and disabling several standard checks to align with project preferences. - Project-wide Code Reformatting: Numerous Kotlin and Kotlin Gradle files across the
ai-catalog/samples
directory have been automatically reformatted. This includes consistent application of trailing commas, updated license headers, and general code style improvements.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
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 issue 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 is currently in preview and 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 to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
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. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request integrates Spotless into the project, standardizing code formatting and style. It includes updates to the root build.gradle.kts
and the addition of a .editorconfig
file. A duplicated configuration entry in .editorconfig
was identified and should be removed.
ktlint_standard_enum-entry-name-case = disabled | ||
ktlint_standard_multiline-if-else = disabled | ||
ktlint_standard_no-empty-first-line-in-method-block = disabled | ||
ktlint_standard_package-name = disabled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bentrengrove I applied spotless, let me know if I am missing something here. |
Might want to update the README to talk about how to apply spotless |
data class ChatMessage(val text: String, val timestamp: Long, val isIncoming: Boolean, val senderIconUrl: Uri?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this better? Git diffs would have less conflicts if we have it per line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect that's how the klint/spotless rule is defined.
I personally prefer multiline too for readability, but it don't think it will have such an impact on merge conflict.
We can technically override it but I don't know if it is really worth the effort.
@bentrengrove any thoughts on this? Did you deactivate/override some rules in some repos?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for for readability as well. Wondering how spotless rules are defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, spotless is configured to run klint
standard rules (defined here). It looks like it's standard across all our Android repos
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we generally disable rules when they go against the Compose API guidelines e.g. function naming as composables should be MyComposable
not myComposable
.
If you can work out the rule that is causing the flattening of this data class, feel free to disable it. I agree that it is more readable with each parameter on its own line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it is ktlint_class_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than
. You could add that to your .editorconfig
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I updated the rule to keep the multiline params.
Apply spotless to project:
ai-catalog/build.gradle.kts
to add spotless tasksai-catalog/.editorconfig