Skip to content

Commit fa5a571

Browse files
authored
Merge pull request #55 from cucumber/scalac-flags
Add recommended list of scalac flags for Scala 2.13
2 parents b2962b8 + a87de9f commit fa5a571

File tree

14 files changed

+148
-30
lines changed

14 files changed

+148
-30
lines changed

scala/pom.xml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,6 @@
4646
<groupId>net.alchim31.maven</groupId>
4747
<artifactId>scala-maven-plugin</artifactId>
4848
<version>${scala-maven-plugin.version}</version>
49-
<configuration>
50-
<args>
51-
<arg>-feature</arg>
52-
<arg>-deprecation</arg>
53-
</args>
54-
<excludes>
55-
<exclude>**/*.java</exclude>
56-
</excludes>
57-
</configuration>
5849
<executions>
5950
<execution>
6051
<id>regular-source-compilation</id>

scala/scala_2.11/pom.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
23
<modelVersion>4.0.0</modelVersion>
34

45
<parent>
@@ -81,6 +82,15 @@
8182
<plugin>
8283
<groupId>net.alchim31.maven</groupId>
8384
<artifactId>scala-maven-plugin</artifactId>
85+
<configuration>
86+
<args>
87+
<arg>-deprecation</arg>
88+
<arg>-feature</arg>
89+
</args>
90+
<excludes>
91+
<exclude>**/*.java</exclude>
92+
</excludes>
93+
</configuration>
8494
</plugin>
8595
<plugin>
8696
<groupId>org.apache.maven.plugins</groupId>

scala/scala_2.12/pom.xml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
23
<modelVersion>4.0.0</modelVersion>
34

