fukuzatsu 0.9.8 → 0.9.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/README.md +10 -6
- data/lib/fukuzatsu/analyzer.rb +12 -12
- data/lib/fukuzatsu/formatters/html.rb +2 -1
- data/lib/fukuzatsu/formatters/templates/index.html.haml +20 -7
- data/lib/fukuzatsu/formatters/templates/output.html.haml +43 -31
- data/lib/fukuzatsu/version.rb +1 -1
- data/spec/analyzer_spec.rb +32 -1
- data/spec/fixtures/eg_class.rb +8 -0
- data/spec/fixtures/eg_mod_class.rb +2 -0
- data/spec/fixtures/eg_mod_class_2.rb +5 -0
- data/spec/fixtures/eg_module.rb +2 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc7d149f079d0f937f492a870b0afaf580b8a282
|
4
|
+
data.tar.gz: a07ef85ca31e0ac5091fc474f8b8624c31d378c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 636161e9e1e6cb468d6027475aed98619ef62b624b2881f9bd52cff4ae83110ce605ee2826f624e1ac81b45ee9d4e08f76b40ea426a8ba0483cdc9d650aea22f
|
7
|
+
data.tar.gz: b62ff6dccd7cbbe91e5c8ca209c061008728e69e215d06f8436615453245cbe9152f17c5c65ef735e74a35808b8e67dd4b84080c441d7128365760a8b06ed419
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -2,11 +2,15 @@
|
|
2
2
|
|
3
3
|
*Note: this gem is a work in progress and should not be considered production-ready until version 1.0*
|
4
4
|
|
5
|
-
Fukuzatsu ("complexity") is a tool for measuring code complexity in Ruby class files. Its analysis
|
5
|
+
Fukuzatsu ("complexity") is a tool for measuring code complexity in Ruby class files. Its analysis
|
6
|
+
generates relative complexity figures similar to the results of cyclomatic complexity algorithms.
|
7
|
+
(You can learn more about cyclomatic complexity at http://en.wikipedia.org/wiki/Cyclomatic_complexity)
|
6
8
|
|
7
|
-
Why should you care about this kind of complexity? More complex code tends to attract bugs and to
|
9
|
+
Why should you care about this kind of complexity? More complex code tends to attract bugs and to
|
10
|
+
increase the friction around extending features or refactoring code.
|
8
11
|
|
9
|
-
Fukuzatsu was created by Coraline Ada Ehmke with invaluable assistance from Mike Ziwisky (mziwisky).
|
12
|
+
Fukuzatsu was created by Coraline Ada Ehmke with invaluable assistance from Mike Ziwisky (mziwisky).
|
13
|
+
It was inspired by Saikuro, written by Zev Blut.
|
10
14
|
|
11
15
|
## Installation
|
12
16
|
|
@@ -18,12 +22,12 @@ This installs the CLI tool.
|
|
18
22
|
|
19
23
|
## Usage
|
20
24
|
|
21
|
-
fuku
|
25
|
+
fuku check path/to/file/my_file.rb
|
22
26
|
|
23
|
-
fuku
|
27
|
+
fuku check path/to/file/my_file.rb -f html
|
24
28
|
# Writes to doc/fuzuzatsu/path/to_file/my_file.rb.htm
|
25
29
|
|
26
|
-
fuku
|
30
|
+
fuku check path/to/file/my_file.rb -f csv
|
27
31
|
# Writes to doc/fuzuzatsu/path/to_file/my_file.rb.csv
|
28
32
|
|
29
33
|
## Contributing
|
data/lib/fukuzatsu/analyzer.rb
CHANGED
@@ -24,23 +24,23 @@ class Analyzer
|
|
24
24
|
|
25
25
|
def extract_class_name
|
26
26
|
return self.class_name if self.class_name
|
27
|
-
|
28
|
-
return "?" unless child
|
29
|
-
name = child.loc.name
|
30
|
-
self.class_name = self.content[name.begin_pos..(name.end_pos - 1)]
|
27
|
+
find_class(parsed) || "?"
|
31
28
|
end
|
32
29
|
|
33
30
|
private
|
34
31
|
|
35
|
-
def
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
32
|
+
def text_at(start_pos, end_pos)
|
33
|
+
content[start_pos..end_pos - 1]
|
34
|
+
end
|
35
|
+
|
36
|
+
def find_class(node)
|
37
|
+
return unless node && node.respond_to?(:type)
|
38
|
+
concat = []
|
39
|
+
if node.type == :module || node.type == :class
|
40
|
+
concat << text_at(node.loc.name.begin_pos, node.loc.name.end_pos)
|
42
41
|
end
|
43
|
-
|
42
|
+
concat << node.children.map{|child| find_class(child)}.compact
|
43
|
+
concat.flatten.select(&:present?).join('::')
|
44
44
|
end
|
45
45
|
|
46
46
|
def extend_graph
|
@@ -25,6 +25,7 @@ module Formatters
|
|
25
25
|
header: header,
|
26
26
|
rows: rows,
|
27
27
|
class_name: file.class_name,
|
28
|
+
complexity: file.complexity,
|
28
29
|
path_to_file: file.path_to_file,
|
29
30
|
date: Time.now.strftime("%Y/%m/%d"),
|
30
31
|
time: Time.now.strftime("%l:%M %P")
|
@@ -59,4 +60,4 @@ module Formatters
|
|
59
60
|
|
60
61
|
end
|
61
62
|
|
62
|
-
end
|
63
|
+
end
|
@@ -10,20 +10,28 @@
|
|
10
10
|
|
11
11
|
%style{media: "screen", type: "text/css"}
|
12
12
|
body { background: #593232; color: #fff; font-family: arial, sans-serif; padding: 2em; }
|
13
|
-
table { border:
|
14
|
-
|
15
|
-
|
13
|
+
table { box-shadow: 0 5px 0 rgba(0,0,0,.8); background: #444; border-spacing: 0; border: 5px solid #000; border-radius: 25px; border-collapse: collapse; min-width: 50%; }
|
14
|
+
th.sorting_asc, th.sorting_desc { text-transform: uppercase !important; font-size: .8em !important; background-image: none !important; background: rgba(64, 41, 41, .5) !important;}
|
15
|
+
th.sorting { background-position: left !important; border-right: 1px solid #222; text-transform: uppercase !important; font-size: .8em !important}
|
16
|
+
tr.header th:first-child { border-radius: 6px 0 0 0; }
|
17
|
+
tr.header th:last-child { border-radius: 0 6px 0 0; }
|
18
|
+
tr.header th:only-child { border-radius: 6px 6px 0 0; }
|
19
|
+
tr.header { background-color: #222; }
|
16
20
|
tr.even { background: rgba(128, 128, 128, 0.5) !important;}
|
17
|
-
tr.odd { background: rgba(128, 128, 128, 0.25) !important
|
21
|
+
tr.odd { background: rgba(128, 128, 128, 0.25) !important}
|
18
22
|
tr.even:hover, tr.odd:hover { background: rgba(128, 128, 128, 0.75) !important;}
|
19
|
-
th { background: #000; text-align: left; padding: .5em;
|
23
|
+
th { background: #000; text-align: left; padding: .5em; }
|
20
24
|
td { text-align: left; padding: .5em; padding-left: 1.25em !important;}
|
21
25
|
td.center { text-align: center; }
|
26
|
+
td.sorting_1 { background: none !important; padding-left: 1.25em !important; }
|
22
27
|
tfoot { background: #000; border-top: 10px solid #000; font-family: courier; margin-top: 4em; font-size: .75em; }
|
23
28
|
a:link, a:visited { color: #aaa }
|
24
|
-
|
25
|
-
|
29
|
+
div.file_meta { float: left; height: 3em; width: 30%; }
|
30
|
+
h1 { color:#fff; font-size: 1.25em; margin-top: .25em; }
|
31
|
+
h2 { color:#fff; font-size: .75em; margin-top: -1em; }
|
32
|
+
h3 { color:#fff; font-size: 1em; float: right; margin-top: 1em; }
|
26
33
|
td.sorting_1 { background: none !important; padding-left: 1.25em !important; }
|
34
|
+
div.dataTables_filter { margin-bottom: 2em !important; }
|
27
35
|
div.dataTables_filter label { color: #fff; }
|
28
36
|
div.dataTables_paginate { display: none !important; }
|
29
37
|
div.dataTables_info { display: none !important; }
|
@@ -31,6 +39,11 @@
|
|
31
39
|
%body
|
32
40
|
%table{class: "output-table"}
|
33
41
|
%thead
|
42
|
+
%tr.header
|
43
|
+
%th{colspan: 4}
|
44
|
+
.file_meta
|
45
|
+
%h1
|
46
|
+
Project Overview
|
34
47
|
%tr
|
35
48
|
%th
|
36
49
|
File
|
@@ -11,48 +11,60 @@
|
|
11
11
|
|
12
12
|
%style{media: "screen", type: "text/css"}
|
13
13
|
body { background: #593232; color: #fff; font-family: arial, sans-serif; padding: 2em; }
|
14
|
-
table { border:
|
15
|
-
|
16
|
-
|
14
|
+
table { box-shadow: 0 5px 0 rgba(0,0,0,.8); background: #444; border-spacing: 0; border: 5px solid #000; border-radius: 25px; border-collapse: collapse; min-width: 50%; }
|
15
|
+
th.sorting_asc, th.sorting_desc { text-transform: uppercase !important; font-size: .8em !important; background-image: none !important; background: rgba(64, 41, 41, .5) !important;}
|
16
|
+
th.sorting { background-position: left !important; border-right: 1px solid #222; text-transform: uppercase !important; font-size: .8em !important}
|
17
|
+
tr.header th:first-child { border-radius: 6px 0 0 0; }
|
18
|
+
tr.header th:last-child { border-radius: 0 6px 0 0; }
|
19
|
+
tr.header th:only-child { border-radius: 6px 6px 0 0; }
|
20
|
+
tfoot tr { border-radius: 6px 6px 6px 6px; }
|
21
|
+
tr.header { background-color: #222; }
|
17
22
|
tr.even { background: rgba(128, 128, 128, 0.5) !important;}
|
18
23
|
tr.odd { background: rgba(128, 128, 128, 0.25) !important}
|
19
24
|
tr.even:hover, tr.odd:hover { background: rgba(128, 128, 128, 0.75) !important;}
|
20
|
-
th { background: #000; text-align: left; padding: .5em;
|
25
|
+
th { background: #000; text-align: left; padding: .5em;}
|
21
26
|
td { text-align: left; padding: .5em; padding-left: 1.25em !important;}
|
22
27
|
td.center { text-align: center; }
|
23
|
-
td.sorting_1 { background: none !important; padding-left: 1.25em !important; }
|
24
|
-
tfoot { background: #000;
|
28
|
+
td.sorting_1 { background: none !important; padding-left: 1.25em !important; text-transform: uppercase; font-size: .8em}
|
29
|
+
tfoot { background: #000; font-family: courier; margin-top: 4em; font-size: .75em; }
|
25
30
|
a:link, a:visited { color: #aaa }
|
26
|
-
|
27
|
-
|
31
|
+
div.file_meta { float: left; height: 3em; width: 30%; }
|
32
|
+
h1 { color:#fff; font-size: 1.25em; margin-top: .25em; }
|
33
|
+
h2 { color:#fff; font-size: .75em; margin-top: -1em; }
|
34
|
+
h3 { color:#fff; font-size: 1em; float: right; margin-top: 1em; }
|
28
35
|
div.dataTables_filter { display: none !important; }
|
29
36
|
div.dataTables_paginate { display: none !important; }
|
30
37
|
div.dataTables_info { display: none !important; }
|
31
38
|
|
32
39
|
%body
|
33
|
-
|
34
|
-
%
|
35
|
-
%
|
36
|
-
%
|
37
|
-
%
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
40
|
+
.container
|
41
|
+
%table{class: "output-table"}
|
42
|
+
%thead
|
43
|
+
%tr.header
|
44
|
+
%th{colspan: 3}
|
45
|
+
.file_meta
|
46
|
+
%h1
|
47
|
+
= class_name
|
48
|
+
%h2
|
49
|
+
= path_to_file
|
50
|
+
.file_meta_right
|
51
|
+
%h3
|
52
|
+
= "Overall Complexity: #{complexity}"
|
53
|
+
%tr
|
54
|
+
= header
|
55
|
+
%tbody
|
56
|
+
= rows
|
57
|
+
%tfoot
|
58
|
+
%tr
|
59
|
+
%td.center{colspan: 3}
|
60
|
+
%em
|
61
|
+
Analyzed on
|
62
|
+
= date
|
63
|
+
at
|
64
|
+
= time
|
65
|
+
by
|
66
|
+
%a{href: "https://gitlab.com/coraline/fukuzatsu", target: "_new"}
|
67
|
+
Fukuzatsu
|
56
68
|
:javascript
|
57
69
|
$(document).ready(function(){
|
58
70
|
$('.output-table').dataTable({
|
data/lib/fukuzatsu/version.rb
CHANGED
data/spec/analyzer_spec.rb
CHANGED
@@ -4,6 +4,37 @@ describe Analyzer do
|
|
4
4
|
|
5
5
|
let(:content_1) { File.read("spec/fixtures/program_1.rb") }
|
6
6
|
let(:content_2) { File.read("spec/fixtures/program_2.rb") }
|
7
|
+
let(:content_3) { File.read("spec/fixtures/eg_class.rb") }
|
8
|
+
let(:content_4) { File.read("spec/fixtures/eg_mod_class.rb") }
|
9
|
+
let(:content_5) { File.read("spec/fixtures/eg_module.rb") }
|
10
|
+
let(:content_6) { File.read("spec/fixtures/eg_mod_class_2.rb") }
|
11
|
+
|
12
|
+
context "#extract_class_name" do
|
13
|
+
|
14
|
+
context "from Class Foo" do
|
15
|
+
it "returns Foo" do
|
16
|
+
expect(Analyzer.new(content_3).extract_class_name).to eq("Foo")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "from Module::Class Foo" do
|
21
|
+
it "returns Foo::Bar" do
|
22
|
+
expect(Analyzer.new(content_4).extract_class_name).to eq("Foo::Bar")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "from Module; Class" do
|
27
|
+
it "returns Extracted::Thing" do
|
28
|
+
expect(Analyzer.new(content_6).extract_class_name).to eq("Extracted::Thing")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "from Module" do
|
33
|
+
it "returns Something" do
|
34
|
+
expect(Analyzer.new(content_5).extract_class_name).to eq("Something")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
7
38
|
|
8
39
|
context "program_1" do
|
9
40
|
|
@@ -25,4 +56,4 @@ describe Analyzer do
|
|
25
56
|
|
26
57
|
end
|
27
58
|
|
28
|
-
end
|
59
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fukuzatsu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bantik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ephemeral
|
@@ -153,6 +153,10 @@ files:
|
|
153
153
|
- lib/fukuzatsu/parsed_method.rb
|
154
154
|
- lib/fukuzatsu/version.rb
|
155
155
|
- spec/analyzer_spec.rb
|
156
|
+
- spec/fixtures/eg_class.rb
|
157
|
+
- spec/fixtures/eg_mod_class.rb
|
158
|
+
- spec/fixtures/eg_mod_class_2.rb
|
159
|
+
- spec/fixtures/eg_module.rb
|
156
160
|
- spec/fixtures/program_1.rb
|
157
161
|
- spec/fixtures/program_2.rb
|
158
162
|
- spec/fixtures/program_3.rb
|
@@ -184,6 +188,10 @@ specification_version: 4
|
|
184
188
|
summary: A simple code complexity analyzer.
|
185
189
|
test_files:
|
186
190
|
- spec/analyzer_spec.rb
|
191
|
+
- spec/fixtures/eg_class.rb
|
192
|
+
- spec/fixtures/eg_mod_class.rb
|
193
|
+
- spec/fixtures/eg_mod_class_2.rb
|
194
|
+
- spec/fixtures/eg_module.rb
|
187
195
|
- spec/fixtures/program_1.rb
|
188
196
|
- spec/fixtures/program_2.rb
|
189
197
|
- spec/fixtures/program_3.rb
|