metric_fu-roodi 2.2.2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/bin/metric_fu-roodi +2 -19
  3. data/bin/metric_fu-roodi-describe +2 -5
  4. data/lib/roodi.rb +6 -2
  5. data/lib/roodi/version.rb +1 -1
  6. metadata +13 -119
  7. data/.gitignore +0 -3
  8. data/.rspec +0 -2
  9. data/Gemfile +0 -6
  10. data/History.txt +0 -111
  11. data/Manifest.txt +0 -56
  12. data/README.txt +0 -98
  13. data/Rakefile +0 -31
  14. data/TODO.md +0 -3
  15. data/lib/roodi/checks.rb +0 -18
  16. data/lib/roodi/checks/abc_metric_method_check.rb +0 -79
  17. data/lib/roodi/checks/assignment_in_conditional_check.rb +0 -32
  18. data/lib/roodi/checks/case_missing_else_check.rb +0 -20
  19. data/lib/roodi/checks/check.rb +0 -76
  20. data/lib/roodi/checks/class_line_count_check.rb +0 -28
  21. data/lib/roodi/checks/class_name_check.rb +0 -31
  22. data/lib/roodi/checks/class_variable_check.rb +0 -24
  23. data/lib/roodi/checks/control_coupling_check.rb +0 -20
  24. data/lib/roodi/checks/cyclomatic_complexity_block_check.rb +0 -41
  25. data/lib/roodi/checks/cyclomatic_complexity_check.rb +0 -50
  26. data/lib/roodi/checks/cyclomatic_complexity_method_check.rb +0 -42
  27. data/lib/roodi/checks/empty_rescue_body_check.rb +0 -32
  28. data/lib/roodi/checks/for_loop_check.rb +0 -20
  29. data/lib/roodi/checks/line_count_check.rb +0 -28
  30. data/lib/roodi/checks/method_line_count_check.rb +0 -29
  31. data/lib/roodi/checks/method_name_check.rb +0 -31
  32. data/lib/roodi/checks/missing_foreign_key_index_check.rb +0 -99
  33. data/lib/roodi/checks/module_line_count_check.rb +0 -28
  34. data/lib/roodi/checks/module_name_check.rb +0 -31
  35. data/lib/roodi/checks/name_check.rb +0 -16
  36. data/lib/roodi/checks/npath_complexity_check.rb +0 -75
  37. data/lib/roodi/checks/npath_complexity_method_check.rb +0 -29
  38. data/lib/roodi/checks/parameter_number_check.rb +0 -34
  39. data/lib/roodi/core.rb +0 -1
  40. data/lib/roodi/core/checking_visitor.rb +0 -26
  41. data/lib/roodi/core/error.rb +0 -17
  42. data/lib/roodi/core/parser.rb +0 -48
  43. data/lib/roodi/core/runner.rb +0 -81
  44. data/lib/roodi/core/visitable_sexp.rb +0 -25
  45. data/lib/roodi_task.rb +0 -35
  46. data/roodi.gemspec +0 -26
  47. data/roodi.yml +0 -25
  48. data/spec/roodi/checks/abc_metric_method_check_spec.rb +0 -89
  49. data/spec/roodi/checks/assignment_in_conditional_check_spec.rb +0 -105
  50. data/spec/roodi/checks/case_missing_else_check_spec.rb +0 -32
  51. data/spec/roodi/checks/class_line_count_check_spec.rb +0 -39
  52. data/spec/roodi/checks/class_name_check_spec.rb +0 -39
  53. data/spec/roodi/checks/class_variable_check_spec.rb +0 -17
  54. data/spec/roodi/checks/control_coupling_check_spec.rb +0 -23
  55. data/spec/roodi/checks/cyclomatic_complexity_block_check_spec.rb +0 -67
  56. data/spec/roodi/checks/cyclomatic_complexity_method_check_spec.rb +0 -200
  57. data/spec/roodi/checks/empty_rescue_body_check_spec.rb +0 -154
  58. data/spec/roodi/checks/for_loop_check_spec.rb +0 -18
  59. data/spec/roodi/checks/method_line_count_check_spec.rb +0 -56
  60. data/spec/roodi/checks/method_name_check_spec.rb +0 -76
  61. data/spec/roodi/checks/missing_foreign_key_index_check_spec.rb +0 -33
  62. data/spec/roodi/checks/module_line_count_check_spec.rb +0 -39
  63. data/spec/roodi/checks/module_name_check_spec.rb +0 -27
  64. data/spec/roodi/checks/npath_complexity_method_check_spec.rb +0 -53
  65. data/spec/roodi/checks/parameter_number_check_spec.rb +0 -47
  66. data/spec/roodi/core/runner_spec.rb +0 -25
  67. data/spec/roodi/roodi.yml +0 -2
  68. data/spec/spec_helper.rb +0 -3
