roodi 2.1.0 → 2.2.0
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.
- data/Gemfile +6 -0
- data/Gemfile.lock +22 -0
- data/History.txt +0 -6
- data/Manifest.txt +0 -4
- data/Rakefile +2 -9
- data/lib/roodi.rb +1 -4
- data/lib/roodi/checks/abc_metric_method_check.rb +4 -2
- data/lib/roodi/checks/assignment_in_conditional_check.rb +2 -4
- data/lib/roodi/checks/check.rb +15 -0
- data/lib/roodi/checks/class_line_count_check.rb +13 -3
- data/lib/roodi/checks/class_name_check.rb +13 -3
- data/lib/roodi/checks/cyclomatic_complexity_block_check.rb +5 -3
- data/lib/roodi/checks/cyclomatic_complexity_check.rb +5 -2
- data/lib/roodi/checks/cyclomatic_complexity_method_check.rb +5 -3
- data/lib/roodi/checks/line_count_check.rb +4 -11
- data/lib/roodi/checks/method_line_count_check.rb +13 -3
- data/lib/roodi/checks/method_name_check.rb +13 -3
- data/lib/roodi/checks/missing_foreign_key_index_check.rb +1 -0
- data/lib/roodi/checks/module_line_count_check.rb +13 -3
- data/lib/roodi/checks/module_name_check.rb +14 -4
- data/lib/roodi/checks/name_check.rb +3 -10
- data/lib/roodi/checks/npath_complexity_check.rb +2 -0
- data/lib/roodi/checks/npath_complexity_method_check.rb +4 -3
- data/lib/roodi/checks/parameter_number_check.rb +8 -4
- data/lib/roodi/core/runner.rb +6 -6
- data/lib/roodi/version.rb +3 -0
- data/roodi.gemspec +18 -0
- data/roodi.yml +24 -15
- data/spec/roodi/checks/abc_metric_method_check_spec.rb +1 -1
- data/spec/roodi/checks/assignment_in_conditional_check_spec.rb +1 -1
- data/spec/roodi/checks/case_missing_else_check_spec.rb +1 -1
- data/spec/roodi/checks/class_line_count_check_spec.rb +1 -1
- data/spec/roodi/checks/class_name_check_spec.rb +1 -1
- data/spec/roodi/checks/class_variable_check_spec.rb +1 -1
- data/spec/roodi/checks/control_coupling_check_spec.rb +1 -1
- data/spec/roodi/checks/cyclomatic_complexity_block_check_spec.rb +1 -1
- data/spec/roodi/checks/cyclomatic_complexity_method_check_spec.rb +1 -1
- data/spec/roodi/checks/empty_rescue_body_check_spec.rb +1 -1
- data/spec/roodi/checks/for_loop_check_spec.rb +1 -1
- data/spec/roodi/checks/method_line_count_check_spec.rb +1 -1
- data/spec/roodi/checks/method_name_check_spec.rb +1 -1
- data/spec/roodi/checks/missing_foreign_key_index_check_spec.rb +1 -1
- data/spec/roodi/checks/module_line_count_check_spec.rb +1 -1
- data/spec/roodi/checks/module_name_check_spec.rb +1 -1
- data/spec/roodi/checks/npath_complexity_method_check_spec.rb +1 -1
- data/spec/roodi/checks/parameter_number_check_spec.rb +1 -1
- data/spec/roodi/roodi.yml +2 -1
- metadata +61 -67
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
roodi (2.2.0)
|
5
|
+
ruby_parser (~> 2.3.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
rake (10.0.3)
|
11
|
+
rspec (1.3.2)
|
12
|
+
ruby_parser (2.3.0)
|
13
|
+
sexp_processor (~> 3.0)
|
14
|
+
sexp_processor (3.2.0)
|
15
|
+
|
16
|
+
PLATFORMS
|
17
|
+
ruby
|
18
|
+
|
19
|
+
DEPENDENCIES
|
20
|
+
rake
|
21
|
+
roodi!
|
22
|
+
rspec (~> 1.3.2)
|
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
@@ -22,7 +22,6 @@ lib/roodi/checks/for_loop_check.rb
|
|
22
22
|
lib/roodi/checks/line_count_check.rb
|
23
23
|
lib/roodi/checks/method_line_count_check.rb
|
24
24
|
lib/roodi/checks/method_name_check.rb
|
25
|
-
lib/roodi/checks/missing_foreign_key_index_check.rb
|
26
25
|
lib/roodi/checks/module_line_count_check.rb
|
27
26
|
lib/roodi/checks/module_name_check.rb
|
28
27
|
lib/roodi/checks/name_check.rb
|
@@ -50,11 +49,8 @@ spec/roodi/checks/empty_rescue_body_check_spec.rb
|
|
50
49
|
spec/roodi/checks/for_loop_check_spec.rb
|
51
50
|
spec/roodi/checks/method_line_count_check_spec.rb
|
52
51
|
spec/roodi/checks/method_name_check_spec.rb
|
53
|
-
spec/roodi/checks/missing_foreign_key_index_check_spec.rb
|
54
52
|
spec/roodi/checks/module_line_count_check_spec.rb
|
55
53
|
spec/roodi/checks/module_name_check_spec.rb
|
56
54
|
spec/roodi/checks/npath_complexity_method_check_spec.rb
|
57
55
|
spec/roodi/checks/parameter_number_check_spec.rb
|
58
|
-
spec/roodi/core/runner_spec.rb
|
59
|
-
spec/roodi/roodi.yml
|
60
56
|
spec/spec_helper.rb
|
data/Rakefile
CHANGED
@@ -1,16 +1,9 @@
|
|
1
|
-
$:.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'hoe'
|
5
1
|
require 'rake'
|
6
2
|
require 'spec/rake/spectask'
|
3
|
+
require 'bundler'
|
7
4
|
require 'roodi'
|
8
5
|
|
9
|
-
|
10
|
-
p.developer('Marty Andrews', 'marty@cogentconsulting.com.au')
|
11
|
-
p.extra_deps = ['ruby_parser']
|
12
|
-
p.remote_rdoc_dir = ''
|
13
|
-
end
|
6
|
+
Bundler::GemHelper.install_tasks
|
14
7
|
|
15
8
|
def roodi(ruby_files)
|
16
9
|
roodi = Roodi::Core::Runner.new
|
data/lib/roodi.rb
CHANGED
@@ -16,9 +16,11 @@ module Roodi
|
|
16
16
|
OPERATORS = [:*, :/, :%, :+, :<<, :>>, :&, :|, :^]
|
17
17
|
DEFAULT_SCORE = 10
|
18
18
|
|
19
|
-
|
19
|
+
attr_accessor :score
|
20
|
+
|
21
|
+
def initialize
|
20
22
|
super()
|
21
|
-
|
23
|
+
self.score = DEFAULT_SCORE
|
22
24
|
end
|
23
25
|
|
24
26
|
def interesting_nodes
|
@@ -7,10 +7,7 @@ module Roodi
|
|
7
7
|
# A conditional containing an assignment is likely to be a mistyped equality check. You
|
8
8
|
# should either fix the typo or factor out the assignment so that the code is clearer.
|
9
9
|
class AssignmentInConditionalCheck < Check
|
10
|
-
|
11
|
-
super()
|
12
|
-
end
|
13
|
-
|
10
|
+
|
14
11
|
def interesting_nodes
|
15
12
|
[:if, :while]
|
16
13
|
end
|
@@ -29,6 +26,7 @@ module Roodi
|
|
29
26
|
end
|
30
27
|
found_assignment
|
31
28
|
end
|
29
|
+
|
32
30
|
end
|
33
31
|
end
|
34
32
|
end
|
data/lib/roodi/checks/check.rb
CHANGED
@@ -3,8 +3,23 @@ require 'roodi/core/error'
|
|
3
3
|
module Roodi
|
4
4
|
module Checks
|
5
5
|
class Check
|
6
|
+
|
6
7
|
NODE_TYPES = [:defn, :module, :resbody, :lvar, :cvar, :class, :if, :while, :until, :for, :rescue, :case, :when, :and, :or]
|
7
8
|
|
9
|
+
class << self
|
10
|
+
|
11
|
+
def make(options = nil)
|
12
|
+
check = new
|
13
|
+
if options
|
14
|
+
options.each do |name, value|
|
15
|
+
check.send("#{name}=", value)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
check
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
8
23
|
def initialize
|
9
24
|
@errors = []
|
10
25
|
end
|
@@ -7,12 +7,22 @@ module Roodi
|
|
7
7
|
# A class getting too large is a code smell that indicates it might be taking on too many
|
8
8
|
# responsibilities. It should probably be refactored into multiple smaller classes.
|
9
9
|
class ClassLineCountCheck < LineCountCheck
|
10
|
+
|
10
11
|
DEFAULT_LINE_COUNT = 300
|
11
12
|
|
12
|
-
def initialize
|
13
|
-
|
14
|
-
|
13
|
+
def initialize
|
14
|
+
super()
|
15
|
+
self.line_count = DEFAULT_LINE_COUNT
|
16
|
+
end
|
17
|
+
|
18
|
+
def interesting_nodes
|
19
|
+
[:class]
|
15
20
|
end
|
21
|
+
|
22
|
+
def message_prefix
|
23
|
+
'Class'
|
24
|
+
end
|
25
|
+
|
16
26
|
end
|
17
27
|
end
|
18
28
|
end
|
@@ -6,16 +6,26 @@ module Roodi
|
|
6
6
|
#
|
7
7
|
# Keeping to a consistent naming convention makes your code easier to read.
|
8
8
|
class ClassNameCheck < NameCheck
|
9
|
+
|
9
10
|
DEFAULT_PATTERN = /^[A-Z][a-zA-Z0-9]*$/
|
10
11
|
|
11
|
-
def initialize
|
12
|
-
|
13
|
-
|
12
|
+
def initialize
|
13
|
+
super()
|
14
|
+
self.pattern = DEFAULT_PATTERN
|
14
15
|
end
|
15
16
|
|
17
|
+
def interesting_nodes
|
18
|
+
[:class]
|
19
|
+
end
|
20
|
+
|
21
|
+
def message_prefix
|
22
|
+
'Class'
|
23
|
+
end
|
24
|
+
|
16
25
|
def find_name(node)
|
17
26
|
node[1].class == Symbol ? node[1] : node[1].last
|
18
27
|
end
|
28
|
+
|
19
29
|
end
|
20
30
|
end
|
21
31
|
end
|
@@ -12,11 +12,12 @@ module Roodi
|
|
12
12
|
# Generally, for a block, 1-2 is considered good, 3-4 ok, 5-8 consider re-factoring, and 8+
|
13
13
|
# re-factor now!
|
14
14
|
class CyclomaticComplexityBlockCheck < CyclomaticComplexityCheck
|
15
|
+
|
15
16
|
DEFAULT_COMPLEXITY = 4
|
16
17
|
|
17
|
-
def initialize
|
18
|
-
|
19
|
-
|
18
|
+
def initialize
|
19
|
+
super()
|
20
|
+
self.complexity = DEFAULT_COMPLEXITY
|
20
21
|
end
|
21
22
|
|
22
23
|
def interesting_nodes
|
@@ -34,6 +35,7 @@ module Roodi
|
|
34
35
|
def evaluate_matching_end
|
35
36
|
add_error "Block cyclomatic complexity is #{@count}. It should be #{@complexity} or less." unless @count <= @complexity
|
36
37
|
end
|
38
|
+
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
@@ -3,11 +3,13 @@ require 'roodi/checks/check'
|
|
3
3
|
module Roodi
|
4
4
|
module Checks
|
5
5
|
class CyclomaticComplexityCheck < Check
|
6
|
+
|
6
7
|
COMPLEXITY_NODE_TYPES = [:if, :while, :until, :for, :rescue, :case, :when, :and, :or]
|
7
8
|
|
8
|
-
|
9
|
+
attr_accessor :complexity
|
10
|
+
|
11
|
+
def initialize
|
9
12
|
super()
|
10
|
-
@complexity = complexity
|
11
13
|
@count = 0
|
12
14
|
@counting = 0
|
13
15
|
end
|
@@ -42,6 +44,7 @@ module Roodi
|
|
42
44
|
def counting?
|
43
45
|
@counting > 0
|
44
46
|
end
|
47
|
+
|
45
48
|
end
|
46
49
|
end
|
47
50
|
end
|
@@ -12,11 +12,12 @@ module Roodi
|
|
12
12
|
# Generally, for a method, 1-4 is considered good, 5-8 ok, 9-10 consider re-factoring, and
|
13
13
|
# 11+ re-factor now!
|
14
14
|
class CyclomaticComplexityMethodCheck < CyclomaticComplexityCheck
|
15
|
+
|
15
16
|
DEFAULT_COMPLEXITY = 8
|
16
17
|
|
17
|
-
def initialize
|
18
|
-
|
19
|
-
|
18
|
+
def initialize
|
19
|
+
super()
|
20
|
+
self.complexity = DEFAULT_COMPLEXITY
|
20
21
|
end
|
21
22
|
|
22
23
|
def interesting_nodes
|
@@ -35,6 +36,7 @@ module Roodi
|
|
35
36
|
def evaluate_matching_end
|
36
37
|
add_error "Method name \"#{@method_name}\" cyclomatic complexity is #{@count}. It should be #{@complexity} or less." unless @count <= @complexity
|
37
38
|
end
|
39
|
+
|
38
40
|
end
|
39
41
|
end
|
40
42
|
end
|
@@ -3,20 +3,12 @@ require 'roodi/checks/check'
|
|
3
3
|
module Roodi
|
4
4
|
module Checks
|
5
5
|
class LineCountCheck < Check
|
6
|
-
|
7
|
-
|
8
|
-
@interesting_nodes = interesting_nodes
|
9
|
-
@line_count = line_count
|
10
|
-
@message_prefix = message_prefix
|
11
|
-
end
|
12
|
-
|
13
|
-
def interesting_nodes
|
14
|
-
@interesting_nodes
|
15
|
-
end
|
6
|
+
|
7
|
+
attr_accessor :line_count
|
16
8
|
|
17
9
|
def evaluate_start(node)
|
18
10
|
line_count = count_lines(node)
|
19
|
-
add_error "#{
|
11
|
+
add_error "#{message_prefix} \"#{node[1]}\" has #{line_count} lines. It should have #{@line_count} or less." unless line_count <= @line_count
|
20
12
|
end
|
21
13
|
|
22
14
|
protected
|
@@ -24,6 +16,7 @@ module Roodi
|
|
24
16
|
def count_lines(node)
|
25
17
|
node.last.line - node.line - 1
|
26
18
|
end
|
19
|
+
|
27
20
|
end
|
28
21
|
end
|
29
22
|
end
|
@@ -8,12 +8,22 @@ module Roodi
|
|
8
8
|
# thing and becoming hard to test. It should probably be refactored into multiple methods
|
9
9
|
# that each do a single thing well.
|
10
10
|
class MethodLineCountCheck < LineCountCheck
|
11
|
+
|
11
12
|
DEFAULT_LINE_COUNT = 20
|
12
13
|
|
13
|
-
def initialize
|
14
|
-
|
15
|
-
|
14
|
+
def initialize
|
15
|
+
super()
|
16
|
+
self.line_count = DEFAULT_LINE_COUNT
|
17
|
+
end
|
18
|
+
|
19
|
+
def interesting_nodes
|
20
|
+
[:defn]
|
16
21
|
end
|
22
|
+
|
23
|
+
def message_prefix
|
24
|
+
'Method'
|
25
|
+
end
|
26
|
+
|
17
27
|
end
|
18
28
|
end
|
19
29
|
end
|
@@ -6,16 +6,26 @@ module Roodi
|
|
6
6
|
#
|
7
7
|
# Keeping to a consistent nameing convention makes your code easier to read.
|
8
8
|
class MethodNameCheck < NameCheck
|
9
|
+
|
9
10
|
DEFAULT_PATTERN = /^[_a-z<>=\[|+-\/\*`]+[_a-z0-9_<>=~@\[\]]*[=!\?]?$/
|
10
11
|
|
11
|
-
def initialize
|
12
|
-
|
13
|
-
|
12
|
+
def initialize
|
13
|
+
super()
|
14
|
+
self.pattern = DEFAULT_PATTERN
|
14
15
|
end
|
15
16
|
|
17
|
+
def interesting_nodes
|
18
|
+
[:defn]
|
19
|
+
end
|
20
|
+
|
21
|
+
def message_prefix
|
22
|
+
'Method'
|
23
|
+
end
|
24
|
+
|
16
25
|
def find_name(node)
|
17
26
|
node[1]
|
18
27
|
end
|
28
|
+
|
19
29
|
end
|
20
30
|
end
|
21
31
|
end
|
@@ -7,12 +7,22 @@ module Roodi
|
|
7
7
|
# A module getting too large is a code smell that indicates it might be taking on too many
|
8
8
|
# responsibilities. It should probably be refactored into multiple smaller modules.
|
9
9
|
class ModuleLineCountCheck < LineCountCheck
|
10
|
+
|
10
11
|
DEFAULT_LINE_COUNT = 300
|
11
12
|
|
12
|
-
def initialize
|
13
|
-
|
14
|
-
|
13
|
+
def initialize
|
14
|
+
super()
|
15
|
+
self.line_count = DEFAULT_LINE_COUNT
|
16
|
+
end
|
17
|
+
|
18
|
+
def interesting_nodes
|
19
|
+
[:module]
|
15
20
|
end
|
21
|
+
|
22
|
+
def message_prefix
|
23
|
+
'Module'
|
24
|
+
end
|
25
|
+
|
16
26
|
end
|
17
27
|
end
|
18
28
|
end
|
@@ -6,16 +6,26 @@ module Roodi
|
|
6
6
|
#
|
7
7
|
# Keeping to a consistent nameing convention makes your code easier to read.
|
8
8
|
class ModuleNameCheck < NameCheck
|
9
|
+
|
9
10
|
DEFAULT_PATTERN = /^[A-Z][a-zA-Z0-9]*$/
|
10
11
|
|
11
|
-
def initialize
|
12
|
-
|
13
|
-
|
12
|
+
def initialize
|
13
|
+
super()
|
14
|
+
self.pattern = DEFAULT_PATTERN
|
14
15
|
end
|
15
|
-
|
16
|
+
|
17
|
+
def interesting_nodes
|
18
|
+
[:module]
|
19
|
+
end
|
20
|
+
|
21
|
+
def message_prefix
|
22
|
+
'Module'
|
23
|
+
end
|
24
|
+
|
16
25
|
def find_name(node)
|
17
26
|
node[1].class == Symbol ? node[1] : node[1].last
|
18
27
|
end
|
28
|
+
|
19
29
|
end
|
20
30
|
end
|
21
31
|
end
|
@@ -3,21 +3,14 @@ require 'roodi/checks/check'
|
|
3
3
|
module Roodi
|
4
4
|
module Checks
|
5
5
|
class NameCheck < Check
|
6
|
-
def initialize(interesting_nodes, pattern, message_prefix)
|
7
|
-
super()
|
8
|
-
@interesting_nodes = interesting_nodes
|
9
|
-
@pattern = pattern
|
10
|
-
@message_prefix = message_prefix
|
11
|
-
end
|
12
6
|
|
13
|
-
|
14
|
-
@interesting_nodes
|
15
|
-
end
|
7
|
+
attr_accessor :pattern
|
16
8
|
|
17
9
|
def evaluate_start(node)
|
18
10
|
name = find_name(node)
|
19
|
-
add_error "#{
|
11
|
+
add_error "#{message_prefix} name \"#{name}\" should match pattern #{@pattern.inspect}" unless name.to_s =~ @pattern
|
20
12
|
end
|
13
|
+
|
21
14
|
end
|
22
15
|
end
|
23
16
|
end
|
@@ -4,11 +4,11 @@ module Roodi
|
|
4
4
|
module Checks
|
5
5
|
# Checks Npath complexity of a method against a specified limit.
|
6
6
|
class NpathComplexityMethodCheck < NpathComplexityCheck
|
7
|
+
|
7
8
|
DEFAULT_COMPLEXITY = 8
|
8
9
|
|
9
|
-
def initialize
|
10
|
-
|
11
|
-
super(complexity)
|
10
|
+
def initialize
|
11
|
+
super(DEFAULT_COMPLEXITY)
|
12
12
|
end
|
13
13
|
|
14
14
|
def interesting_nodes
|
@@ -23,6 +23,7 @@ module Roodi
|
|
23
23
|
def evaluate_end_defn(node)
|
24
24
|
add_error "Method name \"#{@method_name}\" n-path complexity is #{@current_value}. It should be #{@complexity} or less." unless @current_value <= @complexity
|
25
25
|
end
|
26
|
+
|
26
27
|
end
|
27
28
|
end
|
28
29
|
end
|
@@ -8,11 +8,14 @@ module Roodi
|
|
8
8
|
# much, or that the parameters should be grouped into one or more objects of their own. It
|
9
9
|
# probably needs some refactoring.
|
10
10
|
class ParameterNumberCheck < Check
|
11
|
+
|
11
12
|
DEFAULT_PARAMETER_COUNT = 5
|
12
13
|
|
13
|
-
|
14
|
+
attr_accessor :parameter_count
|
15
|
+
|
16
|
+
def initialize
|
14
17
|
super()
|
15
|
-
|
18
|
+
self.parameter_count = DEFAULT_PARAMETER_COUNT
|
16
19
|
end
|
17
20
|
|
18
21
|
def interesting_nodes
|
@@ -22,9 +25,10 @@ module Roodi
|
|
22
25
|
def evaluate_start(node)
|
23
26
|
method_name = node[1]
|
24
27
|
arguments = node[2]
|
25
|
-
|
26
|
-
add_error "Method name \"#{method_name}\" has #{
|
28
|
+
actual_parameter_count = arguments.inject(-1) { |count, each| count = count + (each.class == Symbol ? 1 : 0) }
|
29
|
+
add_error "Method name \"#{method_name}\" has #{actual_parameter_count} parameters. It should have #{@parameter_count} or less." unless actual_parameter_count <= @parameter_count
|
27
30
|
end
|
31
|
+
|
28
32
|
end
|
29
33
|
end
|
30
34
|
end
|
data/lib/roodi/core/runner.rb
CHANGED
@@ -15,7 +15,6 @@ module Roodi
|
|
15
15
|
def initialize(*checks)
|
16
16
|
@config = DEFAULT_CONFIG
|
17
17
|
@checks = checks unless checks.empty?
|
18
|
-
@parser = Parser.new
|
19
18
|
end
|
20
19
|
|
21
20
|
def check(filename, content)
|
@@ -36,7 +35,7 @@ module Roodi
|
|
36
35
|
end
|
37
36
|
|
38
37
|
def print(filename, content)
|
39
|
-
node =
|
38
|
+
node = parse(content, filename)
|
40
39
|
puts "Line: #{node.line}"
|
41
40
|
pp node
|
42
41
|
end
|
@@ -59,7 +58,7 @@ module Roodi
|
|
59
58
|
|
60
59
|
def parse(filename, content)
|
61
60
|
begin
|
62
|
-
|
61
|
+
Parser.new.parse(content, filename)
|
63
62
|
rescue Exception => e
|
64
63
|
puts "#{filename} looks like it's not a valid Ruby file. Skipping..." if ENV["ROODI_DEBUG"]
|
65
64
|
nil
|
@@ -69,12 +68,13 @@ module Roodi
|
|
69
68
|
def load_checks
|
70
69
|
check_objects = []
|
71
70
|
checks = YAML.load_file @config
|
72
|
-
checks.each do |
|
73
|
-
|
74
|
-
check_objects << (
|
71
|
+
checks.each do |check_class_name, options|
|
72
|
+
check_class = Roodi::Checks.const_get(check_class_name)
|
73
|
+
check_objects << check_class.make(options || {})
|
75
74
|
end
|
76
75
|
check_objects
|
77
76
|
end
|
77
|
+
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
data/roodi.gemspec
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
$: << File.expand_path("../lib", __FILE__)
|
2
|
+
require "roodi/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
|
6
|
+
gem.name = "roodi"
|
7
|
+
gem.summary = "Roodi stands for Ruby Object Oriented Design Inferometer"
|
8
|
+
gem.description = "Roodi stands for Ruby Object Oriented Design Inferometer"
|
9
|
+
gem.homepage = "http://roodi.rubyforge.org"
|
10
|
+
gem.authors = ["Marty Andrews"]
|
11
|
+
gem.email = "marty@cogent.co"
|
12
|
+
gem.files = Dir['lib/**/*.rb'] + Dir['bin/*'] + Dir['[A-Za-z]*'] + Dir['spec/**/*']
|
13
|
+
gem.version = Roodi::VERSION.dup
|
14
|
+
gem.platform = Gem::Platform::RUBY
|
15
|
+
gem.add_runtime_dependency("ruby_parser", "~> 2.3.0")
|
16
|
+
gem.executables = ["roodi", "roodi-describe"]
|
17
|
+
|
18
|
+
end
|
data/roodi.yml
CHANGED
@@ -1,16 +1,25 @@
|
|
1
|
-
AssignmentInConditionalCheck:
|
2
|
-
CaseMissingElseCheck:
|
3
|
-
ClassLineCountCheck:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
1
|
+
AssignmentInConditionalCheck:
|
2
|
+
CaseMissingElseCheck:
|
3
|
+
ClassLineCountCheck:
|
4
|
+
line_count: 300
|
5
|
+
ClassNameCheck:
|
6
|
+
pattern: !ruby/regexp /^[A-Z][a-zA-Z0-9]*$/
|
7
|
+
ClassVariableCheck:
|
8
|
+
CyclomaticComplexityBlockCheck:
|
9
|
+
complexity: 4
|
10
|
+
CyclomaticComplexityMethodCheck:
|
11
|
+
complexity: 8
|
12
|
+
EmptyRescueBodyCheck:
|
13
|
+
ForLoopCheck:
|
14
|
+
MethodLineCountCheck:
|
15
|
+
line_count: 20
|
16
|
+
MethodNameCheck:
|
17
|
+
pattern: !ruby/regexp /^[_a-z<>=\[|+-\/\*`]+[_a-z0-9_<>=~@\[\]]*[=!\?]?$/
|
18
|
+
# MissingForeignKeyIndexCheck:
|
19
|
+
ModuleLineCountCheck:
|
20
|
+
line_count: 300
|
21
|
+
ModuleNameCheck:
|
22
|
+
pattern: !ruby/regexp /^[A-Z][a-zA-Z0-9]*$/
|
23
|
+
ParameterNumberCheck:
|
24
|
+
parameter_count: 5
|
16
25
|
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
2
2
|
|
3
3
|
describe Roodi::Checks::AbcMetricMethodCheck do
|
4
4
|
before(:each) do
|
5
|
-
@roodi = Roodi::Core::Runner.new(Roodi::Checks::AbcMetricMethodCheck.
|
5
|
+
@roodi = Roodi::Core::Runner.new(Roodi::Checks::AbcMetricMethodCheck.make({'score' => 0}))
|
6
6
|
end
|
7
7
|
|
8
8
|
def verify_content_score(content, a, b, c)
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
2
2
|
|
3
3
|
describe Roodi::Checks::AssignmentInConditionalCheck do
|
4
4
|
before(:each) do
|
5
|
-
@roodi = Roodi::Core::Runner.new(Roodi::Checks::AssignmentInConditionalCheck.
|
5
|
+
@roodi = Roodi::Core::Runner.new(Roodi::Checks::AssignmentInConditionalCheck.make)
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should accept an assignment before an if clause" do
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
2
2
|
|
3
3
|
describe Roodi::Checks::CaseMissingElseCheck do
|
4
4
|
before(:each) do
|
5
|
-
@roodi = Roodi::Core::Runner.new(Roodi::Checks::CaseMissingElseCheck.
|
5
|
+
@roodi = Roodi::Core::Runner.new(Roodi::Checks::CaseMissingElseCheck.make)
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should accept case statements that do have an else" do
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
2
2
|
|
3
3
|
describe Roodi::Checks::ClassLineCountCheck do
|
4
4
|
before(:each) do
|
5
|
-
@roodi = Roodi::Core::Runner.new(Roodi::Checks::ClassLineCountCheck.
|
5
|
+
@roodi = Roodi::Core::Runner.new(Roodi::Checks::ClassLineCountCheck.make({'line_count' => 1}))
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should accept classes with less lines than the threshold" do
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
2
2
|
|
3
3
|
describe Roodi::Checks::ClassNameCheck do
|
4
4
|
before(:each) do
|
5
|
-
@roodi = Roodi::Core::Runner.new(Roodi::Checks::ClassNameCheck.
|
5
|
+
@roodi = Roodi::Core::Runner.new(Roodi::Checks::ClassNameCheck.make)
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should accept camel case class names starting in capitals" do
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
2
2
|
|
3
3
|
describe Roodi::Checks::ClassVariableCheck do
|
4
4
|
before(:each) do
|
5
|
-
@roodi = Roodi::Core::Runner.new(Roodi::Checks::ClassVariableCheck.
|
5
|
+
@roodi = Roodi::Core::Runner.new(Roodi::Checks::ClassVariableCheck.make)
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should reject class variables" do
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
2
2
|
|
3
3
|
describe Roodi::Checks::ControlCouplingCheck do
|
4
4
|
before(:each) do
|
5
|
-
@roodi = Roodi::Core::Runner.new(Roodi::Checks::ControlCouplingCheck.
|
5
|
+
@roodi = Roodi::Core::Runner.new(Roodi::Checks::ControlCouplingCheck.make)
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should reject methods with if checks using a parameter" do
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
2
2
|
|
3
3
|
describe Roodi::Checks::CyclomaticComplexityBlockCheck do
|
4
4
|
before(:each) do
|
5
|
-
@roodi = Roodi::Core::Runner.new(Roodi::Checks::CyclomaticComplexityBlockCheck.
|
5
|
+
@roodi = Roodi::Core::Runner.new(Roodi::Checks::CyclomaticComplexityBlockCheck.make({'complexity' => 0}))
|
6
6
|
end
|
7
7
|
|
8
8
|
def verify_content_complexity(content, complexity)
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
2
2
|
|
3
3
|
describe Roodi::Checks::CyclomaticComplexityMethodCheck do
|
4
4
|
before(:each) do
|
5
|
-
@roodi = Roodi::Core::Runner.new(Roodi::Checks::CyclomaticComplexityMethodCheck.
|
5
|
+
@roodi = Roodi::Core::Runner.new(Roodi::Checks::CyclomaticComplexityMethodCheck.make({'complexity' => 0}))
|
6
6
|
end
|
7
7
|
|
8
8
|
def verify_content_complexity(content, complexity)
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
2
2
|
|
3
3
|
describe Roodi::Checks::EmptyRescueBodyCheck do
|
4
4
|
before(:each) do
|
5
|
-
@roodi = Roodi::Core::Runner.new(Roodi::Checks::EmptyRescueBodyCheck.
|
5
|
+
@roodi = Roodi::Core::Runner.new(Roodi::Checks::EmptyRescueBodyCheck.make)
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should accept a rescue body with content and no parameter" do
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
2
2
|
|
3
3
|
describe Roodi::Checks::ForLoopCheck do
|
4
4
|
before(:each) do
|
5
|
-
@roodi = Roodi::Core::Runner.new(Roodi::Checks::ForLoopCheck.
|
5
|
+
@roodi = Roodi::Core::Runner.new(Roodi::Checks::ForLoopCheck.make)
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should reject for loops" do
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
2
2
|
|
3
3
|
describe Roodi::Checks::MethodLineCountCheck do
|
4
4
|
before(:each) do
|
5
|
-
@roodi = Roodi::Core::Runner.new(Roodi::Checks::MethodLineCountCheck.
|
5
|
+
@roodi = Roodi::Core::Runner.new(Roodi::Checks::MethodLineCountCheck.make({'line_count' => 1}))
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should accept methods with less lines than the threshold" do
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
2
2
|
|
3
3
|
describe Roodi::Checks::MethodNameCheck do
|
4
4
|
before(:each) do
|
5
|
-
@roodi = Roodi::Core::Runner.new(Roodi::Checks::MethodNameCheck.
|
5
|
+
@roodi = Roodi::Core::Runner.new(Roodi::Checks::MethodNameCheck.make)
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should accept method names with underscores" do
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
2
2
|
|
3
3
|
describe Roodi::Checks::MissingForeignKeyIndexCheck do
|
4
4
|
before(:each) do
|
5
|
-
@roodi = Roodi::Core::Runner.new(Roodi::Checks::MissingForeignKeyIndexCheck.
|
5
|
+
@roodi = Roodi::Core::Runner.new(Roodi::Checks::MissingForeignKeyIndexCheck.make)
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should warn about a missing foreign key" do
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
2
2
|
|
3
3
|
describe Roodi::Checks::ModuleLineCountCheck do
|
4
4
|
before(:each) do
|
5
|
-
@roodi = Roodi::Core::Runner.new(Roodi::Checks::ModuleLineCountCheck.
|
5
|
+
@roodi = Roodi::Core::Runner.new(Roodi::Checks::ModuleLineCountCheck.make({'line_count' => 1}))
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should accept modules with less lines than the threshold" do
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
2
2
|
|
3
3
|
describe Roodi::Checks::ModuleNameCheck do
|
4
4
|
before(:each) do
|
5
|
-
@roodi = Roodi::Core::Runner.new(Roodi::Checks::ModuleNameCheck.
|
5
|
+
@roodi = Roodi::Core::Runner.new(Roodi::Checks::ModuleNameCheck.make)
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should accept camel case module names starting in capitals" do
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
2
2
|
|
3
3
|
describe Roodi::Checks::NpathComplexityMethodCheck do
|
4
4
|
before(:each) do
|
5
|
-
@roodi = Roodi::Core::Runner.new(Roodi::Checks::NpathComplexityMethodCheck.
|
5
|
+
@roodi = Roodi::Core::Runner.new(Roodi::Checks::NpathComplexityMethodCheck.make({'complexity' => 0}))
|
6
6
|
end
|
7
7
|
|
8
8
|
def verify_content_complexity(content, complexity)
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
2
2
|
|
3
3
|
describe Roodi::Checks::ParameterNumberCheck do
|
4
4
|
before(:each) do
|
5
|
-
@roodi = Roodi::Core::Runner.new(Roodi::Checks::ParameterNumberCheck.
|
5
|
+
@roodi = Roodi::Core::Runner.new(Roodi::Checks::ParameterNumberCheck.make({'parameter_count' => 1}))
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should accept methods with less lines than the threshold" do
|
data/spec/roodi/roodi.yml
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
MethodNameCheck:
|
1
|
+
MethodNameCheck:
|
2
|
+
pattern: !ruby/regexp /^[A-Z]+$/
|
metadata
CHANGED
@@ -1,58 +1,40 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: roodi
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.2.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
|
-
authors:
|
7
|
+
authors:
|
7
8
|
- Marty Andrews
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-01-25 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: ruby_parser
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.3.0
|
17
22
|
type: :runtime
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
version_requirement:
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 2.3.3
|
34
|
-
version:
|
35
|
-
description: Roodi stands for Ruby Object Oriented Design Inferometer. It parses your Ruby code and warns you about design issues you have based on the checks that is has configured.
|
36
|
-
email:
|
37
|
-
- marty@cogentconsulting.com.au
|
38
|
-
executables:
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.3.0
|
30
|
+
description: Roodi stands for Ruby Object Oriented Design Inferometer
|
31
|
+
email: marty@cogent.co
|
32
|
+
executables:
|
39
33
|
- roodi
|
40
34
|
- roodi-describe
|
41
35
|
extensions: []
|
42
|
-
|
43
|
-
|
44
|
-
- History.txt
|
45
|
-
- Manifest.txt
|
46
|
-
- README.txt
|
47
|
-
files:
|
48
|
-
- History.txt
|
49
|
-
- Manifest.txt
|
50
|
-
- README.txt
|
51
|
-
- Rakefile
|
52
|
-
- bin/roodi
|
53
|
-
- bin/roodi-describe
|
54
|
-
- lib/roodi.rb
|
55
|
-
- lib/roodi/checks.rb
|
36
|
+
extra_rdoc_files: []
|
37
|
+
files:
|
56
38
|
- lib/roodi/checks/abc_metric_method_check.rb
|
57
39
|
- lib/roodi/checks/assignment_in_conditional_check.rb
|
58
40
|
- lib/roodi/checks/case_missing_else_check.rb
|
@@ -76,13 +58,25 @@ files:
|
|
76
58
|
- lib/roodi/checks/npath_complexity_check.rb
|
77
59
|
- lib/roodi/checks/npath_complexity_method_check.rb
|
78
60
|
- lib/roodi/checks/parameter_number_check.rb
|
79
|
-
- lib/roodi/
|
61
|
+
- lib/roodi/checks.rb
|
80
62
|
- lib/roodi/core/checking_visitor.rb
|
81
63
|
- lib/roodi/core/error.rb
|
82
64
|
- lib/roodi/core/parser.rb
|
83
65
|
- lib/roodi/core/runner.rb
|
84
66
|
- lib/roodi/core/visitable_sexp.rb
|
67
|
+
- lib/roodi/core.rb
|
68
|
+
- lib/roodi/version.rb
|
69
|
+
- lib/roodi.rb
|
85
70
|
- lib/roodi_task.rb
|
71
|
+
- bin/roodi
|
72
|
+
- bin/roodi-describe
|
73
|
+
- Gemfile
|
74
|
+
- Gemfile.lock
|
75
|
+
- History.txt
|
76
|
+
- Manifest.txt
|
77
|
+
- Rakefile
|
78
|
+
- README.txt
|
79
|
+
- roodi.gemspec
|
86
80
|
- roodi.yml
|
87
81
|
- spec/roodi/checks/abc_metric_method_check_spec.rb
|
88
82
|
- spec/roodi/checks/assignment_in_conditional_check_spec.rb
|
@@ -105,34 +99,34 @@ files:
|
|
105
99
|
- spec/roodi/core/runner_spec.rb
|
106
100
|
- spec/roodi/roodi.yml
|
107
101
|
- spec/spec_helper.rb
|
108
|
-
has_rdoc: true
|
109
102
|
homepage: http://roodi.rubyforge.org
|
110
103
|
licenses: []
|
111
|
-
|
112
104
|
post_install_message:
|
113
|
-
rdoc_options:
|
114
|
-
|
115
|
-
- README.txt
|
116
|
-
require_paths:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
117
107
|
- lib
|
118
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
110
|
+
requirements:
|
111
|
+
- - ! '>='
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
segments:
|
115
|
+
- 0
|
116
|
+
hash: -2141010416866692951
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - ! '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
segments:
|
124
|
+
- 0
|
125
|
+
hash: -2141010416866692951
|
130
126
|
requirements: []
|
131
|
-
|
132
|
-
|
133
|
-
rubygems_version: 1.3.5
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 1.8.24
|
134
129
|
signing_key:
|
135
130
|
specification_version: 3
|
136
131
|
summary: Roodi stands for Ruby Object Oriented Design Inferometer
|
137
132
|
test_files: []
|
138
|
-
|