Skip to content

Commit

Permalink
Merge pull request #458 from diffplug/feature/bump-scalafmt-default
Browse files Browse the repository at this point in the history
Feature/bump scalafmt default
  • Loading branch information
nedtwigg committed Sep 24, 2019
2 parents a7c74de + 009c93a commit 12eea16
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -18,6 +18,7 @@ You might be looking for:
- combined with up-to-date checking, could lead to even more confusing results (https://github.com/diffplug/spotless/issues/338)
- only affects the gradle plugin, since that was the only plugin to use this feature
* Minor change to `TestProvisioner`, which should fix the cache-breaking issues, allowing us to speed-up the CI builds a bit.
* Bumped `scalafmt` default version from `1.1.0` to `2.0.1`, since there are [bugs](https://github.com/diffplug/spotless/issues/454) in the old default ([#458](https://github.com/diffplug/spotless/pull/458)).

### Version 1.24.1 - August 12th 2018 (javadoc [lib](https://diffplug.github.io/spotless/javadoc/spotless-lib/1.24.1/) [lib-extra](https://diffplug.github.io/spotless/javadoc/spotless-lib-extra/1.24.1/), artifact [lib]([jcenter](https://bintray.com/diffplug/opensource/spotless-lib), [lib-extra]([jcenter](https://bintray.com/diffplug/opensource/spotless-lib-extra)))

Expand Down
Expand Up @@ -40,7 +40,7 @@ public class ScalaFmtStep {
private ScalaFmtStep() {}

private static final Pattern VERSION_PRE_2_0 = Pattern.compile("[10]\\.(\\d+)\\.\\d+");
private static final String DEFAULT_VERSION = "1.1.0";
private static final String DEFAULT_VERSION = "2.0.1";
static final String NAME = "scalafmt";
static final String MAVEN_COORDINATE_PRE_2_0 = "com.geirsson:scalafmt-core_2.11:";
static final String MAVEN_COORDINATE = "org.scalameta:scalafmt-core_2.11:";
Expand Down
1 change: 1 addition & 0 deletions plugin-gradle/CHANGES.md
Expand Up @@ -14,6 +14,7 @@
([#338](https://github.com/diffplug/spotless/issues/338))
- Fixed now!
* When you specify `targetExclude()`, spotless no longer silently removes `build` directories from the exclusion ([#457](https://github.com/diffplug/spotless/pull/457)).
* Bumped `scalafmt` default version from `1.1.0` to `2.0.1`, since there are [bugs](https://github.com/diffplug/spotless/issues/454) in the old default ([#458](https://github.com/diffplug/spotless/pull/458)).

### Version 3.24.2 - August 19th 2019 ([javadoc](https://diffplug.github.io/spotless/javadoc/spotless-plugin-gradle/3.24.1/), [jcenter](https://bintray.com/diffplug/opensource/spotless-plugin-gradle/3.24.1))

Expand Down
Expand Up @@ -36,6 +36,6 @@ public void integration() throws IOException {
setFile("scalafmt.conf").toResource("scala/scalafmt/scalafmt.conf");
setFile("src/main/scala/basic.scala").toResource("scala/scalafmt/basic.dirty");
gradleRunner().withArguments("spotlessApply").build();
assertFile("src/main/scala/basic.scala").sameAsResource("scala/scalafmt/basic.cleanWithCustomConf");
assertFile("src/main/scala/basic.scala").sameAsResource("scala/scalafmt/basic.cleanWithCustomConf_2.0.1");
}
}
1 change: 1 addition & 0 deletions plugin-maven/CHANGES.md
Expand Up @@ -6,6 +6,7 @@
* Fixes [#410](https://github.com/diffplug/spotless/issues/410) AccessDeniedException in MinGW/ GitBash.
* Also fixes occasional [hang on NFS due to filesystem timers](https://github.com/diffplug/spotless/pull/407#issuecomment-514824364).
* Eclipse-based formatters used to leave temporary files around ([#447](https://github.com/diffplug/spotless/issues/447)). This is now fixed, but only for eclipse 4.12+, no back-port to older Eclipse formatter versions is planned. ([#451](https://github.com/diffplug/spotless/issues/451))
* Bumped `scalafmt` default version from `1.1.0` to `2.0.1`, since there are [bugs](https://github.com/diffplug/spotless/issues/454) in the old default ([#458](https://github.com/diffplug/spotless/pull/458)).

### Version 1.24.1 - August 12th 2019 ([javadoc](https://diffplug.github.io/spotless/javadoc/spotless-maven-plugin/1.24.1/), [jcenter](https://bintray.com/diffplug/opensource/spotless-maven-plugin/1.24.1))

Expand Down
Expand Up @@ -24,7 +24,7 @@ public class IncludesExcludesTest extends MavenIntegrationTest {
private static final String JAVA_FORMATTED = "java/eclipse/JavaCodeFormatted.test";
private static final String JAVA_UNFORMATTED = "java/eclipse/JavaCodeUnformatted.test";
private static final String SCALA_UNFORMATTED = "scala/scalafmt/basic.dirty";
private static final String SCALA_FORMATTED = "scala/scalafmt/basic.clean";
private static final String SCALA_FORMATTED = "scala/scalafmt/basic.clean_2.0.1";

@Test
public void testDefaultIncludesJava() throws Exception {
Expand Down
Expand Up @@ -93,7 +93,7 @@ public void testConfigurationDependency() throws Exception {
assertFile("two/src/main/java/test1.java").sameAsResource("java/eclipse/JavaCodeFormatted.test");
assertFile("two/src/test/java/test2.java").sameAsResource("java/eclipse/JavaCodeFormatted.test");

assertFile("three/src/main/scala/test1.scala").sameAsResource("scala/scalafmt/basic.cleanWithCustomConf");
assertFile("three/src/test/scala/test2.scala").sameAsResource("scala/scalafmt/basic.cleanWithCustomConf");
assertFile("three/src/main/scala/test1.scala").sameAsResource("scala/scalafmt/basic.cleanWithCustomConf_2.0.1");
assertFile("three/src/test/scala/test2.scala").sameAsResource("scala/scalafmt/basic.cleanWithCustomConf_2.0.1");
}
}
Expand Up @@ -24,7 +24,7 @@ public class ScalafmtTest extends MavenIntegrationTest {
public void testScalafmtWithDefaultConfig() throws Exception {
writePomWithScalaSteps("<scalafmt/>");

runTest("scala/scalafmt/basic.clean");
runTest("scala/scalafmt/basic.clean_2.0.1");
}

@Test
Expand All @@ -36,7 +36,7 @@ public void testScalafmtWithCustomConfig() throws Exception {
" <file>${project.basedir}/scalafmt.conf</file>",
"</scalafmt>");

runTest("scala/scalafmt/basic.cleanWithCustomConf");
runTest("scala/scalafmt/basic.cleanWithCustomConf_2.0.1");
}

private void runTest(String s) throws Exception {
Expand Down
@@ -0,0 +1,25 @@
@foobar("annot", {
val x = 2
val y = 2 // y=2
x + y
})
object a
extends b
with c {
def foo[
T: Int#Double#Triple,
R <% String
](
@annot1
x: Int @annot2 =
2,
y: Int = 3
): Int = {
"match" match {
case 1 | 2 =>
3
case <A>2</A> =>
2
}
}
}
18 changes: 18 additions & 0 deletions testlib/src/main/resources/scala/scalafmt/basic.clean_2.0.1
@@ -0,0 +1,18 @@
@foobar("annot", {
val x = 2
val y = 2 // y=2
x + y
})
object a extends b with c {
def foo[T: Int#Double#Triple, R <% String](
@annot1
x: Int @annot2 = 2,
y: Int = 3
): Int = {
"match" match {
case 1 | 2 =>
3
case <A>2</A> => 2
}
}
}
Expand Up @@ -29,16 +29,18 @@
public class ScalaFmtStepTest extends ResourceHarness {
@Test
public void behaviorDefaultConfig() throws Exception {
FormatterStep step = ScalaFmtStep.create(TestProvisioner.mavenCentral());
StepHarness.forStep(step)
.testResource("scala/scalafmt/basic.dirty", "scala/scalafmt/basic.clean");
StepHarness.forStep(ScalaFmtStep.create("1.1.0", TestProvisioner.mavenCentral(), null))
.testResource("scala/scalafmt/basic.dirty", "scala/scalafmt/basic.clean_1.1.0");
StepHarness.forStep(ScalaFmtStep.create("2.0.1", TestProvisioner.mavenCentral(), null))
.testResource("scala/scalafmt/basic.dirty", "scala/scalafmt/basic.clean_2.0.1");
}

@Test
public void behaviorCustomConfig() throws Exception {
FormatterStep step = ScalaFmtStep.create(ScalaFmtStep.defaultVersion(), TestProvisioner.mavenCentral(), createTestFile("scala/scalafmt/scalafmt.conf"));
StepHarness.forStep(step)
.testResource("scala/scalafmt/basic.dirty", "scala/scalafmt/basic.cleanWithCustomConf");
StepHarness.forStep(ScalaFmtStep.create("1.1.0", TestProvisioner.mavenCentral(), createTestFile("scala/scalafmt/scalafmt.conf")))
.testResource("scala/scalafmt/basic.dirty", "scala/scalafmt/basic.cleanWithCustomConf_1.1.0");
StepHarness.forStep(ScalaFmtStep.create("2.0.1", TestProvisioner.mavenCentral(), createTestFile("scala/scalafmt/scalafmt.conf")))
.testResource("scala/scalafmt/basic.dirty", "scala/scalafmt/basic.cleanWithCustomConf_2.0.1");
}

@Test
Expand Down

0 comments on commit 12eea16

Please sign in to comment.