@@ -1,18 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
-
3
- describe Roodi::Checks::ForLoopCheck do
4
- before(:each) do
5
- @roodi = Roodi::Core::Runner.new(Roodi::Checks::ForLoopCheck.make)
6
- end
7
-
8
- it "should reject for loops" do
9
- content = <<-END
10
- for i in 1..2
11
- end
12
- END
13
- @roodi.check_content(content)
14
- errors = @roodi.errors
15
- errors.should_not be_empty
16
- errors[0].to_s.should eql("dummy-file.rb:1 - Don't use 'for' loops. Use Enumerable.each instead.")
17
- end
18
- end
@@ -1,56 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
-
3
- describe Roodi::Checks::MethodLineCountCheck do
4
- before(:each) do
5
- @roodi = Roodi::Core::Runner.new(Roodi::Checks::MethodLineCountCheck.make({'line_count' => 1}))
6
- end
7
-
8
- it "should accept methods with less lines than the threshold" do
9
- content = <<-END
10
- def zero_line_method
11
- end
12
- END
13
- @roodi.check_content(content)
14
- @roodi.errors.should be_empty
15
- end
16
-
17
- it "should accept methods with the same number of lines as the threshold" do
18
- content = <<-END
19
- def one_line_method
20
- 1
21
- end
22
- END
23
- @roodi.check_content(content)
24
- @roodi.errors.should be_empty
25
- end
26
-
27
- it "should reject methods with more lines than the threshold" do
28
- content = <<-END
29
- def two_line_method
30
- puts 1
31
- puts 2
32
- end
33
- END
34
- @roodi.check_content(content)
35
- errors = @roodi.errors
36
- errors.should_not be_empty
37
- errors[0].to_s.should eql("dummy-file.rb:1 - Method \"two_line_method\" has 2 lines. It should have 1 or less.")
38
- end
39
-
40
- it "should count only lines from the method" do
41
- content = <<-END
42
- def first_method
43
- puts 1
44
- end
45
-
46
- def second_method
47
- puts 1
48
- puts 2
49
- end
50
- END
51
- @roodi.check_content(content)
52
- errors = @roodi.errors
53
- errors.should_not be_empty
54
- errors[0].to_s.should eql("dummy-file.rb:5 - Method \"second_method\" has 2 lines. It should have 1 or less.")
55
- end
56
- end
@@ -1,76 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
-
3
- describe Roodi::Checks::MethodNameCheck do
4
- before(:each) do
5
- @roodi = Roodi::Core::Runner.new(Roodi::Checks::MethodNameCheck.make)
6
- end
7
-
8
- it "should accept method names with underscores" do
9
- content = <<-END
10
- def good_method_name
11
- end
12
- END
13
- @roodi.check_content(content)
14
- @roodi.errors.should be_empty
15
- end
16
-
17
- it "should accept method names with numbers" do
18
- content = <<-END
19
- def good_method_1_name
20
- end
21
- END
22
- @roodi.check_content(content)
23
- @roodi.errors.should be_empty
24
- end
25
-
26
- it "should accept method names ending a question mark" do
27
- content = <<-END
28
- def good_method_name?
29
- end
30
- END
31
- @roodi.check_content(content)
32
- @roodi.errors.should be_empty
33
- end
34
-
35
- it "should accept method names ending an exclamation mark" do
36
- content = <<-END
37
- def good_method_name!
38
- end
39
- END
40
- @roodi.check_content(content)
41
- @roodi.errors.should be_empty
42
- end
43
-
44
- it "should accept method names ending an equals sign" do
45
- content = <<-END
46
- def good_method_name=
47
- end
48
- END
49
- @roodi.check_content(content)
50
- @roodi.errors.should be_empty
51
- end
52
-
53
- describe "when processing non-text based method names" do
54
- ['<<', '>>', '==', '=', '<', '<=', '>', '>=', '[]', '[]='].each do |each|
55
- it "should accept #{each} as a method name" do
56
- content = <<-END
57
- def #{each}
58
- end
59
- END
60
- @roodi.check_content(content)
61
- @roodi.errors.should be_empty
62
- end
63
- end
64
- end
65
-
66
- it "should reject camel case method names" do
67
- content = <<-END
68
- def badMethodName
69
- end
70
- END
71
- @roodi.check_content(content)
72
- errors = @roodi.errors
73
- errors.should_not be_empty
74
- errors[0].to_s.should eql("dummy-file.rb:1 - Method name \"badMethodName\" should match pattern /^[_a-z<>=\\[|+-\\/\\*`]+[_a-z0-9_<>=~@\\[\\]]*[=!\\?]?$/")
75
- end
76
- end
@@ -1,33 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
-
3
- describe Roodi::Checks::MissingForeignKeyIndexCheck do
4
- before(:each) do
5
- @roodi = Roodi::Core::Runner.new(Roodi::Checks::MissingForeignKeyIndexCheck.make)
6
- end
7
-
8
- it "should warn about a missing foreign key" do
9
- content = <<-END
10
- ActiveRecord::Schema.define(:version => 20091215233604) do
11
- create_table "projects", :force => true do |t|
12
- t.string "name"
13
- end
14
-
15
- create_table "revisions", :force => true do |t|
16
- t.integer "project_id"
17
- t.string "key"
18
- end
19
-
20
- add_index "revisions", ["project_id"], :name => "index_revisions_on_project_id"
21
-
22
- create_table "source_files", :force => true do |t|
23
- t.integer "revision_id"
24
- t.string "filename"
25
- end
26
- end
27
- END
28
- @roodi.check_content(content, "schema.rb")
29
- errors = @roodi.errors
30
- errors.should_not be_empty
31
- errors[0].to_s.should eql("schema.rb:1 - Table 'source_files' is missing an index on the foreign key 'revision_id'")
32
- end
33
- end
@@ -1,39 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
-
3
- describe Roodi::Checks::ModuleLineCountCheck do
4
- before(:each) do
5
- @roodi = Roodi::Core::Runner.new(Roodi::Checks::ModuleLineCountCheck.make({'line_count' => 1}))
6
- end
7
-
8
- it "should accept modules with less lines than the threshold" do
9
- content = <<-END
10
- module ZeroLineModule
11
- end
12
- END
13
- @roodi.check_content(content)
14
- @roodi.errors.should be_empty
15
- end
16
-
17
- it "should accept modules with the same number of lines as the threshold" do
18
- content = <<-END
19
- module OneLineModule
20
- @foo = 1
21
- end
22
- END
23
- @roodi.check_content(content)
24
- @roodi.errors.should be_empty
25
- end
26
-
27
- it "should reject modules with more lines than the threshold" do
28
- content = <<-END
29
- module TwoLineModule
30
- @foo = 1
31
- @bar = 2
32
- end
33
- END
34
- @roodi.check_content(content)
35
- errors = @roodi.errors
36
- errors.should_not be_empty
37
- errors[0].to_s.should eql("dummy-file.rb:1 - Module \"TwoLineModule\" has 2 lines. It should have 1 or less.")
38
- end
39
- end
@@ -1,27 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
-
3
- describe Roodi::Checks::ModuleNameCheck do
4
- before(:each) do
5
- @roodi = Roodi::Core::Runner.new(Roodi::Checks::ModuleNameCheck.make)
6
- end
7
-
8
- it "should accept camel case module names starting in capitals" do
9
- content = <<-END
10
- module GoodModuleName
11
- end
12
- END
13
- @roodi.check_content(content)
14
- @roodi.errors.should be_empty
15
- end
16
-
17
- it "should reject module names with underscores" do
18
- content = <<-END
19
- module Bad_ModuleName
20
- end
21
- END
22
- @roodi.check_content(content)
23
- errors = @roodi.errors
24
- errors.should_not be_empty
25
- errors[0].to_s.should eql("dummy-file.rb:1 - Module name \"Bad_ModuleName\" should match pattern /^[A-Z][a-zA-Z0-9]*$/")
26
- end
27
- end
@@ -1,53 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
-
3
- describe Roodi::Checks::NpathComplexityMethodCheck do
4
- before(:each) do
5
- @roodi = Roodi::Core::Runner.new(Roodi::Checks::NpathComplexityMethodCheck.make({'complexity' => 0}))
6
- end
7
-
8
- def verify_content_complexity(content, complexity)
9
- @roodi.check_content(content)
10
- errors = @roodi.errors
11
- errors.should_not be_empty
12
- errors[0].to_s.should eql("dummy-file.rb:1 - Method name \"method_name\" n-path complexity is #{complexity}. It should be 0 or less.")
13
- end
14
-
15
- it "should default to 1" do
16
- content = <<-END
17
- def method_name
18
- end
19
- END
20
- verify_content_complexity(content, 1)
21
- end
22
-
23
- it "should find an if block" do
24
- content = <<-END
25
- def method_name
26
- call_foo if some_condition
27
- end
28
- END
29
- verify_content_complexity(content, 2)
30
- end
31
-
32
- it "should find nested if block" do
33
- pending "NPath Complexity implementation that can support 'else' blocks"
34
- content = <<-END
35
- def method_name
36
- if (value1)
37
- foo
38
- else
39
- bar
40
- end
41
- if (value2)
42
- bam
43
- else
44
- baz
45
- end
46
- if (value3)
47
- one
48
- end
49
- end
50
- END
51
- verify_content_complexity(content, 8)
52
- end
53
- end
@@ -1,47 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
-
3
- describe Roodi::Checks::ParameterNumberCheck do
4
- before(:each) do
5
- @roodi = Roodi::Core::Runner.new(Roodi::Checks::ParameterNumberCheck.make({'parameter_count' => 1}))
6
- end
7
-
8
- it "should accept methods with less lines than the threshold" do
9
- content = <<-END
10
- def zero_parameter_method
11
- end
12
- END
13
- @roodi.check_content(content)
14
- @roodi.errors.should be_empty
15
- end
16
-
17
- it "should accept methods with the same number of parameters as the threshold" do
18
- content = <<-END
19
- def one_parameter_method(first_parameter)
20
- end
21
- END
22
- @roodi.check_content(content)
23
- @roodi.errors.should be_empty
24
- end
25
-
26
- it "should reject methods with more parameters than the threshold" do
27
- content = <<-END
28
- def two_parameter_method(first_parameter, second_parameter)
29
- end
30
- END
31
- @roodi.check_content(content)
32
- errors = @roodi.errors
33
- errors.should_not be_empty
34
- errors[0].to_s.should eql("dummy-file.rb:1 - Method name \"two_parameter_method\" has 2 parameters. It should have 1 or less.")
35
- end
36
-
37
- it "should cope with default values on parameters" do
38
- content = <<-END
39
- def two_parameter_method(first_parameter = 1, second_parameter = 2)
40
- end
41
- END
42
- @roodi.check_content(content)
43
- errors = @roodi.errors
44
- errors.should_not be_empty
45
- errors[0].to_s.should eql("dummy-file.rb:1 - Method name \"two_parameter_method\" has 2 parameters. It should have 1 or less.")
46
- end
47
- end
@@ -1,25 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
-
3
- describe Roodi::Core::Runner do
4
-
5
- describe "given a custom config file" do
6
- before do
7
- @runner = Roodi::Core::Runner.new
8
- @runner.config= File.expand_path(File.dirname(__FILE__) + '/../roodi.yml')
9
- end
10
-
11
- it "uses check from it" do
12
- # @runner.check_file(File.expand_path(File.dirname(__FILE__) + '/../fixtures/test_class.rb'))
13
- content = <<-RUBY
14
- class TestClass
15
-
16
- def METHOD
17
-
18
- end
19
- end
20
- RUBY
21
- @runner.check_content(content)
22
- @runner.errors.should be_empty
23
- end
24
- end
25
- end
@@ -1,2 +0,0 @@
1
- MethodNameCheck:
2
- pattern: !ruby/regexp /^[A-Z]+$/
@@ -1,3 +0,0 @@
1
- $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
2
- require 'roodi'
3
- require 'rspec'