45
<parent>
@@ -56,9 +57,9 @@
5657
</resources>
5758
<testSourceDirectory>../sources/src/test/scala</testSourceDirectory>
5859
<testResources>
59-
<testResource>
60-
<directory>../sources/src/test/resources</directory>
61-
</testResource>
60+
<testResource>
61+
<directory>../sources/src/test/resources</directory>
62+
</testResource>
6263
</testResources>
6364
<plugins>
6465
<plugin>
@@ -72,6 +73,17 @@
7273
<plugin>
7374
<groupId>net.alchim31.maven</groupId>
7475
<artifactId>scala-maven-plugin</artifactId>
76+
<configuration>
77+
<args>
78+
<!-- Emit warning and location for usages of deprecated APIs. -->
79+
<arg>-deprecation</arg>
80+
<!-- Emit warning and location for usages of features that should be imported explicitly. -->
81+
<arg>-feature</arg>
82+
</args>
83+
<excludes>
84+
<exclude>**/*.java</exclude>
85+
</excludes>
86+
</configuration>
7587
</plugin>
7688
<plugin>
7789
<groupId>org.apache.maven.plugins</groupId>

scala/scala_2.13/pom.xml

Lines changed: 90 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
23
<modelVersion>4.0.0</modelVersion>
34

45
<parent>
@@ -51,9 +52,9 @@
5152
</resources>
5253
<testSourceDirectory>../sources/src/test/scala</testSourceDirectory>
5354
<testResources>
54-
<testResource>
55-
<directory>../sources/src/test/resources</directory>
56-
</testResource>
55+
<testResource>
56+
<directory>../sources/src/test/resources</directory>
57+
</testResource>
5758
</testResources>
5859
<plugins>
5960
<plugin>
@@ -67,6 +68,91 @@
6768
<plugin>
6869
<groupId>net.alchim31.maven</groupId>
6970
<artifactId>scala-maven-plugin</artifactId>
71+
<configuration>
72+
<!-- https://nathankleyn.com/2019/05/13/recommended-scalac-flags-for-2-13/ -->
73+
<args>
74+
<!-- Emit warning and location for usages of deprecated APIs. -->
75+
<arg>-deprecation</arg>
76+
<!-- Explain type errors in more detail. -->
77+
<arg>-explaintypes</arg>
78+
<!-- Emit warning and location for usages of features that should be imported explicitly. -->
79+
<arg>-feature</arg>
80+
<!-- Existential types (besides wildcard types) can be written and inferred -->
81+
<arg>-language:existentials</arg>
82+
<!-- Allow macro definition (besides implementation and application) -->
83+
<arg>-language:experimental.macros</arg>
84+
<!-- Allow higher-kinded types -->
85+
<arg>-language:higherKinds</arg>
86+
<!-- Allow definition of implicit functions called views -->
87+
<arg>-language:implicitConversions</arg>
88+
<!-- Enable additional warnings where generated code depends on assumptions. -->
89+
<arg>-unchecked</arg>
90+
<!-- Wrap field accessors to throw an exception on uninitialized access. -->
91+
<arg>-Xcheckinit</arg>
92+
<!-- Fail the compilation if there are any warnings. -->
93+
<arg>-Xfatal-warnings</arg>
94+
<!-- Warn if an argument list is modified to match the receiver. -->
95+
<arg>-Xlint:adapted-args</arg>
96+
<!-- Evaluation of a constant arithmetic expression results in an error. -->
97+
<arg>-Xlint:constant</arg>
98+
<!-- Selecting member of DelayedInit. -->
99+
<arg>-Xlint:delayedinit-select</arg>
100+
<!-- A Scaladoc comment appears to be detached from its element. -->
101+
<arg>-Xlint:doc-detached</arg>
102+
<!-- Warn about inaccessible types in method signatures. -->
103+
<arg>-Xlint:inaccessible</arg>
104+
<!-- Warn when a type argument is inferred to be `Any`. -->
105+
<arg>-Xlint:infer-any</arg>
106+
<!-- A string literal appears to be missing an interpolator id. -->
107+
<arg>-Xlint:missing-interpolator</arg>
108+
<!-- Warn when non-nullary `def f()' overrides nullary `def f'. -->
109+
<arg>-Xlint:nullary-override</arg>
110+
<!-- Warn when nullary methods return Unit. -->
111+
<arg>-Xlint:nullary-unit</arg>
112+
<!-- Option.apply used implicit view. -->
113+
<arg>-Xlint:option-implicit</arg>
114+
<!-- Class or object defined in package object. -->
115+
<arg>-Xlint:package-object-classes</arg>
116+
<!-- Parameterized overloaded implicit methods are not visible as view bounds. -->
117+
<arg>-Xlint:poly-implicit-overload</arg>
118+
<!-- A private field (or class parameter) shadows a superclass field. -->
119+
<arg>-Xlint:private-shadow</arg>
120+
<!-- Pattern sequence wildcard must align with sequence component. -->
121+
<arg>-Xlint:stars-align</arg>
122+
<!-- A local type parameter shadows a type already in scope. -->
123+
<arg>-Xlint:type-parameter-shadow</arg>
124+
<!-- Warn when dead code is identified. -->
125+
<arg>-Ywarn-dead-code</arg>
126+
<!-- Warn when more than one implicit parameter section is defined. -->
127+
<arg>-Ywarn-extra-implicit</arg>
128+
<!-- Warn when numerics are widened. -->
129+
<arg>-Ywarn-numeric-widen</arg>
130+
<!-- Warn if an implicit parameter is unused. -->
131+
<arg>-Ywarn-unused:implicits</arg>
132+
<!-- Warn if an import selector is not referenced. -->
133+
<arg>-Ywarn-unused:imports</arg>
134+
<!-- Warn if a local definition is unused. -->
135+
<arg>-Ywarn-unused:locals</arg>
136+
<!-- Warn if a value parameter is unused. -->
137+
<arg>-Ywarn-unused:params</arg>
138+
<!-- Warn if a variable bound in a pattern is unused. -->
139+
<arg>-Ywarn-unused:patvars</arg>
140+
<!-- Warn if a private member is unused. -->
141+
<arg>-Ywarn-unused:privates</arg>
142+
<!-- Warn when non-Unit expression results are unused. -->
143+
<arg>-Ywarn-value-discard</arg>
144+
<!-- Enable paralellisation — change to desired number! -->
145+
<arg>-Ybackend-parallelism</arg>
146+
<arg>8</arg>
147+
<!-- Enables caching of classloaders for compiler plugins -->
148+
<arg>-Ycache-plugin-class-loader:last-modified</arg>
149+
<!-- and macro definitions. This can lead to performance improvements. -->
150+
<arg>-Ycache-macro-class-loader:last-modified</arg>
151+
</args>
152+
<excludes>
153+
<exclude>**/*.java</exclude>
154+
</excludes>
155+
</configuration>
70156
</plugin>
71157
<plugin>
72158
<groupId>org.apache.maven.plugins</groupId>

