java.lang.Object
com.parasoft.findings.jenkins.coverage.api.metrics.source.SourceCodeFacade

public class SourceCodeFacade extends Object
Facade to the source code file structure in Jenkins build folder. Access of those files should be done using an instance of this class only.
Author:
Ullrich Hafner, Florian Orendi
  • Constructor Details

    • SourceCodeFacade

      public SourceCodeFacade()
  • Method Details

    • read

      public String read(File buildResults, String id, String path) throws IOException, InterruptedException
      Reads the contents of the source file of the given file into a String.
      Parameters:
      buildResults - Jenkins directory for build results
      id - if of the coverage results
      path - relative path to the coverage node base filename of the coverage node
      Returns:
      the file content as String
      Throws:
      IOException
      InterruptedException
    • canRead

      public boolean canRead(File buildResults, String id, String path)
      Returns whether the source code is available for the specified source file.
      Parameters:
      buildResults - Jenkins directory for build results
      id - if of the coverage results
      path - relative path to the source code filename name
      Returns:
      the file content as String
    • hasStoredSourceCode

      public boolean hasStoredSourceCode(File buildResults, String id)
      Checks whether any source files has been stored. Even if it is wanted, there might have been errors which cause the absence of any source files.
      Parameters:
      buildResults - Jenkins directory for build results
      id - id of the coverage results
      Returns:
      true whether source files has been stored, else false
    • calculateModifiedLinesCoverageSourceCode

      public String calculateModifiedLinesCoverageSourceCode(String content, FileNode fileNode)
      Filters the sourcecode coverage highlighting for analyzing the modified lines coverage only.
      Parameters:
      content - The original HTML content
      fileNode - The node which represents the coverage of the file
      Returns:
      the filtered HTML sourcecode view