You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/05/15 17:24:09 UTC
[GitHub] [maven-pmd-plugin] michael-o commented on a diff in pull request #66: [MPMD-336] Replace deprecated calls to PMD
michael-o commented on code in PR #66:
URL: https://github.com/apache/maven-pmd-plugin/pull/66#discussion_r873199264
##########
src/main/java/org/apache/maven/plugins/pmd/exec/PmdExecutor.java:
##########
@@ -323,6 +307,26 @@ private PmdResult run() throws MavenReportException
return new PmdResult( new File( request.getTargetDirectory(), "pmd.xml" ), request.getOutputEncoding() );
}
+ /**
+ * Gets the errors as a single string. Each error is in its own line.
+ * @param withDetails if <code>true</code> then add the error details additionally (contains e.g. the stacktrace)
+ * @return the errors as string
+ */
+ private String getErrorsAsString( List<Report.ProcessingError> errors, boolean withDetails )
+ {
+ List<String> errorsAsString = new ArrayList<>( errors.size() );
+ for ( Report.ProcessingError error : errors )
+ {
+ errorsAsString.add( error.getFile() + ": " + error.getMsg() );
+ if ( withDetails )
+ {
+ errorsAsString.add( error.getDetail() );
Review Comment:
No space betweeen msessage and detail?
##########
src/main/java/org/apache/maven/plugins/pmd/exec/PmdExecutor.java:
##########
@@ -323,6 +307,26 @@ private PmdResult run() throws MavenReportException
return new PmdResult( new File( request.getTargetDirectory(), "pmd.xml" ), request.getOutputEncoding() );
}
+ /**
+ * Gets the errors as a single string. Each error is in its own line.
+ * @param withDetails if <code>true</code> then add the error details additionally (contains e.g. the stacktrace)
+ * @return the errors as string
+ */
+ private String getErrorsAsString( List<Report.ProcessingError> errors, boolean withDetails )
+ {
+ List<String> errorsAsString = new ArrayList<>( errors.size() );
+ for ( Report.ProcessingError error : errors )
+ {
+ errorsAsString.add( error.getFile() + ": " + error.getMsg() );
+ if ( withDetails )
+ {
+ errorsAsString.add( error.getDetail() );
+ }
+ }
+ return org.codehaus.plexus.util.StringUtils.join( errorsAsString.toArray(),
+ System.getProperty( "line.separator" ) );
Review Comment:
`System.lineSeparator()`
##########
src/main/java/org/apache/maven/plugins/pmd/exec/PmdExecutor.java:
##########
@@ -323,6 +307,26 @@ private PmdResult run() throws MavenReportException
return new PmdResult( new File( request.getTargetDirectory(), "pmd.xml" ), request.getOutputEncoding() );
}
+ /**
+ * Gets the errors as a single string. Each error is in its own line.
+ * @param withDetails if <code>true</code> then add the error details additionally (contains e.g. the stacktrace)
+ * @return the errors as string
+ */
+ private String getErrorsAsString( List<Report.ProcessingError> errors, boolean withDetails )
+ {
+ List<String> errorsAsString = new ArrayList<>( errors.size() );
+ for ( Report.ProcessingError error : errors )
+ {
+ errorsAsString.add( error.getFile() + ": " + error.getMsg() );
+ if ( withDetails )
+ {
+ errorsAsString.add( error.getDetail() );
+ }
+ }
+ return org.codehaus.plexus.util.StringUtils.join( errorsAsString.toArray(),
Review Comment:
We are on Java 8, use `String#join()`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org