scala/sources/src/main/scala/io/cucumber/scala/ScalaDefaultDataTableEntryTransformerDefinition.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ trait ScalaDefaultDataTableEntryTransformerDefinition extends DefaultDataTableEn
1616

1717
override val location: StackTraceElement = new Exception().getStackTrace()(3)
1818

19-
override val tableEntryByTypeTransformer: TableEntryByTypeTransformer = (fromValue: JavaMap[String, String], toValueType: Type, tableCellByTypeTransformer: TableCellByTypeTransformer) => {
19+
override val tableEntryByTypeTransformer: TableEntryByTypeTransformer = (fromValue: JavaMap[String, String], toValueType: Type, _: TableCellByTypeTransformer) => {
2020
replaceEmptyPatternsWithEmptyString(fromValue.asScala.toMap)
2121
.map(details.body.apply(_, toValueType))
2222
.get

scala/sources/src/main/scala/io/cucumber/scala/ScalaDsl.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,6 @@ private[scala] trait StepDsl extends BaseScalaDsl {
486486

487487
object Fun0 {
488488

489-
import scala.language.implicitConversions
490-
491489
implicit def function0AsFun0(f: Function0[Any]): Fun0 = new Fun0(f)
492490

493491
}

scala/sources/src/main/scala/io/cucumber/scala/ScalaStepDefinition.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ trait ScalaStepDefinition extends StepDefinition with AbstractGlueDefinition {
2626
}
2727

2828
override def execute(args: Array[AnyRef]): Unit = {
29-
executeAsCucumber(stepDetails.body(args.toList))
29+
executeAsCucumber {
30+
stepDetails.body(args.toList)
31+
()
32+
}
3033
}
3134

3235
override def getPattern: String = stepDetails.pattern

scala/sources/src/test/scala/io/cucumber/scala/ScalaBackendTest.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ import org.junit.{Before, Test}
1111
import org.mockito.ArgumentMatchers.any
1212
import org.mockito.Mockito._
1313

14+
import scala.annotation.nowarn
1415
import scala.jdk.CollectionConverters._
1516

17+
@nowarn
1618
class ScalaBackendTest {
1719

1820
private val fakeGlue: Glue = mock(classOf[Glue])

scala/sources/src/test/scala/io/cucumber/scala/ScalaDslDocStringTypeTest.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package io.cucumber.scala
33
import io.cucumber.core.backend._
44
import org.junit.Test
55

6+
import scala.annotation.nowarn
67

8+
@nowarn
79
class ScalaDslDocStringTypeTest {
810

911
@Test

scala/sources/src/test/scala/io/cucumber/scala/ScalaDslHooksTest.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import org.junit.Assert.{assertEquals, assertTrue}
77
import org.junit.{Before, Test}
88
import org.mockito.Mockito.mock
99

10+
import scala.annotation.nowarn
11+
12+
@nowarn
1013
class ScalaDslHooksTest {
1114

1215
private val fakeState = mock(classOf[TestCaseState])

0 commit comments

Comments
 (0)