Package com.lpvs.util

Class LPVSCommentUtil

java.lang.Object
com.lpvs.util.LPVSCommentUtil

public class LPVSCommentUtil extends Object
Utility class providing methods for generating links and formatting matched lines in comments. It includes functionality to create links to specific lines in a file on version control platforms like GitHub, based on the provided LPVSQueue configuration, LPVSFile, and LPVSVcs.

This class is designed to enhance the generation of comment content by creating clickable links to specific lines in a file, making it easier for users to navigate directly to the relevant code.

  • Constructor Details

    • LPVSCommentUtil

      public LPVSCommentUtil()
  • Method Details

    • getMatchedLinesAsLink

      public static String getMatchedLinesAsLink(LPVSQueue webhookConfig, LPVSFile file, LPVSVcs vcs)
      Generates a formatted string containing links to matched lines in a file.
      Parameters:
      webhookConfig - The LPVSQueue configuration for the webhook.
      file - The LPVSFile representing the file with matched lines.
      vcs - The LPVSVcs representing the version control system (e.g., GitHub).
      Returns:
      A string containing formatted links to matched lines in the file.
    • reportCommentBuilder

      public static String reportCommentBuilder(LPVSQueue webhookConfig, List<LPVSFile> scanResults, List<LPVSLicenseService.Conflict<String,String>> conflicts)
      Generates a formatted string for an LPVS GitHub comment.
      Parameters:
      webhookConfig - The LPVSQueue configuration for the webhook.
      scanResults - List containing preformatted scan results.
      conflicts - List of conflicts, containing license conflict information.
      Returns:
      A string containing scan results in GitHub-friendly format.
    • buildHTMLComment

      public static String buildHTMLComment(LPVSQueue webhookConfig, List<LPVSFile> scanResults, List<LPVSLicenseService.Conflict<String,String>> conflicts)
      Generates a formatted string for an HTML report with scan results.
      Parameters:
      webhookConfig - The LPVSQueue configuration for the webhook.
      scanResults - List containing preformatted scan results.
      conflicts - List containing license conflict information.
      Returns:
      A string containing scan results in HTML format.
    • saveHTMLToFile

      public static void saveHTMLToFile(String htmlContent, String filePath)
      Saves HTML report to given location.
      Parameters:
      htmlContent - The string, containing report in HTML format.
      filePath - The path to expected html report file.