Skip to content

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

@piter75

Description

@piter75

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions