Skip to content

Commit

Permalink
JENKINS-20646 Summary is missing for the first build
Browse files Browse the repository at this point in the history
- The build summary was displayed only if both current and previous reports were not null. Only current report should be tested at top-level, test of previous report is relevant only while processing the differences.
- Hardcoded "in" string on summary page added to localication Messages (English only).

- Create a new project.
- Process a first build.
- Show its summary.
- Verify the summary contains valid text.
- Process a second build.
- Show its summary.
- Verify the summary contains valid text.
- All tests passed.
  • Loading branch information
mixalturek committed Nov 19, 2013
1 parent 621bdab commit 5493d93
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
30 changes: 22 additions & 8 deletions src/main/java/hudson/plugins/sloccount/ReportSummary.java
Expand Up @@ -19,24 +19,34 @@ private ReportSummary(){
public static String createReportSummary(SloccountReport report, SloccountReport previous){
StringBuilder builder = new StringBuilder();

if((report != null)&&(previous != null)){
if(report != null){

String strLines = Messages.Sloccount_ReportSummary_Lines();
String strFiles = Messages.Sloccount_ReportSummary_Files();
String strAnd = Messages.Sloccount_ReportSummary_and();
String strIn = Messages.Sloccount_ReportSummary_in();
String strLanguages = Messages.Sloccount_ReportSummary_Languages();

builder.append("<a href=\"" + SloccountBuildAction.URL_NAME + "\">");
builder.append(report.getLineCountString());
printDifference(report.getLineCount(), previous.getLineCount(), builder);

if(previous != null) {
printDifference(report.getLineCount(), previous.getLineCount(), builder);
}

builder.append(" " + strLines + "</a> in ");
builder.append(" " + strLines + "</a> " + strIn + " ");
builder.append(report.getFileCountString());
printDifference(report.getFileCount(), previous.getFileCount(), builder);

if(previous != null) {
printDifference(report.getFileCount(), previous.getFileCount(), builder);
}

builder.append(" " + strFiles + " " + strAnd + " ");
builder.append(report.getLanguageCountString());
printDifference(report.getLanguageCount(), previous.getLanguageCount(), builder);

if(previous != null) {
printDifference(report.getLanguageCount(), previous.getLanguageCount(), builder);
}

builder.append(" " + strLanguages + ".");
}
Expand All @@ -48,12 +58,15 @@ public static String createReportSummaryDetails(SloccountReport report, Sloccoun

StringBuilder builder = new StringBuilder();

if((report != null)&&(previous != null)){
if(report != null){

for(Language language : report.getLanguages()){

Language previousLanguage = null;
previousLanguage = previous.getLanguage(language.getName());

if(previous != null) {
previousLanguage = previous.getLanguage(language.getName());
}

appendLanguageDetails(language, previousLanguage, builder);
}
Expand All @@ -66,6 +79,7 @@ private static void appendLanguageDetails(Language language, Language previous,

String strLines = Messages.Sloccount_ReportSummary_Lines();
String strFiles = Messages.Sloccount_ReportSummary_Files();
String strIn = Messages.Sloccount_ReportSummary_in();

builder.append("<li>");
builder.append("<a href=\"");
Expand All @@ -79,7 +93,7 @@ private static void appendLanguageDetails(Language language, Language previous,
if(previous != null){
printDifference(language.getLineCount(), previous.getLineCount(), builder);
}
builder.append(" " + strLines + " in ");
builder.append(" " + strLines + " " + strIn + " ");
builder.append(language.getFileCountString());
if(previous != null){
printDifference(language.getFileCount(), previous.getFileCount(), builder);
Expand Down
Expand Up @@ -7,4 +7,5 @@ Sloccount.Trend.Name=SLOCCount Trend
Sloccount.ReportSummary.Lines=lines of code
Sloccount.ReportSummary.Files=files
Sloccount.ReportSummary.and=and
Sloccount.ReportSummary.in=in
Sloccount.ReportSummary.Languages=languages

0 comments on commit 5493d93

Please sign in to comment.