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

Allow usage of "behavior of" (used in ScalaTest) by default when AvoidInfix is enabled #3699

Closed
piter75 opened this issue Nov 23, 2023 · 0 comments · Fixed by #3711
Closed

Comments

@piter75
Copy link

piter75 commented Nov 23, 2023

Configuration

Please paste the contents of your .scalafmt.conf file here:

version = 3.7.17

rewrite {
  rules = [AvoidInfix]
}

Steps

Given code like this:

behavior of "XYZ"

Problem

Scalafmt formats code like this:

behavior.of("XYZ")

Expectation

I would like the formatted output to look like this:

behavior of "XYZ"

Workaround

A workaround is to add the following line to the configuration:

rewrite.neverInfix.exclude."+" = "of"

However it seems to be an unnecessary tediousness and complexity of configuration especially given that most other ScalaTest infix keywords are already excluded from AvoidInfix rule by default.

Proposed solution

I am willing to submit a pull request (PR) that adds "of" to the default neverInfix.exclude list.

However, it's worth noting that the "behavior of" example is used in tests as a manual token append demonstration. We could potentially choose a different keyword in the test scenario to make the change.
I would like to confirm this before contributing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant