Skip to content

Commit

Permalink
Merge pull request #33 from AccelerationNet/JENKINS-17548
Browse files Browse the repository at this point in the history
display violations when no source file is present
  • Loading branch information
mfriedenhagen committed Dec 15, 2014
2 parents 0493faa + a1ed66d commit f055396
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 9 deletions.
28 changes: 25 additions & 3 deletions src/main/java/hudson/plugins/violations/render/FileModelProxy.java
Expand Up @@ -2,6 +2,7 @@

import java.util.Map;
import java.util.Set;
import java.util.TreeSet;

import hudson.Functions;
import hudson.model.AbstractBuild;
Expand Down Expand Up @@ -121,6 +122,19 @@ private void addBlock(
ret.append("</td></tr>\n");
}

public Set<Map.Entry<String, TreeSet<Violation>>> getTypeMapEntries(){
return getFileModel().getTypeMap().entrySet();
}


public Set<Map.Entry<Integer, Set<Violation>>> getViolationEntries(){
return getFileModel().getLineViolationMap().entrySet();
}

public String getDisplayName(){
return getFileModel().getDisplayName();
}

/**
* This gets called from the index.jelly script to
* render the marked up contents of the file.
Expand All @@ -133,6 +147,7 @@ public String getFileContent() {
int previousLine = -1;
int startLine = 0;
int currentLine = -1;

for (Map.Entry<Integer, String> e
: fileModel.getLines().entrySet()) {
currentLine = e.getKey();
Expand Down Expand Up @@ -222,6 +237,15 @@ private String getSeverityIcon(int level) {
return "/plugin/violations/images/16x16/" + color + "-warning.png";
}

/**
* Get the URL for the icon, taking context into account
* @param v the violation
* @return URL
*/
public String getSeverityIconUrl(Violation v){
return contextPath + getSeverityIcon(v.getSeverityLevel());
}

/**
* Get the severity column for a violation.
* @param v the violation.
Expand All @@ -232,9 +256,7 @@ public String severityColumn(Violation v) {
addVDiv(b);
b.append("<a class='healthReport'>");
b.append(
"<img src='"
+ contextPath
+ getSeverityIcon(v.getSeverityLevel())
"<img src='" + getSeverityIconUrl(v)
+ "' alt='"
+ v.getSeverity()
+ "'/>");
Expand Down
Expand Up @@ -22,13 +22,19 @@
value="${rootURL}/plugin/violations/images/16x16"/>

<j:set var="href" value="${it.showLines}"/>
<h3><img src="${image}"/> ${model.displayName}</h3>
<h3><img src="${image}"/>${it.displayName}</h3>


<j:forEach var="t" items="${model.typeMap.entrySet()}">
<j:forEach var="t" items="${it.typeMapEntries}">
<table class="pane">
<tbody>
<tr><td class="pane-header" colspan="5"><j:out value="${it.typeLine(t.key)}"/></td></tr>
<thead>
<tr>
<td class="pane-header" colspan="5">
<j:out value="${it.typeLine(t.key)}"/>
</td>
</tr>
</thead>
<tbody>
<j:forEach var="v" items="${t.value}">
<tr>
<td class="pane">
Expand All @@ -41,15 +47,22 @@
</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>
<td class="pane" width="99%" style="white-space:normal;"><j:out value="${v.message}"/></td>
</tr>
</j:forEach>
</tbody>
</table>
<p></p>
</j:forEach>

<j:out value="${it.fileContent}"/>
<j:choose>
<j:when test="${it.showLines}">
<j:out value="${it.fileContent}"/>
</j:when>
<j:otherwise>
<p>FxCop could not determine source code location. See <a href="https://blogs.msdn.com/b/codeanalysis/archive/2007/05/12/faq-why-is-file-and-line-information-available-for-some-warnings-in-fxcop-but-not-for-others.aspx">FAQ: Why is file and line information available for some warnings in FxCop but not for others?</a> for explanations.</p>
</j:otherwise>
</j:choose>

<!--
<j:set var="line" value="${model.nextLine}"/>
Expand Down
1 change: 1 addition & 0 deletions src/main/webapp/css/style.css
Expand Up @@ -34,6 +34,7 @@ td.line {
td.message {
border-width: 0px 1px 0px 0px;
width: 100%;
white-space: normal;
}


Expand Down

0 comments on commit f055396

Please sign in to comment.