stefan-paal-innoq commented on a change in pull request #34:
URL: 
https://github.com/apache/maven-checkstyle-plugin/pull/34#discussion_r479753346



##########
File path: 
src/main/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleReport.java
##########
@@ -780,6 +770,53 @@ private void generateMainReport( CheckstyleResults 
results, ResourceBundle bundl
         generator.generateReport( results );
     }
 
+    private void initializeXrefLocation( CheckstyleReportGenerator generator )
+    {
+      String relativePath = determineRelativePath( xrefLocation );
+      if ( xrefLocation.exists() || checkMavenJxrPluginIsConfigured() )
+      {
+          // XRef was already generated by manual execution of a lifecycle 
binding
+          // the report is on its way
+          generator.setXrefLocation( relativePath );
+      }
+    }
+
+    private void initializeXrefTestLocation( CheckstyleReportGenerator 
generator )
+    {
+      String relativePath = determineRelativePath( xrefTestLocation );
+      if ( xrefTestLocation.exists() || checkMavenJxrPluginIsConfigured() )
+      {
+          // XRef was already generated by manual execution of a lifecycle 
binding
+          // the report is on its way
+          generator.setXrefTestLocation( relativePath );
+      }
+    }
+
+    private String determineRelativePath( File location )
+    {
+      String relativePath = PathTool.getRelativePath( getOutputDirectory(), 
location.getAbsolutePath() );
+      if ( StringUtils.isEmpty( relativePath ) )

Review comment:
       ok, i get it and agree. i have just used what was already there :-)
   
   the call to PathTool.getRelativePath should actually either return a 
zero-length string or a valid path. the null check and the whitespaces trimming 
are just a kind of defensive implementation. we could just look for a 
zero-length string, e.g. with "relativePath.isEmpty" if that suits you more. 
   
   pushed another commit with explicit evaluation of the string content, 
including the null check and whitespace trimming.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to