org.sonar.plugins.pitest.pitest_source_tab.rb Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sonar-pitest-plugin Show documentation
Show all versions of sonar-pitest-plugin Show documentation
Plugin for the mutation testing tool Pitest
<%= format_measure(measure('pitest_mutations_coverage')) %>
<%
["pitest_mutations_total", "pitest_mutations_detected", "pitest_mutations_noCoverage", "pitest_mutations_killed",
"pitest_mutations_survived", "pitest_mutations_memoryError", "pitest_mutations_timedOut", "pitest_mutations_unknown"].each do |metric_name|
%>
<%= metric(metric_name).short_name%>:
<%= format_measure(measure(metric_name)) %>
<% end %>
<%
def getMutantStyle(mutant)
styleStatusMap = {
"KILLED" => "mutationkilled",
"MEMORY_ERROR" => "mutationkilled",
"TIMED_OUT" => "mutationkilled",
"NO_COVERAGE" => "mutationnocoverage",
"UNKNOWN" => "mutationnocoverage",
"SURVIVED" => "mutationsurvived"
}
return styleStatusMap[mutant["s"]]
end
def countMutantsByStatus(mutants, *status)
result = 0;
mutants.each do |mutant|
if status.include?(mutant["s"])
result = result +1
end
end
return result
end
data = JSON.parse measure('pitest_mutations_data').data
[email protected]_highlighted_lines()
source_lines.each_with_index do |line, index|
mutants = data[(index+1).to_s]
survivedMutants = 0;
notCoveredMutants = 0;
style = "";
displayedIndex = (index+1).to_s
unless mutants.nil?
survivedMutants = countMutantsByStatus(mutants, "SURVIVED")
notCoveredMutants = countMutantsByStatus(mutants, "NO_COVERAGE", "UNKNOWN")
if survivedMutants > 0
style = "red"
elsif notCoveredMutants > 0
style = "orange"
else
style = "green"
end
end
%>
"><%= displayedIndex %>
<%= mutants.nil? ? " " : mutants.length.to_s %>
<%= mutants.nil? ? " " : survivedMutants.to_s + "/" + notCoveredMutants.to_s %>
<%= line%>
<% unless mutants.nil? %>
<% mutants.each do |mutant| %>
<%= mutant["s"] %>
<%= mutant["mname"] %>
<%= mutant["mdesc"] %>
<% end %>
<% end %>
<% end %>
© 2015 - 2024 Weber Informatics LLC | Privacy Policy