-
Notifications
You must be signed in to change notification settings - Fork 60
[DISCUSSION ONLY - DO NOT MERGE] Added CheckStyle and Spotless plugins for code checking and formatting #141
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
base: main
Are you sure you want to change the base?
Conversation
…matting. Signed-off-by: Sun Yuhan <sunyuhan1998@users.noreply.github.com>
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 @sunyuhan1998, 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 is a discussion-only proposal to integrate code style checking and automatic formatting tools into the project. My goal is to establish a consistent code style across the repository and provide mechanisms for developers to easily adhere to it, improving readability and maintainability. It introduces Checkstyle for static analysis and Spotless for formatting, both integrated into the Maven build process.
Highlights
- Introduction of Code Quality Tools: I've introduced both Checkstyle and Spotless Maven plugins to enforce code style and enable automatic formatting. This aims to unify the codebase's appearance and reduce common formatting issues.
- Maven Integration: Both Checkstyle and Spotless are configured to run during the Maven
validate
phase. This ensures that style checks and formatting validations are performed early in the build lifecycle. - Checkstyle Configuration: Checkstyle is configured with a custom rule set (
src/checkstyle/checkstyle.xml
) focusing initially on import-related rules, specifically disallowing wildcard imports, redundant imports, illegal imports, and unused imports. More rules can be added later as needed. - Spotless Configuration: Spotless is set up to use Google Java Format with the AOSP style. It also includes a rule to automatically remove unused imports, providing basic code cleanup capabilities.
- Usage Instructions: To trigger the checks,
mvn clean validate
can be run. For automatic formatting via Spotless,mvn spotless:apply
is available.
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 introduces Checkstyle and Spotless to enforce code style and formatting, which is a great step for the project's maintainability. My review focuses on the Maven configuration for these new plugins. I've identified a few critical issues, such as incorrect plugin and dependency versions and a misconfigured path for the Checkstyle rules, which would cause build failures. I've also included suggestions to update to the latest tool versions and to simplify the Spotless configuration for better clarity. Addressing these points will ensure the new tools are set up correctly and effectively.
@sunyuhan1998 Just about to get on a plane, but will look later/tomorrow. In the meantime, it could be good to see what kind of stuff it reports against the existing codebase. Maybe as a link to a gist, if it is very long :-) |
BTW I converted the PR to a draft, so that it cannot be merged |
Sure, no problem. This is just a rough experimental attempt. I think it will still take some time before we actually integrate it, and during that period we can further discuss and refine the plan in detail. |
We need to add a code style checking and automatic formatting plugin to unify the code style and automatically handle common formatting issues.
In this PR, the
Checkstyle
andSpotless
plugins have been introduced. ForCheckstyle
, only some of the previously discussed rules have been included in the rule filesrc/checkstyle/checkstyle.xml
, such as disallowing importing unused classes and disallowing wildcard imports. More rules can be added in the future if needed.As for
Spotless
, it is currently using the default rules. Both plugins run during the Mavenvalidate
phase.You can directly run
mvn clean validate
to trigger the checks from both plugins, and runmvn spotless:apply
to trigger Spotless to automatically format the code.@kabir Do you think this direction aligns with what we're hoping for?