issuesdensity.widgets.hotspot_most_violated_components.html.erb Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sonar-issues-density-plugin Show documentation
Show all versions of sonar-issues-density-plugin Show documentation
Provides RCI (Rules Compliance Index) and Weighted Issues metrics
The newest version!
<%
limit = widget_properties["numberOfLines"]
metric = Metric.by_key('weighted_violations')
snapshots_conditions=["snapshots.qualifier in (:qualifiers)", "snapshots.islast=:islast", "snapshots.status = 'P'"]
snapshots_values={:qualifiers => @snapshot.leaves_qualifiers, :islast => true}
snapshots_conditions << '(snapshots.root_snapshot_id=:root_sid AND snapshots.path LIKE :path)'
snapshots_values[:root_sid] = (@snapshot.root_snapshot_id || @snapshot.id)
snapshots_values[:path]="#{@snapshot.path}#{@snapshot.id}.%"
measures_conditions = ["project_measures.rule_id IS NULL AND project_measures.characteristic_id IS NULL AND project_measures.person_id IS NULL"]
measures_values = {}
measures_conditions << "project_measures.metric_id = :m_id"
measures_values[:m_id] = metric.id
measures=ProjectMeasure.find(:all,
:joins => :snapshot,
:conditions => [(snapshots_conditions + measures_conditions).join(' AND '), snapshots_values.merge(measures_values)],
:order => "project_measures.value #{'DESC' if metric.direction<0}",
:limit => limit)
measures=measures.select { |m| m.text_value.present? }
snapshots=Snapshot.find(measures.map { |m| m.snapshot_id }, :include => 'project')
snapshots_by_id = {}
snapshots.each do |s|
snapshots_by_id[s.id]=s
end
title = message('widget.hotspot_most_violated_resources.name')
if measures.empty?
%>
<%= title -%>
<%
else
%>
<%
measures.each do |measure|
resource = snapshots_by_id[measure.snapshot_id].resource
violations_per_severity={}
measure.text_value.split(';').each do |part|
fields=part.split('=')
violations_per_severity[fields[0]]=fields[1]
end
%>
<%= link_to_resource(resource, h(resource.name), {:metric => 'violations', :class => 'underlined-link'}) -%>
<%= violations_per_severity["BLOCKER"] ? violations_per_severity["BLOCKER"].to_s : "0" -%>
<%= violations_per_severity["CRITICAL"] ? violations_per_severity["CRITICAL"].to_s : "0" -%>
<%= violations_per_severity["MAJOR"] ? violations_per_severity["MAJOR"].to_s : "0" -%>
<%= violations_per_severity["MINOR"] ? violations_per_severity["MINOR"].to_s : "0" -%>
<%= violations_per_severity["INFO"] ? violations_per_severity["INFO"].to_s : "0" -%>
<%
end
%>
<% end %>