Skip to content

Add consistency to parameter lists formatting #1805

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

Closed
wants to merge 1 commit into from
Closed

Add consistency to parameter lists formatting #1805

wants to merge 1 commit into from

Conversation

arbitrary-dev
Copy link
Contributor

To make it more in line with argument list formatting of #classes

@SethTisue
Copy link
Member

can't say I've seen this style around much. is there any evidence there's consensus on this? does scalafmt do it this way?

@arbitrary-dev
Copy link
Contributor Author

is there any evidence there's consensus on this?

Not that I'm aware of.

To my opinion, parameter lists for method should be formatted the same as for classes, but currently they are different, which is confusing.

does scalafmt do it this way?

Here's default formatting with scalafmt 2.7.5:

sbt:scalafmtRoot> tests/testOnly *FormatTests -- -z "Test default param list formatting"
[info] Compiling 1 Scala source to /home/man/work/scalafmt/scalafmt-dynamic/target/scala-2.13/classes ...
[info] Compiling 2 Scala sources to /home/man/work/scalafmt/scalafmt-core/jvm/target/scala-2.13/classes ...
FormatTests:92 Total explored: 316
[info] FormatTests:
[info] - default/DefDef.stat:327: Test default param list formatting           | *** FAILED ***
[info]   ===========
[info]   => Obtained
[info]   ===========
[info]   protected def forResource(resourceInfo: Any)(f: (JsonNode) => Any)(implicit
[info]       urlCreator: URLCreator,
[info]       configurer: OAuthConfiguration): Any = {
[info]     ???
[info]   }
[info]   
[info]            
[info]   =======
[info]   => Diff
[info]   =======
[info]   -protected def forResource(resourceInfo: Any)
[info]   -                         (f: (JsonNode) => Any)
[info]   -                         (implicit urlCreator: URLCreator, configurer: OAuthConfiguration): Any = {
[info]   +protected def forResource(resourceInfo: Any)(f: (JsonNode) => Any)(implicit
[info]   +    urlCreator: URLCreator,
[info]   +    configurer: OAuthConfiguration): Any = {
[info]      ??? (DefDef.stat:327)

Also long parameter lists hanging to the right are difficult to read on small screens, vertical scrolling is often required.

@SethTisue
Copy link
Member

The style guide doesn't aim to resolve all style questions, only questions on which consensus or near-consensus exists.

So I think we could accept this PR if it were modified to offer alternatives, but I don't think it's mergeable to enshrine the style you are recommending here as the style.

@SethTisue SethTisue marked this pull request as draft January 14, 2021 01:15
@SethTisue
Copy link
Member

closing for inactivity. happy to reopen if activity resumes

@SethTisue SethTisue closed this Feb 1, 2021
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