Skip to content

Commit dd58e28

Browse files
committed
Declare JUnit test classes package-private and final
Error Prone now fails the build on Picnic's JUnitClassModifiers, the first of the checks vfs-s3 makes build-breaking to be switched on here: a JUnit 5 test class that is not abstract is package-private and final. Its suggested fix changed the 25 test classes that were public or not final. None of them is extended or used outside its package.
1 parent 0829854 commit dd58e28

26 files changed

Lines changed: 47 additions & 47 deletions

‎buildSrc/src/main/groovy/open-java-format.error-prone-conventions.gradle‎

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,26 @@ pluginManager.withPlugin('java-gradle-plugin') {
2828
}
2929
}
3030

31-
// The checks vfs-s3 makes build-breaking. Off until the code is fixed, one check at a time:
32-
// JUnitMethodDeclaration 206, StaticImport 84, LexicographicalAnnotationListing 46, JUnitClassModifiers 25,
31+
// The checks vfs-s3 makes build-breaking. The commented ones stay off until the code is fixed, one check at a
32+
// time: JUnitMethodDeclaration 206, StaticImport 84, LexicographicalAnnotationListing 46,
3333
// RedundantStringConversion 6, AlmostJavadoc 3 findings; the rest have none.
34-
//tasks.withType(JavaCompile).configureEach {
35-
// options.errorprone {
36-
// error('StaticImport')
37-
// error('UnnecessarilyFullyQualified')
38-
// error('EmptyBlockTag')
39-
// error('OperatorPrecedence')
40-
// error('RedundantStringConversion')
41-
// error('PatternMatchingInstanceof')
42-
// error('UnnecessaryParentheses')
43-
// error('LexicographicalAnnotationListing')
44-
// error('JUnitMethodDeclaration')
45-
// error('JUnitClassModifiers')
46-
// error('MissingSummary')
47-
// error('AlmostJavadoc')
48-
// error('BadImport')
49-
// error('JdkObsolete')
50-
// // NonStaticImport (Picnic) is the inverse of StaticImport and would give contradictory advice.
51-
// disable('NonStaticImport')
52-
// }
53-
//}
34+
tasks.withType(JavaCompile).configureEach {
35+
options.errorprone {
36+
//error('StaticImport')
37+
//error('UnnecessarilyFullyQualified')
38+
//error('EmptyBlockTag')
39+
//error('OperatorPrecedence')
40+
//error('RedundantStringConversion')
41+
//error('PatternMatchingInstanceof')
42+
//error('UnnecessaryParentheses')
43+
//error('LexicographicalAnnotationListing')
44+
//error('JUnitMethodDeclaration')
45+
error('JUnitClassModifiers')
46+
//error('MissingSummary')
47+
//error('AlmostJavadoc')
48+
//error('BadImport')
49+
//error('JdkObsolete')
50+
// NonStaticImport (Picnic) is the inverse of StaticImport and would give contradictory advice.
51+
//disable('NonStaticImport')
52+
}
53+
}

