Violations プラグイン コードをダウンロードして修正し、ソース コードを持たないファイルの違反の表を表示してから、Violations プラグインを再コンパイルしました (そして、修正したプラグインを手動で Jenkins にロードしました)。
私の元のスクリーンショットでわかるように、ファイル名も表示されませんでした。「getFileNameAlt」関数は名前を適切に取得し、以下のゼリースクリプトの「File: ${it.fileNameAlt}」行に表示されます (リンクを参照)。下のスクリーンショットへ)。
~\violations\src\main\java\hudson\plugins\violations\render\FileModelProxy.java に以下を追加して、テーブルをレンダリングしました。
public String getFileNameAlt() {
return new File(fileModel.getDisplayName()).getName();
}
public String getSummaryTable() {
StringBuilder gst = new StringBuilder();
int count = 0;
gst.append(" <table class='violations' width='100%'>\n");
gst.append(" <tr>\n");
gst.append(" <td class='violations-header'> # </td>\n");
gst.append(" <td class='violations-header'> Type </td>\n");
gst.append(" <td class='violations-header'> Class</td>\n");
gst.append(" <td class='violations-header'> Message</td>\n");
gst.append(" <td class='violations-header'> Description</td>\n");
gst.append(" </tr>\n");
Set<Violation> violations = fileModel.getLineViolationMap().get(0);
for (Violation v: violations) {
++count;
gst.append(" <tr>\n");
gst.append(" <td class='violations'>");
gst.append(count);
gst.append("</td>\n");
gst.append(" <td class='violations'>");
gst.append(v.getType());
gst.append("</td>\n");
gst.append(" <td class='violations'>");
gst.append(v.getSource());
gst.append("</td>\n");
gst.append(" <td class='violations'>");
gst.append(v.getMessage());
gst.append("</td>\n");
gst.append(" <td class='violations'>");
gst.append(v.getPopupMessage());
gst.append("</td>\n");
gst.append(" </tr>\n");
}
//}
gst.append(" </table>\n");
gst.append("<p><br>\n");
gst.append("<h3>Total Number of violations: \n");
gst.append(count);
gst.append("</h3><p>\n");
return gst.toString();
}
そして、〜\violations\target\classes\hudson\plugins\violations\render\FileModelProxy\index.jellyファイルを更新して、ソースコード内の違反を表示するコードのすぐ上に追加しました(これは私にとってはうまくいきました)。は、以下の "" 要約行です。
<j:set
var="iconDir"
value="${rootURL}/plugin/violations/images/16x16"/>
<j:set var="href" value="${it.showLines}"/>
<h1><img src="${image}"/> File: ${it.fileNameAlt}</h1>
<j:out value="${it.summaryTable}"/>
<j:forEach var="t" items="${model.typeMap.entrySet()}">
<table class="pane">
<tbody>
<tr><td class="pane-header" colspan="5"><j:out value="${it.typeLine(t.key)}"/></td></tr>
<j:forEach var="v" items="${t.value}">
<tr>
<td class="pane">
<j:if test="${href}">
<a href="#line${v.line}">${v.line}</a>
</j:if>
<j:if test="${!href}">
${v.line}
</j:if>
</td>
<!--<td class="pane">${v.source}</td> -->
<td class="pane"><j:out value="${it.severityColumn(v)}"/></td>
<td class="pane" width="99%">${v.message}</td>
</tr>
</j:forEach>
</tbody>
</table>
<p></p>
</j:forEach>
最後に、style.css ファイルを少しいじって、"violations" (~\violations\target\violations\css\style.css) というテーブル スタイル定義を追加しました。
.violations {
margin-top: 4px;
}
.violations td {
padding: 4px 4px 3px 4px;
}
table.violations {
width: 100%;
border-collapse: collapse;
border: 1px #bbb solid;
}
table.violations > tbody > tr > td:last-child {
border-right: 1px #bbb solid;
}
td.violations {
border: 1px #bbb solid;
padding: 3px 4px 3px 4px;
vertical-align: middle;
}
td.violations-header {
border: 1px #bbb solid;
border-right: none;
border-left: none;
background-color: #f0f0f0;
font-weight: bold;
}
th.violations {
border: 1px #bbb solid;
font-weight: bold;
}
次の図は、ソース コードを持たないファイルの結果のテーブルを示しています。私の場合、ファイルは「.cs」で終わっていません
http://i.stack.imgur.com/StChP.jpg