@Override
public String getColumn4() {
+ String age = "";
+ if (violation.getAge()!=null && violation.getAge()>0) {
+ age = " <span class='note'>(" + violation.getAge() + " days)</span>";
+ }
return "<div class=\"warn\">" + Icons.forPriority(violation.getPriority()).getHTML() + "</img> "
- + Utils.formatDate(violation.getCreatedAt())
+ " <a href=\"" + Links.urlForRule(violation.getRuleKey(), false)
+ "\" onclick=\"window.open(this.href,'rule','height=800,width=900,scrollbars=1,resizable=1');return false;\" title=\""
+ violation.getRuleKey() + "\"><b>"
+ Utils.escapeHtml(violation.getRuleName()) + "</b></a> : "
- + Utils.escapeHtml(violation.getMessage()) + "</div>";
+ + Utils.escapeHtml(violation.getMessage()) + age + "</div>";
}
}
public void start() {
List<PastSnapshot> variationSnapshots = configuration.getProjectPastSnapshots();
for (PastSnapshot variationSnapshot : variationSnapshots) {
+ projectSnapshot = session.reattach(Snapshot.class, projectSnapshot.getId());
projectSnapshot.setVariationMode(variationSnapshot.getIndex(), variationSnapshot.getMode());
projectSnapshot.setVariationModeParam(variationSnapshot.getIndex(), variationSnapshot.getModeParameter());
session.save(projectSnapshot);
}
+ session.commit();
}
}
Violation violation = new Violation();
violation.setMessage(JsonUtils.getString(json, "message"));
violation.setLine(JsonUtils.getInteger(json, "line"));
- violation.setPriority(JsonUtils.getString(json, "priority"));
+ violation.setSeverity(JsonUtils.getString(json, "priority"));
violation.setCreatedAt(JsonUtils.getDate(json, "createdAt"));
+ violation.setAge(JsonUtils.getInteger(json, "age"));
JSONObject rule = (JSONObject) json.get("rule");
if (rule != null) {
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
#
module DrilldownHelper
+ include DashboardHelper
def measure_or_variation_value(measure)
if measure
belongs_to :rule
belongs_to :snapshot
+ def age_in_days
+ if created_at
+ ((snapshot.created_at - created_at)/(60 * 60 * 24)).to_i
+ else
+ nil
+ end
+ end
+
def to_hash_json
json = {}
json['message'] = message
json['line'] = line if line
json['priority'] = Sonar::RulePriority.to_s(failure_level).upcase
- json['createdAt'] = format_datetime(created_at) if created_at
+ if created_at
+ json['createdAt'] = format_datetime(created_at)
+ json['age'] = age_in_days
+ end
json['rule'] = {
:key => rule.key,
- :name => rule.name}
+ :name => rule.name
+ }
json['resource'] = {
:key => snapshot.project.key,
:name => snapshot.project.name,
:scope => snapshot.project.scope,
:qualifier => snapshot.project.qualifier,
- :language => snapshot.project.language}
+ :language => snapshot.project.language
+ }
json
end
xml.message(message)
xml.line(line) if line
xml.priority(Sonar::RulePriority.to_s(failure_level))
- xml.createdAt(format_datetime(created_at)) if created_at
+ if created_at
+ xml.createdAt(format_datetime(created_at))
+ xml.age(age_in_days)
+ end
xml.rule do
xml.key(rule.key)
xml.name(rule.name)
<div id="snapshot_title" class="page_title">
<h4>
<%
- version_event=@snapshot.event(EventCategory::KEY_VERSION)
profile_measure=@snapshot.measure(Metric::PROFILE)
%>
- <%= link_to_favourite(@project) -%> <%= "#{version_event.fullname} - " if version_event %> <%= l @snapshot.created_at %>
+ <%= link_to_favourite(@project) -%> Version <%= @snapshot.version -%> - <%= l @snapshot.created_at %>
<% if profile_measure %> - Profile <%= link_to profile_measure.data, :controller => '/rules_configuration', :action => 'index', :id => profile_measure.value.to_i %><% end %>
- Compare to
<form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:var => nil} -%>" style="display: inline">
<%= variation_select_option(@snapshot, 1) -%>
<%= variation_select_option(@snapshot, 2) -%>
<%= variation_select_option(@snapshot, 3) -%>
+ <%= variation_select_option(@snapshot, 4) -%>
+ <%= variation_select_option(@snapshot, 5) -%>
</select>
</form>
</h4>
-<%= render :partial => 'project/snapshot_title' -%>
+<div id="snapshot_title" class="page_title">
+<h4>
+<%
+ profile_measure=@snapshot.measure(Metric::PROFILE)
+ %>
+<%= link_to_favourite(@project) -%> Version <%= @snapshot.version -%> - <%= l @snapshot.created_at %>
+<% if profile_measure %> - Profile <%= link_to profile_measure.data, :controller => '/rules_configuration', :action => 'index', :id => profile_measure.value.to_i %><% end %>
+- <form method="GET" action="<%= url_for :only_path=>true, :overwrite_params => {:var => nil} -%>" style="display: inline">
+ <select id="select-comparison" name="var" onchange="submit()" class="small">
+ <option value="">All violations</option>
+ <%= variation_select_option(@snapshot, 1) -%>
+ <%= variation_select_option(@snapshot, 2) -%>
+ <%= variation_select_option(@snapshot, 3) -%>
+ <%= variation_select_option(@snapshot, 4) -%>
+ <%= variation_select_option(@snapshot, 5) -%>
+ </select>
+ </form>
+</h4>
+</div>
+
<%= render :partial => 'gwt/base', :locals => {:resource => @highlighted_resource, :popup => false, :metric => 'violations'} %>
<%= render :partial => 'gwt/resource_viewers', :locals => {:resource => @project} %>
version_event=@snapshot.event(EventCategory::KEY_VERSION)
profile_measure=@snapshot.measure(Metric::PROFILE)
%>
-<%= link_to_favourite(@project) -%> <%= "#{version_event.fullname} - " if version_event %> <%= l @snapshot.created_at %>
+<%= link_to_favourite(@project) -%> Version <%= "#{@snapshot.version} -%> - <%= l @snapshot.created_at %>
<% if profile_measure %> - profile <%= link_to profile_measure.data, :controller => '/rules_configuration', :action => 'index', :id => profile_measure.value.to_i %><% end %>
</h4>
</div>
-<div id='dashboard'>
-<%= render :partial => 'project/snapshot_title' %>
-<table><tr>
- <td width="390px" valign="top" style="padding: 0 4px 0 0">
-
- </td>
- <td width="390px" valign="top" style="padding: 0 0 0 4px">
-
-<% @widgets.each do |widget|
- begin
- widget_body=render :inline => widget.getTarget().getTemplate()
- rescue => error
- logger.error("Can not render widget #{widget.getId()}: " + error)
- logger.error(error.backtrace.join("\n"))
- widget_body="<p>Can not render widget #{widget.getTitle()}. See logs.</p>"
- end
- if widget_body.include? '<'
-%>
-<div id="<%= widget.getId() -%>" class="widget">
-<%= widget_body %>
-<div class="clear"></div>
-</div>
-<% else %>
-<div id="<%= widget.getId() -%>" ></div>
-<% end
-end %>
- </td>
-</tr></table>
-<script type="text/javascript">
- function selectReviewMetric(){
- $$('.review_description_update').each(function(element) {
- element.hide();
- });
- review = $('review_metric_id').value;
- $('review_description_'+review).show();
- $('review_value_'+review).show();
- }
-
- function selectEventCateg(){
- $$('#event_cat_desc .comments').each(function(elt) {
- elt.hide();
- });
- selected_categ = $('event_category').value;
- if (selected_categ!=null && selected_categ!='') {
- $('event_cat_desc_'+selected_categ).show();
- }
- }
-</script>
-</div>
\ No newline at end of file
private String resourceScope = null;
private String resourceQualifier = null;
private Date createdAt = null;
+ private Integer age = null;
public String getMessage() {
return message;
return this;
}
+ /**
+ * @since 2.5
+ */
+ public Integer getAge() {
+ return age;
+ }
+
+ public Violation setAge(Integer age) {
+ this.age = age;
+ return this;
+ }
+
/**
* @since 2.5
*/
violation.setLine(JsonUtils.getInteger(json, "line"));
violation.setSeverity(JsonUtils.getString(json, "priority"));
violation.setCreatedAt(JsonUtils.getDateTime(json, "createdAt"));
+ violation.setAge(JsonUtils.getInteger(json, "age"));
JSONObject rule = (JSONObject) json.get("rule");
if (rule != null) {