‎gradle-open-java-format/src/test/java/com/palantir/javaformat/gradle/AppliesWithoutSpotlessTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* Most projects that apply the formatter never apply Spotless, so there are no Spotless classes on their buildscript
2929
* classpath. The Spotless integration has to stay dormant there instead of failing the whole plugin.
3030
*/
31-
class AppliesWithoutSpotlessTest {
31+
final class AppliesWithoutSpotlessTest {
3232

3333
@TempDir
3434
private Path projectDir;

‎gradle-open-java-format/src/test/java/com/palantir/javaformat/gradle/ConfigureJavaFormatterXmlTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import org.junit.jupiter.params.provider.CsvSource;
3434
import org.junit.jupiter.params.provider.MethodSource;
3535

36-
class ConfigureJavaFormatterXmlTest {
36+
final class ConfigureJavaFormatterXmlTest {
3737

3838
@Language("xml")
3939
private static final String EXISTING_CLASS_PATH = """

‎gradle-open-java-format/src/test/java/com/palantir/javaformat/gradle/FormatDiffTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import org.junit.jupiter.params.ParameterizedTest;
4242
import org.junit.jupiter.params.provider.MethodSource;
4343

44-
class FormatDiffTest {
44+
final class FormatDiffTest {
4545

4646
private static final File CLASSPATH_FILE = new File("build/impl.classpath");
4747
private static final File NATIVE_IMAGE_FILE = new File("build/nativeImage.path");

‎gradle-open-java-format/src/test/java/com/palantir/javaformat/gradle/FormatDiffWithoutJavacExportsTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* internals (#19). It fails before the first file now, naming the two settings that make the formatter run. This
3131
* class runs in the default test task; PalantirJavaFormatPluginTest does not, because it needs the native binary.
3232
*/
33-
class FormatDiffWithoutJavacExportsTest {
33+
final class FormatDiffWithoutJavacExportsTest {
3434

3535
/** ./gradlew writeImplClasspath generates this file. Forward slashes: the path goes into a Groovy string. */
3636
private static final String CLASSPATH_FILE =

‎gradle-open-java-format/src/test/java/com/palantir/javaformat/gradle/PalantirJavaFormatIdeaPluginTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import org.junit.jupiter.params.ParameterizedTest;
3636
import org.junit.jupiter.params.provider.ValueSource;
3737

38-
class PalantirJavaFormatIdeaPluginTest {
38+
final class PalantirJavaFormatIdeaPluginTest {
3939

4040
// Forward slashes: the path goes into a Groovy string, where a Windows backslash would start an escape.
4141
private static final String NATIVE_IMAGE_FILE =

‎gradle-open-java-format/src/test/java/com/palantir/javaformat/gradle/PalantirJavaFormatPluginTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.junit.jupiter.params.ParameterizedTest;
2727
import org.junit.jupiter.params.provider.CsvSource;
2828

29-
class PalantirJavaFormatPluginTest {
29+
final class PalantirJavaFormatPluginTest {
3030

3131
/** ./gradlew writeImplClasspath generates this file. */
3232
// Forward slashes: the path goes into a Groovy string, where a Windows backslash would start an escape.

‎gradle-open-java-format/src/test/java/com/palantir/javaformat/gradle/PalantirJavaFormatSpotlessPluginTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import org.junit.jupiter.params.ParameterizedTest;
2626
import org.junit.jupiter.params.provider.CsvSource;
2727

28-
class PalantirJavaFormatSpotlessPluginTest {
28+
final class PalantirJavaFormatSpotlessPluginTest {
2929

3030
/** ./gradlew writeImplClasspath generates this file. */
3131
// Forward slashes: the path goes into a Groovy string, where a Windows backslash would start an escape.

‎gradle-open-java-format/src/test/java/com/palantir/javaformat/gradle/SpotlessExcludesTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import org.junit.jupiter.params.ParameterizedTest;
2828
import org.junit.jupiter.params.provider.ValueSource;
2929

30-
class SpotlessExcludesTest {
30+
final class SpotlessExcludesTest {
3131

3232
// Forward slashes: the path goes into a Groovy string, where a Windows backslash would start an escape.
3333
private static final String CLASSPATH_FILE =

‎gradle-open-java-format/src/test/java/com/palantir/javaformat/gradle/SupportsCurrentSpotlessTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* cache, which is what now catches eager resolution. gradle-consistent-versions used to play that role; it is gone,
3232
* because applying it is precisely what Gradle 9 rejects.
3333
*/
34-
class SupportsCurrentSpotlessTest {
34+
final class SupportsCurrentSpotlessTest {
3535

3636
// Forward slashes: the path goes into a Groovy string, where a Windows backslash would start an escape.
3737
private static final String CLASSPATH_FILE =

0 commit comments

Comments
 (0)