You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2026/01/07 17:17:08 UTC

(maven-checkstyle-plugin) branch master updated: Remove deprecated replace methods in favor of String.replace (#658)

This is an automated email from the ASF dual-hosted git repository.

elharo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-checkstyle-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 85d87e0  Remove deprecated replace methods in favor of String.replace (#658)
85d87e0 is described below

commit 85d87e0d2055fb0b7288e58bee3bfb2b8496cde3
Author: Elliotte Rusty Harold <el...@users.noreply.github.com>
AuthorDate: Wed Jan 7 17:17:04 2026 +0000

    Remove deprecated replace methods in favor of String.replace (#658)
---
 .../org/apache/maven/plugins/checkstyle/CheckstyleReportRenderer.java | 4 ++--
 .../maven/plugins/checkstyle/exec/CheckstyleCheckerListener.java      | 4 ++--
 .../maven/plugins/checkstyle/exec/DefaultCheckstyleExecutor.java      | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReportRenderer.java b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReportRenderer.java
index 743425a..f6b3061 100644
--- a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReportRenderer.java
+++ b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleReportRenderer.java
@@ -339,8 +339,8 @@ public class CheckstyleReportRenderer extends AbstractMavenReportRenderer {
         if (expectedMessage != null) {
             // event.getMessage() uses java.text.MessageFormat in its implementation.
             // Read MessageFormat Javadoc about single quote:
-            // http://java.sun.com/j2se/1.4.2/docs/api/java/text/MessageFormat.html
-            String msgWithoutSingleQuote = StringUtils.replace(expectedMessage, "'", "");
+            // https://docs.oracle.com/javase/8/docs/api/java/text/MessageFormat.html
+            String msgWithoutSingleQuote = expectedMessage.replace("'", "");
 
             if (!(expectedMessage.equals(event.getMessage()) || msgWithoutSingleQuote.equals(event.getMessage()))) {
                 return false;
diff --git a/src/main/java/org/apache/maven/plugins/checkstyle/exec/CheckstyleCheckerListener.java b/src/main/java/org/apache/maven/plugins/checkstyle/exec/CheckstyleCheckerListener.java
index d32353a..b3e4662 100644
--- a/src/main/java/org/apache/maven/plugins/checkstyle/exec/CheckstyleCheckerListener.java
+++ b/src/main/java/org/apache/maven/plugins/checkstyle/exec/CheckstyleCheckerListener.java
@@ -118,10 +118,10 @@ public class CheckstyleCheckerListener extends AutomaticBean implements AuditLis
      */
     @Override
     public void fileStarted(AuditEvent event) {
-        final String fileName = StringUtils.replace(event.getFileName(), "\\", "/");
+        final String fileName = event.getFileName().replace("\\", "/");
 
         for (File sourceDirectory : sourceDirectories) {
-            String sourceDirectoryPath = StringUtils.replace(sourceDirectory.getPath(), "\\", "/");
+            String sourceDirectoryPath = sourceDirectory.getPath().replace("\\", "/");
 
             if (fileName.startsWith(sourceDirectoryPath + "/")) {
                 currentFile = StringUtils.substring(fileName, sourceDirectoryPath.length() + 1);
diff --git a/src/main/java/org/apache/maven/plugins/checkstyle/exec/DefaultCheckstyleExecutor.java b/src/main/java/org/apache/maven/plugins/checkstyle/exec/DefaultCheckstyleExecutor.java
index 8435bef..4353ecb 100644
--- a/src/main/java/org/apache/maven/plugins/checkstyle/exec/DefaultCheckstyleExecutor.java
+++ b/src/main/java/org/apache/maven/plugins/checkstyle/exec/DefaultCheckstyleExecutor.java
@@ -387,7 +387,7 @@ public class DefaultCheckstyleExecutor implements CheckstyleExecutor {
             if (StringUtils.isNotEmpty(request.getPropertyExpansion())) {
                 String propertyExpansion = request.getPropertyExpansion();
                 // Convert \ to \\, so that p.load will convert it back properly
-                propertyExpansion = StringUtils.replace(propertyExpansion, "\\", "\\\\");
+                propertyExpansion = propertyExpansion.replace("\\", "\\\\");
                 p.load(new ByteArrayInputStream(propertyExpansion.getBytes()));
             }