Skip to content
Permalink
Browse files
[JENKINS-31221] Resolved issue - Implement access to comments count
add commentCount in:
SloccountDiff.java
SloccountDiffLanguage.java
SloccountDiffSummary.java

add column in jelly:
statistics.jelly
languages.jelly
modules.jelly

SloccountParser: in parseLine remove commentCount and replace in report.add commentCount by 0
  • Loading branch information
Jim committed Nov 2, 2015
1 parent 0d502be commit 3a12ffe493e18ef39aca49a7e3a6244b1acf350f
Showing 9 changed files with 85 additions and 16 deletions.
@@ -19,6 +19,12 @@ public abstract class SloccountDiff implements Comparable<SloccountDiff> {

/** Difference of files count between current and previous report. */
private final int fileCountDelta;

/** Comments count in the newer report. */
private final int commentCount;

/** Difference of comments count between current and previous report. */
private final int commentCountDelta;

/**
* Constructor.
@@ -28,18 +34,25 @@ public abstract class SloccountDiff implements Comparable<SloccountDiff> {
* @param lineCountDelta
* difference of lines count between current and previous
* report
* @param fileCount files
* count in the newer report
* @param fileCount
* files count in the newer report
* @param fileCountDelta
* difference of files count between current and previous
* report
* @param commentCount
* comments count in the newer report
* @param commentCountDelta
* difference of comments count between current and previous
* report
*/
public SloccountDiff(int lineCount,
int lineCountDelta, int fileCount, int fileCountDelta) {
int lineCountDelta, int fileCount, int fileCountDelta, int commentCount, int commentCountDelta) {
this.lineCount = lineCount;
this.lineCountDelta = lineCountDelta;
this.fileCount = fileCount;
this.fileCountDelta = fileCountDelta;
this.commentCount = commentCount;
this.commentCountDelta = commentCountDelta;
}

/**
@@ -84,6 +97,14 @@ public int getLineCount() {
public int getLineCountDelta() {
return lineCountDelta;
}

public int getCommentCount() {
return commentCount;
}

public int getCommentCountDelta() {
return commentCountDelta;
}

public int getFileCount() {
return fileCount;
@@ -106,6 +127,20 @@ public String getLineCountDeltaString() {
String result = StringUtil.grouping(lineCountDelta);
return (lineCountDelta > 0) ? "+" + result : result;
}

public String getCommentCountString() {
return StringUtil.grouping(commentCount);
}

public String getCommentCountDeltaString() {
if(commentCountDelta == 0) {
return "";
}

// Negative prefix '-' is added automatically
String result = StringUtil.grouping(commentCountDelta);
return (commentCountDelta > 0) ? "+" + result : result;
}

public String getFileCountString() {
return StringUtil.grouping(fileCount);
@@ -26,10 +26,15 @@ public class SloccountDiffLanguage extends SloccountDiff {
* @param fileCountDelta
* difference of files count between current and previous
* report
* @param commentCount
* comments count in the newer report
* @param commentCountDelta
* difference of comments count between current and previous
* report
*/
public SloccountDiffLanguage(String name, int lineCount,
int lineCountDelta, int fileCount, int fileCountDelta) {
super(lineCount, lineCountDelta, fileCount, fileCountDelta);
int lineCountDelta, int fileCount, int fileCountDelta, int commentCount, int commentCountDelta) {
super(lineCount, lineCountDelta, fileCount, fileCountDelta, commentCount, commentCountDelta);
this.name = name;
}

@@ -33,12 +33,16 @@ public class SloccountDiffSummary extends SloccountDiff {
* @param fileCountDelta
* difference of files count between current and previous
* report
*
* @param commentCount
* comments count in the newer report
* @param commentCountDelta
* difference of comments count between current and previous
* report
* @see #getDiffSummary(SloccountReportStatistics, SloccountReportStatistics)
*/
private SloccountDiffSummary(List<SloccountDiffLanguage> languageDiffs,
int lineCount, int lineCountDelta, int fileCount, int fileCountDelta) {
super(lineCount, lineCountDelta, fileCount, fileCountDelta);
int lineCount, int lineCountDelta, int fileCount, int fileCountDelta, int commentCount, int commentCountDelta) {
super(lineCount, lineCountDelta, fileCount, fileCountDelta, commentCount, commentCountDelta);

// No copy, can be called only internally
this.languageDiffs = languageDiffs;
@@ -70,6 +74,8 @@ public static SloccountDiffSummary getDiffSummary(
int lineCountDelta = 0;
int fileCount = 0;
int fileCountDelta = 0;
int commentCount = 0;
int commentCountDelta = 0;

for(String language: languages) {
// Quadratic complexity can be optimized, but languages count is small
@@ -80,16 +86,21 @@ public static SloccountDiffSummary getDiffSummary(
curStats.getLineCount(),
curStats.getLineCount() - prevStats.getLineCount(),
curStats.getFileCount(),
curStats.getFileCount() - prevStats.getFileCount()));
curStats.getFileCount() - prevStats.getFileCount(),
curStats.getCommentCount(),
curStats.getCommentCount() - prevStats.getCommentCount()));

lineCount += curStats.getLineCount();
lineCountDelta += curStats.getLineCount() - prevStats.getLineCount();
fileCount += curStats.getFileCount();
fileCountDelta += curStats.getFileCount() - prevStats.getFileCount();
commentCount += curStats.getCommentCount();
commentCountDelta += curStats.getCommentCount() - prevStats.getCommentCount();
}

return new SloccountDiffSummary(result, lineCount, lineCountDelta,
fileCount, fileCountDelta);
fileCount, fileCountDelta,
commentCount, commentCountDelta);
}

