gradle-baseline icon indicating copy to clipboard operation
gradle-baseline copied to clipboard

Support record types

Open raiju opened this issue 4 years ago • 2 comments

What happened?

When using record types, I hit the following issues:

  • Misfiring StrictUnusedVariable:
Foo.java:43: error: [StrictUnusedVariable] The parameter 'a' is never read.
    record Foo(int a, int b) {}
  • Checkstyle; record in class: Checkstyle: Method name 'Foo' must match pattern '^[a-z][a-zA-Z0-9_]+$'.

  • checkUnusedDependenciesMain fails with This feature requires ASM8_EXPERIMENTAL

I ended up adding the following overrides for now:

build.gradle

tasks.withType(JavaCompile).configureEach {
    options.compilerArgs += ["--enable-preview"]
    options.errorprone.disable 'StrictUnusedVariable'
}
tasks.javadoc.options {
    addBooleanOption('-enable-preview', true)
    addStringOption('-release', '14')
}
tasks.withType(Test).configureEach {
    jvmArgs(['--enable-preview'])
}
tasks.checkUnusedDependenciesMain.enabled = false

custom-suppressions.xml

...
    <suppress files="[/\\]src[/\\]" checks="MethodName" />
...

What did you want to happen?

Records are supported without issues.

raiju avatar Jun 11 '20 21:06 raiju

@raiju can you confirm that this issue has been resolved?

ferozco avatar Jun 12 '20 17:06 ferozco

--- a/build.gradle
+++ b/build.gradle
@@ -10,7 +10,7 @@ buildscript {
         classpath 'com.palantir.jakarta-renames:gradle-jakarta-renames:0.3.11'
         classpath 'com.palantir.javaformat:gradle-palantir-java-format:1.0.0'
         classpath 'com.palantir.apollo:gradle-apollo:0.69.0'
-        classpath 'com.palantir.baseline:gradle-baseline-java:3.23.0'
+        classpath 'com.palantir.baseline:gradle-baseline-java:3.26.0'
         classpath 'com.palantir.blacklist:gradle-blacklist-plugin:0.13.0'
         classpath 'com.palantir.conjure.backcompat:gradle-conjure-backcompat:3.4.1'
         classpath 'com.palantir.deployability:gradle-sls-docker:1.13.0'
diff --git a/scenarios/build.gradle b/scenarios/build.gradle
index 16cf81b..15b6cb0 100644
--- a/scenarios/build.gradle
+++ b/scenarios/build.gradle
@@ -19,7 +19,6 @@ sourceCompatibility = 14
 // Records!
 tasks.withType(JavaCompile).configureEach {
     options.compilerArgs += ["--enable-preview"]
-    options.errorprone.disable 'StrictUnusedVariable'
 }

I still get StrictUnusedVariable errors when run with this diff ^

The checkUnusedDependenciesMain task also still fails (with the same error)

raiju avatar Jun 12 '20 18:06 raiju