kjeldahl-metric_fu 1.1.5.1 → 1.1.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -116,11 +116,23 @@ module MetricFu
116
116
  def file_url(name, line) # :nodoc:
117
117
  filename = File.expand_path(name.gsub(/^\//, ''))
118
118
  if MetricFu.configuration.platform.include?('darwin')
119
- "txmt://open/?url=file://#{filename}" << (line ? "&line=#{line}" : "")
119
+ "txmt://open/?url=file://#{filename}" << (line ? "&amp;line=#{line}" : "")
120
120
  else
121
121
  "file://#{filename}"
122
122
  end
123
123
  end
124
+
125
+ # Replaces <,> and & with their entities
126
+ def encode(content)
127
+ content.gsub!('&', '&amp;')
128
+ {'<' => '&lt;', '>' => '&gt;'}.each_pair { |s,r| content.gsub!(s,r)}
129
+ content
130
+ end
131
+
132
+ def graph_image(file, html_options = {})
133
+ attributes = {:alt => 'Graph image'}.merge(html_options).map{|k,v| "#{k}='#{v}'"}
134
+ "<img src='#{file}?#{rand(2000)}' #{attributes}/>"
135
+ end
124
136
 
125
137
  # Provides a brain dead way to cycle between two values during
126
138
  # an iteration of some sort. Pass in the first_value, the second_value,
@@ -87,7 +87,11 @@ module MetricFu
87
87
 
88
88
  def to_h
89
89
  global_percent_run = ((@global_total_lines_run.to_f / @global_total_lines.to_f) * 100)
90
- {:rcov => @rcov.merge({:global_percent_run => round_to_tenths(global_percent_run) })}
90
+ result = @rcov.merge({:global_percent_run => round_to_tenths(global_percent_run) })
91
+ def result.files
92
+ select {|k,v| k != :global_percent_run}
93
+ end
94
+ {:rcov => result}
91
95
  end
92
96
 
93
97
  private
@@ -2,7 +2,8 @@ class AwesomeTemplate < MetricFu::Template
2
2
 
3
3
  def write
4
4
  # Getting rid of the crap before and after the project name from integrity
5
- @name = File.basename(Dir.pwd).gsub(/^\w+-|-\w+$/, "")
5
+ dir = MetricFu.configuration.is_cruise_control_rb? ? File.join(Dir.pwd, '..') : Dir.pwd
6
+ @name = File.basename(File.expand_path(dir)).gsub(/^\w+-|-\w+$/, "")
6
7
 
7
8
  report.each_pair do |section, contents|
8
9
  if template_exists?(section)
@@ -210,6 +210,9 @@ a {
210
210
  color: #337022; }
211
211
  #content #projects li a.failed {
212
212
  color: #ff1100; }
213
+ #content #projects li a span.totals {
214
+ font-size: 0.5em;
215
+ padding-left: 1em;}
213
216
  #content #projects li .meta {
214
217
  position: absolute;
215
218
  right: .6em;
@@ -2,7 +2,7 @@
2
2
 
3
3
  <p><a href='http://ruby.sadi.st/Flay.html'>Flay</a> analyzes ruby code for structural similarities.</p>
4
4
 
5
- <img src="flay.png?<%= Time.now %>">
5
+ <%= graph_image('flay.png', :alt => "Structural similarities graph") %>
6
6
 
7
7
  <h4>Total Score (lower is better): <%= @flay[:total_score] %></h4>
8
8
 
@@ -19,7 +19,7 @@
19
19
  <%= link_to_filename(file[:name], file[:line]) %><br/>
20
20
  <% end %>
21
21
  </td>
22
- <td><%= match[:reason] %></td>
22
+ <td><%= encode(match[:reason]) %></td>
23
23
  </tr>
24
24
  <% count += 1 %>
25
25
  <% end %>
@@ -1,7 +1,7 @@
1
1
  <h3>Flog Results</h3>
2
2
  <p><a href='http://ruby.sadi.st/Flog.html'>Flog</a> measures code complexity.</p>
3
3
 
4
- <img src="flog.png?<%= Time.now %>">
4
+ <%= graph_image('flog.png', :alt => "Code complexity graph") %>
5
5
 
6
6
  <h2>Total Flog score for all methods: <%= @flog[:total]%></h2>
7
7
  <h2>Average Flog score for all methods: <%= @flog[:average]%></h2>
@@ -28,7 +28,7 @@
28
28
  <% @flog[:pages].each do |page| %>
29
29
  <h2 id="<%= page[:path].gsub(/[^a-z]+/, '_') %>"><%= link_to_filename page[:path] %></h2>
30
30
  <% page[:scanned_methods].each do |sm| %>
31
- <p><%= sm[:name] %></p>
31
+ <p><%= encode(sm[:name]) %></p>
32
32
  <p>Total Score: <%=sm[:score]%></p>
33
33
  <table>
34
34
  <tr>
@@ -38,7 +38,7 @@
38
38
  <% sm[:operators].each do |operator| %>
39
39
  <tr>
40
40
  <td><%= operator[:score] %></td>
41
- <td><%= operator[:operator] %></td>
41
+ <td><%= encode(operator[:operator]) %></td>
42
42
  </tr>
43
43
  <% end %>
44
44
  </table>
@@ -4,13 +4,13 @@
4
4
  <li class='even failure'><a href="churn.html">Churn</a></li>
5
5
  <% end %>
6
6
  <% if @flay %>
7
- <li class='even failure'><a href="flay.html">Flay</a></li>
7
+ <li class='even failure'><a href="flay.html">Flay <span class='totals'><%= @flay[:total_score] %></span></a></li>
8
8
  <% end %>
9
9
  <% if @flog %>
10
- <li class='even failure'><a href="flog.html">Flog</a></li>
10
+ <li class='even failure'><a href="flog.html">Flog <span class='totals'><%= @flog[:total]%> / <%= @flog[:average]%></span></a></li>
11
11
  <% end %>
12
12
  <% if @rcov %>
13
- <li class='even failure'><a href="rcov.html">Rcov</a></li>
13
+ <li class='even failure'><a href="rcov.html">Rcov <span class='totals'><%= @rcov[:global_percent_run] %>%</span></a> </li>
14
14
  <% end %>
15
15
  <% if @reek %>
16
16
  <li class='even failure'><a href="reek.html">Reek</a></li>
@@ -22,7 +22,7 @@
22
22
  <li class='even failure'><a href="saikuro.html">Saikuro</a></li>
23
23
  <% end %>
24
24
  <% if @stats %>
25
- <li class='even failure'><a href="stats.html">Stats</a></li>
25
+ <li class='even failure'><a href="stats.html">Stats Code <span class='totals'><%=@stats[:codeLOC]%> lines</span></a></li>
26
26
  <% end %>
27
27
  </ul>
28
28
  <p>Generated on <%= Time.now.localtime %></p>
@@ -4,13 +4,13 @@
4
4
  <meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
5
5
  <meta content='en' http-equiv='Content-Language' />
6
6
  <title>metrics</title>
7
- <style>
7
+ <style type="text/css">
8
8
  <%= inline_css("css/reset.css") %>
9
9
  <%= inline_css("css/buttons.css") %>
10
10
  <%= inline_css("css/integrity.css") %>
11
11
  <%= inline_css("css/default.css") %>
12
12
  </style>
13
- <link REL="SHORTCUT ICON" HREF="/favicon.ico">
13
+ <link rel="SHORTCUT ICON" href="/favicon.ico"/>
14
14
  </head>
15
15
  <body>
16
16
  <div id='header'>
@@ -2,16 +2,16 @@
2
2
 
3
3
  <p>C0 code coverage information.</p>
4
4
 
5
- <img src="rcov.png?<%= Time.now %>">
5
+ <%= graph_image('rcov.png', :alt => "C0 coverage graph") %>
6
6
 
7
- <p>Total Coverage: <%= @rcov.delete(:global_percent_run) %>% </p>
7
+ <p>Total Coverage: <%= @rcov[:global_percent_run] %>% </p>
8
8
  <table>
9
9
  <tr>
10
10
  <th>File Path</th>
11
11
  <th>Percent run</th>
12
12
  </tr>
13
13
  <% count = 0 %>
14
- <% @rcov.sort_by{ |k,v| v[:percent_run] }.each do |fname, file| %>
14
+ <% @rcov.files.sort_by{ |k,v| v[:percent_run] }.each do |fname, file| %>
15
15
  <tr>
16
16
  <td><a href="#<%= fname.gsub(/[^a-z]+/, '_') %>"><%= fname %></a></td>
17
17
  <td><%= file[:percent_run] %></td>
@@ -20,14 +20,14 @@
20
20
  <% end %>
21
21
  </table>
22
22
 
23
- <% @rcov.sort_by{ |k,v| v[:percent_run] }.each do |fname, file| %>
23
+ <% @rcov.files.sort_by{ |k,v| v[:percent_run] }.each do |fname, file| %>
24
24
  <h2 id="<%= fname.gsub(/[^a-z]+/, '_') %>"> <%= fname %></h2>
25
25
  <div class="rcov_overflow">
26
26
  <table class="rcov_code">
27
27
  <% file[:lines].each_with_index do |line, index| %>
28
28
  <tr>
29
29
  <% css_class = line[:was_run] ? "rcov_run" : "rcov_not_run" %>
30
- <td class="<%= css_class %>"><%= link_to_filename(fname, index + 1, "<pre>#{line[:content]}</pre>") %></td>
30
+ <td class="<%= css_class %>"><pre><%= link_to_filename(fname, index + 1, encode(line[:content])) %></pre></td>
31
31
  </tr>
32
32
  <% end %>
33
33
  </table>
@@ -2,7 +2,7 @@
2
2
 
3
3
  <p><a href="http://reek.rubyforge.org/">Reek</a> detects common code smells in ruby code.</p>
4
4
 
5
- <img src="reek.png?<%= Time.now %>">
5
+ <%= graph_image('reek.png', :alt => "Code smells graph") %>
6
6
 
7
7
  <table>
8
8
  <tr>
@@ -17,13 +17,13 @@
17
17
  <tr class='<%= cycle("light", "dark", count) %>'>
18
18
  <td><%= link_to_filename(match[:file_path]) %></td>
19
19
  <td>
20
- <%= smell[:method] %>
20
+ <%= encode(smell[:method]) %>
21
21
  </td>
22
22
  <td>
23
- <%= smell[:message] %>
23
+ <%= encode(smell[:message]) %>
24
24
  </td>
25
25
  <td>
26
- <%= smell[:type] %>
26
+ <%= encode(smell[:type]) %>
27
27
  </td>
28
28
  </tr>
29
29
  <% count += 1 %>
@@ -2,7 +2,7 @@
2
2
 
3
3
  <p><a href="http://roodi.rubyforge.org/">Roodi</a> parses your Ruby code and warns you about design issues you have based on the checks that is has configured.</p>
4
4
 
5
- <img src="roodi.png?<%= Time.now %>">
5
+ <%= graph_image('roodi.png') %>
6
6
 
7
7
  <table>
8
8
  <tr>
@@ -13,7 +13,7 @@
13
13
  <% @roodi[:problems].each do |problem| %>
14
14
  <tr class='<%= cycle("light", "dark", count) %>'>
15
15
  <td><%= link_to_filename(problem[:file], problem[:line]) %></td>
16
- <td><%= problem[:problem] %></td>
16
+ <td><%= encode(problem[:problem]) %></td>
17
17
  </tr>
18
18
  <% count += 1 %>
19
19
  <% end %>
@@ -10,7 +10,7 @@
10
10
  </tr>
11
11
  <% @saikuro[:methods].each do |method| %>
12
12
  <tr>
13
- <td><%= method[:name] %></td>
13
+ <td><%= encode(method[:name]) %></td>
14
14
  <td><%= method[:complexity] %></td>
15
15
  <td><%= method[:lines] %></td>
16
16
  </tr>
@@ -28,7 +28,7 @@
28
28
  </tr>
29
29
  <% @saikuro[:classes].each do |klass| %>
30
30
  <tr>
31
- <td><%= klass[:name] %></td>
31
+ <td><%= encode(klass[:name]) %></td>
32
32
  <td><%= klass[:complexity] %></td>
33
33
  <td><%= klass[:lines] %></td>
34
34
  </tr>
@@ -53,7 +53,7 @@
53
53
  <% klass[:methods].each do |method| %>
54
54
  <tr>
55
55
  <td>
56
- <%= method[:name] %>
56
+ <%= encode(method[:name]) %>
57
57
  </td>
58
58
  <td>
59
59
  <%= method[:complexity] %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kjeldahl-metric_fu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5.1
4
+ version: 1.1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Scruggs