Files
error-prone-support/integration-tests/checkstyle-init.patch
Stephan Schroevers dc87aeda6c Improve integration test setup (#1427)
Summary of changes:
- Configure Renovate to update AssertJ and fmt-maven-plugin version
  references in patch files and shell scripts any time those
  dependencies are updated in the top-level `pom.xml`.
- Enhance the `--sync` flag such that it also updates the initial patch
  file, avoiding drift due to line shifts.
2024-11-20 13:58:28 +01:00

201 lines
10 KiB
Diff

--- a/pom.xml
+++ b/pom.xml
@@ -368,6 +368,12 @@
<version>1.4.4</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>3.26.3<!-- Renovate: org.assertj:assertj-bom --></version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
@@ -2420,6 +2426,8 @@
<arg>
-Xplugin:ErrorProne ${error-prone.configuration-args}
</arg>
+ <arg>-Xmaxwarns</arg>
+ <arg>1000000</arg>
</compilerArgs>
<annotationProcessorPaths>
<path>
@@ -2432,6 +2440,11 @@
<artifactId>error-prone-contrib</artifactId>
<version>${error-prone-support.version}</version>
</path>
+ <path>
+ <groupId>tech.picnic.error-prone-support</groupId>
+ <artifactId>refaster-runner</artifactId>
+ <version>${error-prone-support.version}</version>
+ </path>
</annotationProcessorPaths>
</configuration>
</execution>
@@ -2474,9 +2487,10 @@
<arg>-XDcompilePolicy=simple</arg>
<arg>
-Xplugin:ErrorProne \
- -XepExcludedPaths:.*[\\/]resources[\\/].* \
${error-prone.configuration-args}
</arg>
+ <arg>-Xmaxwarns</arg>
+ <arg>1000000</arg>
</compilerArgs>
<annotationProcessorPaths>
<path>
@@ -2489,6 +2503,11 @@
<artifactId>error-prone-contrib</artifactId>
<version>${error-prone-support.version}</version>
</path>
+ <path>
+ <groupId>tech.picnic.error-prone-support</groupId>
+ <artifactId>refaster-runner</artifactId>
+ <version>${error-prone-support.version}</version>
+ </path>
</annotationProcessorPaths>
</configuration>
</execution>
--- a/src/it/java/com/google/checkstyle/test/chapter2filebasic/rule21filename/FileNameTest.java
+++ b/src/it/java/com/google/checkstyle/test/chapter2filebasic/rule21filename/FileNameTest.java
@@ -23,6 +23,8 @@ import org.junit.jupiter.api.Test;
import com.google.checkstyle.test.base.AbstractGoogleModuleTestSupport;
+// This class is referenced from another package.
+@SuppressWarnings("JUnitClassModifiers")
public class FileNameTest extends AbstractGoogleModuleTestSupport {
@Override
--- a/src/it/java/com/google/checkstyle/test/chapter3filestructure/rule3sourcefile/SourceFileStructureTest.java
+++ b/src/it/java/com/google/checkstyle/test/chapter3filestructure/rule3sourcefile/SourceFileStructureTest.java
@@ -23,6 +23,8 @@ import org.junit.jupiter.api.Test;
import com.google.checkstyle.test.base.AbstractGoogleModuleTestSupport;
+// This class is referenced from another package.
+@SuppressWarnings("JUnitClassModifiers")
public class SourceFileStructureTest extends AbstractGoogleModuleTestSupport {
@Override
--- a/src/it/java/com/google/checkstyle/test/chapter3filestructure/toolongpackagetotestcoveragegooglesjavastylerule/PackageStatementTest.java
+++ b/src/it/java/com/google/checkstyle/test/chapter3filestructure/toolongpackagetotestcoveragegooglesjavastylerule/PackageStatementTest.java
@@ -23,6 +23,8 @@ import org.junit.jupiter.api.Test;
import com.google.checkstyle.test.base.AbstractGoogleModuleTestSupport;
+// This class is referenced from another package.
+@SuppressWarnings("JUnitClassModifiers")
public class PackageStatementTest extends AbstractGoogleModuleTestSupport {
@Override
--- a/src/main/java/com/puppycrawl/tools/checkstyle/DetailNodeTreeStringPrinter.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/DetailNodeTreeStringPrinter.java
@@ -63,6 +63,8 @@ public final class DetailNodeTreeStringPrinter {
* @return DetailNode tree
* @throws IllegalArgumentException if there is an error parsing the Javadoc.
*/
+ // Invoking `getParseErrorMessage` requires that `status.getParseErrorMessage()` is `null`.
+ @SuppressWarnings("CheckArgumentWithMessage")
public static DetailNode parseJavadocAsDetailNode(DetailAST blockComment) {
final JavadocDetailNodeParser parser = new JavadocDetailNodeParser();
final ParseStatus status = parser.parseJavadocAsDetailNode(blockComment);
--- a/src/main/java/com/puppycrawl/tools/checkstyle/SarifLogger.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/SarifLogger.java
@@ -157,6 +157,9 @@ public class SarifLogger extends AbstractAutomaticBean implements AuditListener
@Override
public void auditFinished(AuditEvent event) {
final String version = SarifLogger.class.getPackage().getImplementationVersion();
+ // Here `version` may be `null`, while `String#replace` requires non-`null` arguments.
+ // XXX: Investigate better nullness handling by `IdentityConversion`.
+ @SuppressWarnings("IdentityConversion")
final String rendered = report
.replace(VERSION_PLACEHOLDER, String.valueOf(version))
.replace(RESULTS_PLACEHOLDER, String.join(",\n", results));
--- a/src/test/java/com/puppycrawl/tools/checkstyle/CheckerTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/CheckerTest.java
@@ -97,6 +97,8 @@ import de.thetaphi.forbiddenapis.SuppressForbidden;
* @noinspectionreason ClassWithTooManyDependencies - complex tests require a large number
* of imports
*/
+// This class is referenced from another package.
+@SuppressWarnings("JUnitClassModifiers")
public class CheckerTest extends AbstractModuleTestSupport {
@TempDir
--- a/src/test/java/com/puppycrawl/tools/checkstyle/ConfigurationLoaderTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/ConfigurationLoaderTest.java
@@ -47,6 +47,8 @@ import com.puppycrawl.tools.checkstyle.internal.utils.TestUtil;
/**
* Unit test for ConfigurationLoader.
*/
+// This class is referenced from another package.
+@SuppressWarnings("JUnitClassModifiers")
public class ConfigurationLoaderTest extends AbstractPathTestSupport {
@Override
--- a/src/test/java/com/puppycrawl/tools/checkstyle/PackageObjectFactoryTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/PackageObjectFactoryTest.java
@@ -98,6 +98,8 @@ public class PackageObjectFactoryTest {
public void testCtorNullPackageException1() {
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
try {
+ // XXX: Don't suggest `ImmutableSet.of(elem)` for nullable `elem`.
+ @SuppressWarnings("ImmutableSetOf1")
final Object test = new PackageObjectFactory(Collections.singleton(null), classLoader);
assertWithMessage("Exception is expected but got " + test).fail();
}
@@ -126,6 +128,8 @@ public class PackageObjectFactoryTest {
public void testCtorNullPackageException3() {
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
try {
+ // XXX: Don't suggest `ImmutableSet.of(elem)` for nullable `elem`.
+ @SuppressWarnings("ImmutableSetOf1")
final Object test = new PackageObjectFactory(Collections.singleton(null), classLoader,
TRY_IN_ALL_REGISTERED_PACKAGES);
assertWithMessage("Exception is expected but got " + test).fail();
--- a/src/test/java/com/puppycrawl/tools/checkstyle/TreeWalkerTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/TreeWalkerTest.java
@@ -84,6 +84,8 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
* @noinspectionreason ClassWithTooManyDependencies - complex tests require a
* large number of imports
*/
+// This class is referenced from another package.
+@SuppressWarnings("JUnitClassModifiers")
public class TreeWalkerTest extends AbstractModuleTestSupport {
@TempDir
--- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/utils/XdocGenerator.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/utils/XdocGenerator.java
@@ -55,7 +55,8 @@ public final class XdocGenerator {
for (Path path : templatesFilePaths) {
final String pathToFile = path.toString();
final File inputFile = new File(pathToFile);
- final File tempFile = File.createTempFile(pathToFile.replace(".template", ""), "");
+ final File outputFile = new File(pathToFile.replace(".template", ""));
+ final File tempFile = File.createTempFile(outputFile.getName(), "");
tempFile.deleteOnExit();
final XdocsTemplateSinkFactory sinkFactory = (XdocsTemplateSinkFactory)
plexus.lookup(SinkFactory.ROLE, XDOCS_TEMPLATE_HINT);
@@ -70,7 +71,6 @@ public final class XdocGenerator {
finally {
sink.close();
}
- final File outputFile = new File(pathToFile.replace(".template", ""));
final StandardCopyOption copyOption = StandardCopyOption.REPLACE_EXISTING;
Files.copy(tempFile.toPath(), outputFile.toPath(), copyOption);
}
--- a/src/test/java/com/puppycrawl/tools/checkstyle/utils/CheckUtilTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/utils/CheckUtilTest.java
@@ -47,6 +47,8 @@ import com.puppycrawl.tools.checkstyle.checks.coding.NestedIfDepthCheck;
import com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck;
import com.puppycrawl.tools.checkstyle.checks.naming.AccessModifierOption;
+// This class is referenced from another package.
+@SuppressWarnings("JUnitClassModifiers")
public class CheckUtilTest extends AbstractModuleTestSupport {
@Override