rubycritic 0.0.15 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rubycritic/configuration.rb +6 -5
- data/lib/rubycritic/core/analysed_file.rb +5 -3
- data/lib/rubycritic/report_generators/base.rb +7 -1
- data/lib/rubycritic/report_generators/code_file.rb +2 -2
- data/lib/rubycritic/report_generators/current_code_file.rb +1 -1
- data/lib/rubycritic/report_generators/line.rb +4 -1
- data/lib/rubycritic/report_generators/templates/code_index.html.erb +1 -1
- data/lib/rubycritic/report_generators/templates/layouts/application.html.erb +4 -4
- data/lib/rubycritic/report_generators/view_helpers.rb +17 -7
- data/lib/rubycritic/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a43f9d486a902fa7eda73e1df3e492cdb6ab085
|
4
|
+
data.tar.gz: a29c16803a4e83f4b559065630b024b76b45a69c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0720b07a319110c0cb31dc6c5ca1ec69fef4eb60d7759069ba1e1e869a16f537d1e7d49553aa5ca544ccc91993c481f16f6fe7da2abe8917358499f952e2436
|
7
|
+
data.tar.gz: 05e48772690e0230b7e8d5788751204e754ccaaf0c4e40d72a4e5520fc0bad81ddc3f87a09f141d9a494372de94ae9c1e6df5adf808d2b765de22a3ae23294d1
|
@@ -13,11 +13,12 @@ module Rubycritic
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def root=(path)
|
16
|
-
@root =
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
@root =
|
17
|
+
if Pathname(path).relative?
|
18
|
+
File.expand_path(path)
|
19
|
+
else
|
20
|
+
path
|
21
|
+
end
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
@@ -31,9 +31,11 @@ module Rubycritic
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def complexity_per_method
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
if methods_count == 0
|
35
|
+
"N/A"
|
36
|
+
else
|
37
|
+
complexity.fdiv(methods_count).round(1)
|
38
|
+
end
|
37
39
|
end
|
38
40
|
|
39
41
|
def has_smells?
|
@@ -23,7 +23,7 @@ module Rubycritic
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def file_directory
|
26
|
-
root_directory
|
26
|
+
@file_directory ||= root_directory
|
27
27
|
end
|
28
28
|
|
29
29
|
def file_name
|
@@ -34,6 +34,12 @@ module Rubycritic
|
|
34
34
|
raise NotImplementedError.new("The #{self.class} class must implement the #{__method__} method.")
|
35
35
|
end
|
36
36
|
|
37
|
+
private
|
38
|
+
|
39
|
+
def root_directory
|
40
|
+
@root_directory ||= Pathname.new(::Rubycritic.configuration.root)
|
41
|
+
end
|
42
|
+
|
37
43
|
def get_binding
|
38
44
|
binding
|
39
45
|
end
|
@@ -14,7 +14,7 @@ module Rubycritic
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def file_directory
|
17
|
-
|
17
|
+
@file_directory ||= root_directory + @pathname.dirname
|
18
18
|
end
|
19
19
|
|
20
20
|
def file_name
|
@@ -26,7 +26,7 @@ module Rubycritic
|
|
26
26
|
File.readlines(@pathname).each.with_index(LINE_NUMBER_OFFSET) do |line_text, line_number|
|
27
27
|
location = Location.new(@pathname, line_number)
|
28
28
|
line_smells = @analysed_file.smells_at_location(location)
|
29
|
-
file_code << Line.new(line_text, line_smells).render
|
29
|
+
file_code << Line.new(file_directory, line_text, line_smells).render
|
30
30
|
end
|
31
31
|
|
32
32
|
file_body = TEMPLATE.result(get_binding { file_code })
|
@@ -8,7 +8,10 @@ module Rubycritic
|
|
8
8
|
NORMAL_TEMPLATE = erb_template("line.html.erb")
|
9
9
|
SMELLY_TEMPLATE = erb_template("smelly_line.html.erb")
|
10
10
|
|
11
|
-
|
11
|
+
attr_reader :file_directory
|
12
|
+
|
13
|
+
def initialize(file_directory, text, smells)
|
14
|
+
@file_directory = file_directory
|
12
15
|
@text = CGI::escapeHTML(text.chomp)
|
13
16
|
@smells = smells
|
14
17
|
@template =
|
@@ -13,7 +13,7 @@
|
|
13
13
|
<% @analysed_files.each do |analysed_file| %>
|
14
14
|
<tr>
|
15
15
|
<td class="first-cell">
|
16
|
-
<a href="<%= file_path(analysed_file.pathname) %>"><%= analysed_file.name %></a>
|
16
|
+
<a href="<%= file_path(analysed_file.pathname.sub_ext('.html')) %>"><%= analysed_file.name %></a>
|
17
17
|
</td>
|
18
18
|
<td class="numeric-cell"><%= analysed_file.churn %></td>
|
19
19
|
<td class="numeric-cell"><%= analysed_file.complexity %></td>
|
@@ -10,11 +10,11 @@
|
|
10
10
|
</head>
|
11
11
|
<body>
|
12
12
|
<header class="project-header group">
|
13
|
-
<h1 class="logo"><a href="<%= file_path('overview') %>" class="logo-link">RubyCritic</a></h1>
|
13
|
+
<h1 class="logo"><a href="<%= file_path('overview.html') %>" class="logo-link">RubyCritic</a></h1>
|
14
14
|
<nav class="project-nav">
|
15
|
-
<a href="<%= file_path('overview') %>" class="project-nav-item">Overview</a>
|
16
|
-
<a href="<%= file_path('code_index') %>" class="project-nav-item">Code</a>
|
17
|
-
<a href="<%= file_path('smells_index') %>" class="project-nav-item">Smells</a>
|
15
|
+
<a href="<%= file_path('overview.html') %>" class="project-nav-item">Overview</a>
|
16
|
+
<a href="<%= file_path('code_index.html') %>" class="project-nav-item">Code</a>
|
17
|
+
<a href="<%= file_path('smells_index.html') %>" class="project-nav-item">Smells</a>
|
18
18
|
</nav>
|
19
19
|
</header>
|
20
20
|
<%= yield %>
|
@@ -8,27 +8,37 @@ module Rubycritic
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def javascript_tag(file)
|
11
|
-
"<script src='" + asset_path(
|
11
|
+
"<script src='" + asset_path("javascripts", "#{file}.js").to_s + "'></script>"
|
12
12
|
end
|
13
13
|
|
14
14
|
def stylesheet_path(file)
|
15
|
-
asset_path(
|
15
|
+
asset_path("stylesheets", "#{file}.css")
|
16
16
|
end
|
17
17
|
|
18
|
-
def asset_path(
|
19
|
-
|
18
|
+
def asset_path(*fragments)
|
19
|
+
relative_path(([root_directory, "assets"] + fragments).reduce(:+))
|
20
20
|
end
|
21
21
|
|
22
22
|
def file_path(file)
|
23
|
-
|
23
|
+
relative_path(root_directory + file)
|
24
24
|
end
|
25
25
|
|
26
26
|
def smell_location_path(location)
|
27
|
-
|
27
|
+
relative_path(root_directory + "#{location.pathname.sub_ext('.html')}#L#{location.line}")
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def relative_path(pathname)
|
33
|
+
pathname.relative_path_from(file_directory)
|
34
|
+
end
|
35
|
+
|
36
|
+
def file_directory
|
37
|
+
raise NotImplementedError.new("The #{self.class} class must implement the #{__method__} method.")
|
28
38
|
end
|
29
39
|
|
30
40
|
def root_directory
|
31
|
-
|
41
|
+
raise NotImplementedError.new("The #{self.class} class must implement the #{__method__} method.")
|
32
42
|
end
|
33
43
|
end
|
34
44
|
|
data/lib/rubycritic/version.rb
CHANGED