-
Notifications
You must be signed in to change notification settings - Fork 250
Update scalafmt configuration for Scala 3 #679
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
Conversation
- Change dialect from scala213source3 to scala3 - Add StandardConvention project layout - Reduce maxColumn from 180 to 100 for better readability - Add Scala 3 specific rewrite rules for modern syntax - Configure newlines and docstring formatting 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
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 @xerial, 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 focuses on modernizing the code formatting rules for Scala 3 projects by updating the .scalafmt.conf file. The changes aim to enhance code readability, enforce consistent styling, and leverage new Scala 3 syntax features through automated rewrites, aligning the project's formatting with current Scala 3 best practices.
Highlights
- Scala 3 Compatibility: Updated the
scalafmtdialect fromscala213source3toscala3to ensure proper formatting and support for Scala 3.7.1 features. - Code Readability & Style: Reduced the maximum column width from 180 to 100 characters and introduced the
StandardConventionproject layout for improved code readability and organization. - Modern Scala 3 Syntax Rewrites: Enabled Scala 3 specific rewrite rules to automatically convert code to new syntax, remove optional braces, and insert end markers for larger code blocks (over 30 lines).
- Formatting Consistency: Configured docstring formatting to include a blank first line and refined newline rules for top-level statements and source files to ensure consistent code style throughout the project.
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 updates the scalafmt configuration to align with Scala 3 best practices, improving code readability and consistency. The changes include updating the dialect, reducing the line length, and adding modern rewrite rules. My review identified a critical issue with an invalid scalafmt version that will break the build, and a medium-severity issue where a formatting rule doesn't match its descriptive comment. Addressing these points will ensure the new configuration is both functional and clear.
| @@ -1,5 +1,16 @@ | |||
| version = 3.9.4 | |||
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.
The specified scalafmt version 3.9.4 does not appear to be a valid published version. The latest stable version of scalafmt is 3.8.1. Using a non-existent version will cause the build to fail when sbt-scalafmt attempts to download the runner. Please update this to a valid, published version.
version = 3.8.1
| newlines.topLevelStatementBlankLines = [ | ||
| { | ||
| blanks { after = 1 } | ||
| } | ||
| ] |
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.
The comment on line 10, # Add a new line before case class, is inconsistent with the configuration below it. The current rule will add a blank line after every top-level statement, not just before case class definitions. This is because the regexes property is not specified and defaults to [".*"], which matches all top-level statements.
This broad rule could lead to undesirable formatting, such as extra newlines after the last import statement or at the end of a file.
To align the rule with the comment's intent, it should be made more specific to target only case class definitions.
newlines.topLevelStatementBlankLines = [
{
regexes = ["^case class"]
blanks.before = 1
}
]
Summary
scala213source3toscala3StandardConventionproject layout for better organizationChanges
scala213source3toscala3to properly support Scala 3.7.1StandardConventionproject layoutTest plan
🤖 Generated with Claude Code