Lokesh Kumar February 2016

How can I receive Blocker / Critical / Major / Minor / Info in the PDF generated by sonar-runner?

Shown below are my two screens, one of Sonar GUI and the other of PDF:

screens

As can be seen from the image, Blocker/Critical/Major/Minor/Info details are shown in the GUI but not in the generated PDF.

I followed the code from sonar-pdf-report. In the code, I also found out that we have no code to generate GUI for the major/minor/blocker etc.

Answers


Lokesh Kakran February 2016

The src code you Downloaded doesn't have code to generate above requirement, for that follow the steps given below.

Step:1: Go to file >> report-text-en-properties under src/main/resources>>tendency & write ..

general.Blocker=Blocker
general.Critical=Critical
general.Major=Major
general.Minor=Minor
general.Info=Info

Step:2: check MetricKeys.java under the package org.sonar.report.pdf.util does have the below code or not, write if it is not available

  public static final String BLOCKER_VIOLATIONS = "blocker_violations";
  public static final String CRITICAL_VIOLATIONS = "critical_violations";
  public static final String MAJOR_VIOLATIONS = "major_violations";
  public static final String MINOR_VIOLATIONS = "minor_violations";
  public static final String INFO_VIOLATIONS = "info_violations";

Step:3 Go to ExecutivePDFReporter.java under the org.sonar.report.pdf package, & write ..

 /** code for blocker critical major minor info 
     *  @Lokesh Kr. Kakran
     */
    PdfPTable technicalDebtBlocker = new PdfPTable(1);
    Style.noBorderTable(technicalDebtBlocker);
    technicalDebtBlocker
        .addCell(new Phrase(getTextProperty("general.Blocker"),
            Style.DASHBOARD_TITLE_FONT));
    PdfPTable technicalDebtTendencyBlocker = new PdfPTable(2);
    Style.noBorderTable(technicalDebtTendencyBlocker);
    technicalDebtTendencyBlocker.getDefaultCell().setFixedHeight(
        Style.TENDENCY_ICONS_HEIGHT);
    technicalDebtTendencyBlocker.addCell(new Phrase(project.getMeasure(
        MetricKeys.BLOCKER_VIOLATIONS).getFormatValue(),
        Style.DASHBOARD_DATA_FONT));
    // Workarround for avoid resizing
    Image tendencyTechnicalDebtResizeBlocker = getTendencyImage(
        project.getMeasure(MetricKeys.BLOCKER_VIOLATIONS)
            .getQualitativeTendency(),
        proje 

Post Status

Asked in February 2016
Viewed 1,936 times
Voted 8
Answered 1 times

Search




Leave an answer