/**
@@ -107,16 +118,18 @@ private static SloccountDiffSummary getDiffSummary(SloccountReportStatistics cur
List<SloccountDiffLanguage> result = new ArrayList<SloccountDiffLanguage>();
int lineCount = 0;
int fileCount = 0;
int commentCount = 0;

for(SloccountLanguageStatistics language: current.getStatistics()) {
result.add(new SloccountDiffLanguage(language.getName(),
language.getLineCount(), 0, language.getFileCount(), 0));
language.getLineCount(), 0, language.getFileCount(), 0, language.getCommentCount(), 0));

lineCount += language.getLineCount();
fileCount += language.getFileCount();
commentCount += language.getCommentCount();
}

return new SloccountDiffSummary(result, lineCount, 0, fileCount, 0);
return new SloccountDiffSummary(result, lineCount, 0, fileCount, 0, commentCount, 0);
}

/**
@@ -127,7 +140,7 @@ private static SloccountDiffSummary getDiffSummary(SloccountReportStatistics cur
*/
private static SloccountDiffSummary getDiffSummary() {
return new SloccountDiffSummary(
Collections.<SloccountDiffLanguage>emptyList(), 0, 0, 0, 0);
Collections.<SloccountDiffLanguage>emptyList(), 0, 0, 0, 0, 0, 0);
}

