Skip to content
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

Feature Request: Support Automatic Conversion of snake_case to camelCase #4027

Closed
linkedlist771 opened this issue May 21, 2024 · 1 comment
Closed

Comments

@linkedlist771
Copy link

Configuration (required)

version = 3.7.3  // Latest scalafmt version as of May 21, 2024

Command-line parameters (required)

When I run scalafmt via CLI like this:

scalafmt --test 

it does not automatically convert snake_case to camelCase.

Steps

Given code like this:

val data_in = 42
def process_data(input_value: Int) = input_value * 2

Problem

Scalafmt does not modify the naming convention and leaves the code unchanged:

val data_in = 42
def process_data(input_value: Int) = input_value * 2

Expectation

I would like the formatted output to look like this:

val dataIn = 42
def processData(inputValue: Int) = inputValue * 2

Workaround

Currently, there is no automated workaround within scalafmt. Manual correction or custom scripts are the only options.

Notes

  • This feature would align scalafmt with the widely accepted camelCase convention in Scala.
  • A similar feature request has been discussed for other languages, suggesting a broader need.
  • While exploring solutions in the OpenXiangShan project, a custom Python script was developed, highlighting the lack of existing tooling for this conversion.
  • This feature origins from this PR.
@kitbellew
Copy link
Collaborator

scalafmt cannot do what you want. it's a syntactic tool, and you need a semantic tool instead, such as scalafix.

you should resubmit this in scalafix and, in the meantime, add a scalastyle rule such as a ClassNamesChecker to validate camels, snakes or kebabs, as needed.

P.S. The comment below was true a year ago.

version = 3.7.3  // Latest scalafmt version as of May 21, 2024

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

No branches or pull requests

2 participants