Skip to content

Conversation

@grundprinzip
Copy link
Contributor

What changes were proposed in this pull request?

When using the scalafmt.conf file as provided by the project repository to organize and optimize imports there is a case in which un-desired behavior appears.

If the import group does not fit on a single line, Scalafmt will by default try to bin-pack and then break out over mulitple lines.

For example:

import org.apache.spark.sql.catalyst.analysis.{UnresolvedAlias, UnresolvedAttribute, UnresolvedFunction, UnresolvedRelation, UnresolvedStar}

will become

import org.apache.spark.sql.catalyst.analysis.{
  UnresolvedAlias,
  UnresolvedAttributed,
  ...
}

In previous code reviews this has been marked as departing from the consistency of the Spark code base. This patch enables an option in Scalafmt to force the import group on a single line even if it exceeds the max line length.

Why are the changes needed?

Code consistency.

Does this PR introduce any user-facing change?

No

When using the scalafmt.conf file as provided by the project repository to
organize and optimize imports there is a case in which un-desired behavior
appears.

If the import group does not fit on a single line, Scalafmt will by default
try to bin-pack and then break out over mulitple lines.

For example:

    import org.apache.spark.sql.catalyst.analysis.{UnresolvedAlias, UnresolvedAttribute, UnresolvedFunction, UnresolvedRelation, UnresolvedStar}

will become

    import org.apache.spark.sql.catalyst.analysis.{
      UnresolvedAlias,
      UnresolvedAttributed,
      ...
    }

In previous code reviews this has been marked as departing from the consistency
of the Spark code base. This patch enables an option in Scalafmt to force
the import group on a single line even if it exceeds the max line length.
@grundprinzip grundprinzip marked this pull request as ready for review October 14, 2022 06:44
Copy link
Member

@HyukjinKwon HyukjinKwon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would have been better to have a JIRA since this isn't virtually same before/after the fix:

If the change is new, then it usually needs a new JIRA. However, trivial changes, where the what should change is virtually the same as the how it should change do not require a JIRA. Example: Fix typos in Foo scaladoc

https://spark.apache.org/contributing.html

Otherwise LGTM.

@grundprinzip grundprinzip changed the title [BUILD] Force import groups on a single line. [SPARK-40797] [BUILD] Force import groups on a single line. Oct 14, 2022
@grundprinzip
Copy link
Contributor Author

Created a JIRA and updated the title.

@HyukjinKwon
Copy link
Member

Merged to master.

Since CI doesn't have anything to do with this change.

SandishKumarHN pushed a commit to SandishKumarHN/spark that referenced this pull request Dec 12, 2022
### What changes were proposed in this pull request?

When using the scalafmt.conf file as provided by the project repository to organize and optimize imports there is a case in which un-desired behavior appears.

If the import group does not fit on a single line, Scalafmt will by default try to bin-pack and then break out over mulitple lines.

For example:

    import org.apache.spark.sql.catalyst.analysis.{UnresolvedAlias, UnresolvedAttribute, UnresolvedFunction, UnresolvedRelation, UnresolvedStar}

will become

    import org.apache.spark.sql.catalyst.analysis.{
      UnresolvedAlias,
      UnresolvedAttributed,
      ...
    }

In previous code reviews this has been marked as departing from the consistency of the Spark code base. This patch enables an option in Scalafmt to force the import group on a single line even if it exceeds the max line length.

### Why are the changes needed?
Code consistency.

### Does this PR introduce _any_ user-facing change?
No

Closes apache#38252 from grundprinzip/scalafmt.

Authored-by: Martin Grund <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
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

Successfully merging this pull request may close these issues.

2 participants