# Non idempotent formatting #192

Closed
opened this Issue Apr 19, 2016 · 2 comments

Projects
None yet
2 participants
Member

### olafurpg commented Apr 19, 2016

 See ``` - def log(formatToken: FormatToken): String = s"""\${log(formatToken.left)} - |\${log(formatToken.between:_*)} - |\${log(formatToken.right)}""".stripMargin + def log(formatToken: FormatToken): String = + s"""\${log(formatToken.left)} + |\${log( + formatToken.between: _*)} + |\${log(formatToken.right)}""".stripMargin``` Reformatting again produces: ``` def log(formatToken: FormatToken): String = s"""\${log(formatToken.left)} |\${log(formatToken.between: _*)} |\${log(formatToken.right)}""".stripMargin```

### paulp commented Apr 29, 2016

 Here's a non-idempotent situation not involving an interpolated string. ```class A { def traced(in: A => Unit, out: B => Unit): Fun[A, B] = ( f . mapIn[A] { x => in(x) ; x } . mapOut[B] { x => out(x) ; x } ) }``` becomes ```class A { def traced(in: A => Unit, out: B => Unit): Fun[A, B] = (f .mapIn[A] { x => in(x); x } .mapOut[B] { x => out(x); x }) }``` which becomes ```class A { def traced(in: A => Unit, out: B => Unit): Fun[A, B] = (f.mapIn[A] { x => in(x); x } .mapOut[B] { x => out(x); x }) }``` Also, it was a lot better before anything happened to it. And in the "watch out for the future" department, those leading dots are only necessary through 2.10. In 2.11 and beyond that can be written ``` def traced(in: A => Unit, out: B => Unit): Fun[A, B] = ( f mapIn[A] { x => in(x) ; x } mapOut[B] { x => out(x) ; x } )``` I think dotless syntax is far superior for readability but I doubt most people can handle it unless their formatter does all the handling of it, hint hint.
Member

### olafurpg commented Apr 30, 2016

 Thanks for the example! I think dotless syntax is far superior for readability but I doubt most people can handle it unless their formatter does all the handling of it, hint hint. Some auto migration tool would be nice, indeed. I'm not sure about baking it with scalafmt, I think it better belongs to another tool like scala-tidy, similar to clang-tidy.

Closed

Closed

### olafurpg added a commit that referenced this issue May 6, 2016

``` Follow spark coding style for massive return types. ```
`Partly fixes #192.`
``` 7bc2d1a ```

Closed

### olafurpg added a commit that referenced this issue May 6, 2016

``` Reformat project with 0.2.1 because of #192 ```
``` 021e4ff ```

### olafurpg added a commit that referenced this issue May 6, 2016

``` Fix buggy implementation of #171, towards #192 ```
``` 01a2d77 ```

### olafurpg added a commit that referenced this issue May 6, 2016

``` Add interpolation test from #192. ```
``` 60e1b58 ```

### olafurpg added a commit that referenced this issue May 6, 2016

``` Disable stripMargin alignment in default style, fixes #170. ```
`WIP towards #192.`
``` 73185ff ```

Closed