/**
@@ -127,19 +127,17 @@ private void parseLine(String line, SloccountReportInterface report){
}

int lineCount = Integer.parseInt(tokens[0]);
int commentCount = Integer.parseInt(tokens[1]);
String languageName = tokens[1];
String moduleName = tokens[2];
String filePath = tokens[3];

if(LOG_ENABLED && (this.logger != null)){
logger.println("lineCount: " + lineCount);
logger.println("language : " + languageName);
logger.println("commentCount: " + commentCount);
logger.println("file : " + filePath);
logger.println("module : " + moduleName);
}

report.add(filePath, languageName, moduleName, lineCount, commentCount);
report.add(filePath, languageName, moduleName, lineCount, 0);
}
}
@@ -11,6 +11,8 @@
<td class="pane-header">${%Language}</td>
<td class="pane-header">${%Lines}</td>
<td class="pane-header">${%Lines} ${%Delta}</td>
<td class="pane-header">${%Comments}</td>
<td class="pane-header">${%Comments} ${%Delta}</td>
<td class="pane-header">${%Files}</td>
<td class="pane-header">${%Files} ${%Delta}</td>
</tr>
@@ -26,6 +28,8 @@
</j:if>
<td class="pane number" data="${language.lineCount}">${language.lineCountString}</td>
<td class="pane number" data="${language.lineCountDelta}">${language.lineCountDeltaString}</td>
<td class="pane number" data="${language.commentCount}">${language.commentCountString}</td>
<td class="pane number" data="${language.commentCountDelta}">${language.commentCountDeltaString}</td>
<td class="pane number" data="${language.fileCount}">${language.fileCountString}</td>
<td class="pane number" data="${language.fileCountDelta}">${language.fileCountDeltaString}</td>
</tr>
@@ -36,6 +40,8 @@
<td class="pane-header">${%Total}</td>
<td class="pane-header number" data="${diff.lineCount}">${diff.lineCountString}</td>
<td class="pane-header number" data="${diff.lineCountDelta}">${diff.lineCountDeltaString}</td>
<td class="pane-header number" data="${diff.commentCount}">${diff.commentCountString}</td>
<td class="pane-header number" data="${diff.commentCountDelta}">${diff.commentCountDeltaString}</td>
<td class="pane-header number" data="${diff.fileCount}">${diff.fileCountString}</td>
<td class="pane-header number" data="${diff.fileCountDelta}">${diff.fileCountDeltaString}</td>
</tr>
@@ -6,6 +6,7 @@
<td class="pane-header">${%Folder}</td>
<td class="pane-header" style="width:2em">${%Files}</td>
<td class="pane-header" style="width:2em">${%Lines}</td>
<td class="pane-header" style="width:2em">${%Comments}</td>
<td class="pane-header" style="width:60%">${%Distribution}</td>
</tr>
</thead>
@@ -16,6 +17,7 @@
<tr>
<td class="pane"><a href="folderResult/${container.urlName}">${container.name}</a></td>
<td class="pane number" data="${container.fileCount}">${container.fileCountString}</td>
<td class="pane number" data="${container.commentCount}">${container.commentCountString}</td>
<td class="pane number" data="${container.lineCount}">${container.lineCountString}</td>
<td class="pane" data="${container.lineCount}"><st:include page="/tabview/distribution-graph.jelly" /></td>
</tr>
@@ -25,6 +27,7 @@
<tr class="sortbottom">
<td class="pane-header">${%Total} ${cachedReport.folderCountString}</td>
<td class="pane-header number" data="${cachedReport.fileCount}">${cachedReport.fileCountString}</td>
<td class="pane-header number" data="${cachedReport.commentCount}">${cachedReport.commentCountString}</td>
<td class="pane-header number" data="${cachedReport.lineCount}">${cachedReport.lineCountString}</td>
<td class="pane-header" data="0"> </td>
</tr>
@@ -6,6 +6,7 @@
<td class="pane-header">${%Language}</td>
<td class="pane-header" style="width:2em">${%Files}</td>
<td class="pane-header" style="width:2em">${%Lines}</td>
<td class="pane-header" style="width:2em">${%Comments}</td>
<td class="pane-header" style="width:60%">${%Distribution}</td>
</tr>
</thead>
@@ -17,6 +18,7 @@
<td class="pane"><a href="languageResult/${container.urlName}">${container.name}</a></td>
<td class="pane number" data="${container.fileCount}">${container.fileCountString}</td>
<td class="pane number" data="${container.lineCount}">${container.lineCountString}</td>
<td class="pane number" data="${container.commentCount}">${container.commentCountString}</td>
<td class="pane" data="${container.lineCount}"><st:include page="/tabview/distribution-graph.jelly" /></td>
</tr>
</j:forEach>
@@ -26,6 +28,7 @@
<td class="pane-header">${%Total} ${cachedReport.languageCountString}</td>
<td class="pane-header number" data="${cachedReport.fileCount}">${cachedReport.fileCountString}</td>
<td class="pane-header number" data="${cachedReport.lineCount}">${cachedReport.lineCountString}</td>
<td class="pane-header number" data="${cachedReport.commentCount}">${cachedReport.commentCountString}</td>
<td class="pane-header" data="0"> </td>
</tr>
</tfoot>
@@ -6,6 +6,7 @@
<td class="pane-header">${%Modules}</td>
<td class="pane-header" style="width:2em">${%Files}</td>
<td class="pane-header" style="width:2em">${%Lines}</td>
<td class="pane-header" style="width:2em">${%Comments}</td>
<td class="pane-header" style="width:60%">${%Distribution}</td>
</tr>
</thead>
@@ -17,6 +18,7 @@
<td class="pane"><a href="moduleResult/${container.urlName}">${container.name}</a></td>
<td class="pane number" data="${container.fileCount}">${container.fileCountString}</td>
<td class="pane number" data="${container.lineCount}">${container.lineCountString}</td>
<td class="pane number" data="${container.commentCount}">${container.commentCountString}</td>
<td class="pane" data="${container.lineCount}"><st:include page="/tabview/distribution-graph.jelly" /></td>
</tr>
</j:forEach>
@@ -26,6 +28,7 @@
<td class="pane-header">${%Total} ${cachedReport.moduleCountString}</td>
<td class="pane-header number" data="${cachedReport.fileCount}">${cachedReport.fileCountString}</td>
<td class="pane-header number" data="${cachedReport.lineCount}">${cachedReport.lineCountString}</td>
<td class="pane-header number" data="${cachedReport.commentCount}">${cachedReport.commentCountString}</td>
<td class="pane-header" data="0"> </td>
</tr>
</tfoot>
@@ -12,6 +12,7 @@
<tr>
<td class="pane-header">${%Job}</td>
<td class="pane-header">${%Lines}</td>
<td class="pane-header">${%Comments}</td>
<td class="pane-header">${%Files}</td>
<td class="pane-header">${%Languages}</td>
</tr>
@@ -23,6 +24,7 @@

<td class="pane"><dp:jobLink job="${job}" /></td>
<td class="pane number" data="${stats.lineCount}">${stats.lineCountString}</td>
<td class="pane number" data="${stats.commentCount}">${stats.commentCountString}</td>
<td class="pane number" data="${stats.fileCount}">${stats.fileCountString}</td>
<td class="pane number" data="${stats.languageCount}">${stats.languageCountString}</td>

@@ -35,6 +37,7 @@
<tr class="sortbottom">
<td class="pane-header">${%Total}</td>
<td class="pane-header number" data="${totalLines}">${it.grouping(totalLines)}</td>
<td class="pane-header number" data="${totalComments}">${it.grouping(totalComments)}</td>
<td class="pane-header number" data="${totalFiles}">${it.grouping(totalFiles)}</td>
<td class="pane-header number" data="0">-</td>
</tr>

0 comments on commit 3a12ffe

Please sign in to comment.