reek 0.3.1 → 1.0.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.
Files changed (96) hide show
  1. data/History.txt +20 -0
  2. data/README.txt +4 -80
  3. data/Rakefile +15 -4
  4. data/bin/reek +10 -16
  5. data/config/defaults.reek +53 -0
  6. data/lib/reek.rb +1 -21
  7. data/lib/reek/block_context.rb +37 -0
  8. data/lib/reek/class_context.rb +73 -0
  9. data/lib/reek/code_context.rb +47 -0
  10. data/lib/reek/code_parser.rb +204 -0
  11. data/lib/reek/exceptions.reek +13 -0
  12. data/lib/reek/if_context.rb +25 -0
  13. data/lib/reek/method_context.rb +85 -0
  14. data/lib/reek/module_context.rb +34 -0
  15. data/lib/reek/name.rb +42 -0
  16. data/lib/reek/object_refs.rb +3 -6
  17. data/lib/reek/options.rb +60 -40
  18. data/lib/reek/rake_task.rb +20 -29
  19. data/lib/reek/report.rb +16 -27
  20. data/lib/reek/sexp_formatter.rb +52 -0
  21. data/lib/reek/singleton_method_context.rb +27 -0
  22. data/lib/reek/smell_warning.rb +49 -0
  23. data/lib/reek/smells/control_couple.rb +21 -13
  24. data/lib/reek/smells/duplication.rb +23 -27
  25. data/lib/reek/smells/feature_envy.rb +18 -25
  26. data/lib/reek/smells/large_class.rb +32 -17
  27. data/lib/reek/smells/long_method.rb +24 -16
  28. data/lib/reek/smells/long_parameter_list.rb +25 -18
  29. data/lib/reek/smells/long_yield_list.rb +7 -9
  30. data/lib/reek/smells/nested_iterators.rb +13 -9
  31. data/lib/reek/smells/smell_detector.rb +66 -0
  32. data/lib/reek/smells/smells.rb +71 -10
  33. data/lib/reek/smells/uncommunicative_name.rb +49 -41
  34. data/lib/reek/smells/utility_function.rb +18 -18
  35. data/lib/reek/source.rb +116 -0
  36. data/lib/reek/spec.rb +146 -0
  37. data/lib/reek/stop_context.rb +62 -0
  38. data/lib/reek/yield_call_context.rb +14 -0
  39. data/reek.gemspec +42 -0
  40. data/spec/integration/reek_source_spec.rb +20 -0
  41. data/spec/{script_spec.rb → integration/script_spec.rb} +11 -24
  42. data/spec/reek/class_context_spec.rb +198 -0
  43. data/spec/reek/code_context_spec.rb +92 -0
  44. data/spec/reek/code_parser_spec.rb +44 -0
  45. data/spec/reek/config_spec.rb +42 -0
  46. data/spec/reek/if_context_spec.rb +17 -0
  47. data/spec/reek/method_context_spec.rb +52 -0
  48. data/spec/reek/module_context_spec.rb +38 -0
  49. data/spec/reek/options_spec.rb +2 -28
  50. data/spec/reek/report_spec.rb +6 -40
  51. data/spec/reek/sexp_formatter_spec.rb +31 -0
  52. data/spec/reek/singleton_method_context_spec.rb +17 -0
  53. data/spec/reek/smells/control_couple_spec.rb +10 -18
  54. data/spec/reek/smells/duplication_spec.rb +53 -32
  55. data/spec/reek/smells/feature_envy_spec.rb +87 -49
  56. data/spec/reek/smells/large_class_spec.rb +45 -4
  57. data/spec/reek/smells/long_method_spec.rb +25 -41
  58. data/spec/reek/smells/long_parameter_list_spec.rb +30 -76
  59. data/spec/reek/smells/nested_iterators_spec.rb +19 -29
  60. data/spec/reek/smells/smell_spec.rb +9 -18
  61. data/spec/reek/smells/uncommunicative_name_spec.rb +88 -53
  62. data/spec/reek/smells/utility_function_spec.rb +45 -44
  63. data/spec/samples/inline_spec.rb +40 -0
  64. data/spec/samples/optparse_spec.rb +100 -0
  65. data/spec/samples/redcloth_spec.rb +93 -0
  66. data/spec/spec_helper.rb +3 -1
  67. data/tasks/reek.rake +1 -10
  68. data/tasks/rspec.rake +16 -35
  69. metadata +43 -46
  70. data/lib/reek/checker.rb +0 -66
  71. data/lib/reek/class_checker.rb +0 -25
  72. data/lib/reek/file_checker.rb +0 -20
  73. data/lib/reek/method_checker.rb +0 -198
  74. data/lib/reek/printer.rb +0 -154
  75. data/lib/reek/smells/smell.rb +0 -56
  76. data/lib/reek/version.rb +0 -9
  77. data/setup.rb +0 -1585
  78. data/spec/integration_spec.rb +0 -30
  79. data/spec/reek/class_checker_spec.rb +0 -48
  80. data/spec/reek/method_checker_spec.rb +0 -67
  81. data/spec/reek/printer_spec.rb +0 -30
  82. data/spec/reek_source_spec.rb +0 -12
  83. data/spec/samples/inline.reek +0 -27
  84. data/spec/samples/optparse.reek +0 -79
  85. data/spec/samples/optparse/date.rb +0 -17
  86. data/spec/samples/optparse/shellwords.rb +0 -6
  87. data/spec/samples/optparse/time.rb +0 -10
  88. data/spec/samples/optparse/uri.rb +0 -6
  89. data/spec/samples/optparse/version.rb +0 -70
  90. data/spec/samples/redcloth.reek +0 -65
  91. data/tasks/samples.rake +0 -17
  92. data/website/index.html +0 -71
  93. data/website/index.txt +0 -40
  94. data/website/javascripts/rounded_corners_lite.inc.js +0 -285
  95. data/website/stylesheets/screen.css +0 -138
  96. data/website/template.rhtml +0 -48
@@ -1,30 +1,15 @@
1
1
  require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
2
 
3
- require 'reek/method_checker'
4
- require 'reek/report'
3
+ require 'reek/smells/utility_function'
5
4
 
6
5
  include Reek
6
+ include Reek::Smells
7
7
 
8
- describe MethodChecker, "(Utility Function)" do
8
+ describe UtilityFunction do
9
9
 
10
10
  before(:each) do
11
11
  @rpt = Report.new
12
- @cchk = MethodChecker.new(@rpt, 'Thing')
13
- end
14
-
15
- it 'should not report empty method' do
16
- @cchk.check_source('def simple(arga) end')
17
- @rpt.should be_empty
18
- end
19
-
20
- it 'should not report instance variable reference' do
21
- @cchk.check_source('def simple(arga) @yellow end')
22
- @rpt.should be_empty
23
- end
24
-
25
- it 'should not report vcall' do
26
- @cchk.check_source('def simple(arga) y end')
27
- @rpt.should be_empty
12
+ @cchk = CodeParser.new(@rpt, SmellConfig.new.smell_listeners)
28
13
  end
29
14
 
30
15
  it 'should not report attrset' do
@@ -35,36 +20,20 @@ describe MethodChecker, "(Utility Function)" do
35
20
  @rpt.should be_empty
36
21
  end
37
22
 
38
- it 'should not report references to self' do
39
- @cchk.check_source('def into; self; end')
40
- @rpt.should be_empty
41
- end
42
-
43
- it 'should count usages of self' do
44
- @cchk.check_source('def <=>(other) Options[:sort_order].compare(self, other) end')
45
- @rpt.should be_empty
23
+ it 'should count usages of self'do
24
+ 'def <=>(other) Options[:sort_order].compare(self, other) end'.should_not reek
46
25
  end
47
-
48
26
  it 'should count self reference within a dstr' do
49
- @cchk.check_source('def as(alias_name); "#{self} as #{alias_name}".to_sym; end')
50
- @rpt.should be_empty
27
+ 'def as(alias_name); "#{self} as #{alias_name}".to_sym; end'.should_not reek
51
28
  end
52
-
53
29
  it 'should count calls to self within a dstr' do
54
- source = 'def to_sql; "\'#{self.gsub(/\'/, "\'\'")}\'"; end'
55
- @cchk.check_source(source)
56
- @rpt.should be_empty
30
+ 'def to_sql; "\'#{self.gsub(/\'/, "\'\'")}\'"; end'.should_not reek
57
31
  end
58
-
59
32
  it 'should report simple parameter call' do
60
- @cchk.check_source('def simple(arga) arga.to_s end')
61
- @rpt.length.should == 1
62
- @rpt[0].should == UtilityFunction.new(@cchk, 1)
33
+ 'def simple(arga) arga.to_s end'.should reek_of(:UtilityFunction, /simple/)
63
34
  end
64
-
65
35
  it 'should report message chain' do
66
- @cchk.check_source('def simple(arga) arga.b.c end')
67
- @rpt.length.should == 1
36
+ 'def simple(arga) arga.b.c end'.should reek_of(:UtilityFunction, /simple/)
68
37
  end
69
38
 
70
39
  it 'should not report overriding methods' do
@@ -74,7 +43,7 @@ describe MethodChecker, "(Utility Function)" do
74
43
  class Son < Father
75
44
  def thing(ff); ff; end
76
45
  end
77
- ClassChecker.new(@rpt).check_object(Son)
46
+ @cchk.check_object(Son)
78
47
  @rpt.should be_empty
79
48
  end
80
49
 
@@ -89,7 +58,39 @@ class Cache
89
58
  end
90
59
  end
91
60
  EOS
92
- @cchk.check_source(source)
93
- @rpt.should be_empty
61
+ source.should_not reek
62
+ end
63
+
64
+ it 'should recognise a deep call' do
65
+ src = <<EOS
66
+ class Red
67
+ def deep(text)
68
+ text.each { |mod| atts = shelve(mod) }
69
+ end
70
+
71
+ def shelve(val)
72
+ @shelf << val
73
+ end
74
+ end
75
+ EOS
76
+ src.should_not reek
77
+ end
78
+ end
79
+
80
+ describe UtilityFunction, 'should only report a method containing a call' do
81
+ it 'should not report empty method' do
82
+ 'def simple(arga) end'.should_not reek
83
+ end
84
+ it 'should not report literal' do
85
+ 'def simple(arga) 3; end'.should_not reek
86
+ end
87
+ it 'should not report instance variable reference' do
88
+ 'def simple(arga) @yellow end'.should_not reek
89
+ end
90
+ it 'should not report vcall' do
91
+ 'def simple(arga) y end'.should_not reek
92
+ end
93
+ it 'should not report references to self' do
94
+ 'def into; self; end'.should_not reek
94
95
  end
95
96
  end
@@ -0,0 +1,40 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+ describe 'sample gem source code' do
4
+ it "reports the correct smells in inline.rb" do
5
+ ruby = File.new('spec/samples/inline.rb').to_source
6
+ ruby.should reek_of(:ControlCouple, /Inline::C#parse_signature/, /raw/)
7
+ ruby.should reek_of(:ControlCouple, /Module#inline/, /options/)
8
+ ruby.should reek_of(:Duplication, /Inline::C#build/, /\$\?\.==\(0\)/)
9
+ ruby.should reek_of(:Duplication, /Inline::C#build/, /Inline.directory/)
10
+ ruby.should reek_of(:Duplication, /Inline::C#build/, /io.puts/)
11
+ ruby.should reek_of(:Duplication, /Inline::C#build/, /io.puts\(#endif\)/)
12
+ ruby.should reek_of(:Duplication, /Inline::C#build/, /io.puts\(#ifdef __cplusplus\)/)
13
+ ruby.should reek_of(:Duplication, /Inline::C#crap_for_windoze/, /Config::CONFIG\[libdir\]/)
14
+ ruby.should reek_of(:Duplication, /Inline::C#generate/, /result.sub!\(\(\?-mix:\\A\\n\), \)/)
15
+ ruby.should reek_of(:Duplication, /Inline::C#generate/, /signature\[args\]/)
16
+ ruby.should reek_of(:Duplication, /Inline::C#generate/, /signature\[args\].map/)
17
+ ruby.should reek_of(:Duplication, /Inline::C#initialize/, /stack.empty?/)
18
+ ruby.should reek_of(:Duplication, /Inline::self.rootdir/, /env.nil?/)
19
+ ruby.should reek_of(:Duplication, /Module#inline/, /Inline.const_get\(lang\)/)
20
+ ruby.should reek_of(:FeatureEnvy, /Inline::C#strip_comments/, /src/)
21
+ ruby.should reek_of(:LargeClass, /Inline::C/)
22
+ ruby.should reek_of(:LongMethod, /File#self.write_with_backup/)
23
+ ruby.should reek_of(:LongMethod, /Inline::C#build/)
24
+ ruby.should reek_of(:LongMethod, /Inline::C#generate/)
25
+ ruby.should reek_of(:LongMethod, /Inline::C#load_cache/)
26
+ ruby.should reek_of(:LongMethod, /Inline::C#module_name/)
27
+ ruby.should reek_of(:LongMethod, /Inline::C#parse_signature/)
28
+ ruby.should reek_of(:LongMethod, /Inline::self.rootdir/)
29
+ ruby.should reek_of(:LongMethod, /Module#inline/)
30
+ ruby.should reek_of(:NestedIterators, /Inline::C#build/)
31
+ ruby.should reek_of(:UncommunicativeName, /Inline::C#build/, /'t'/)
32
+ ruby.should reek_of(:UncommunicativeName, /Inline::C#build/, /'n'/)
33
+ ruby.should reek_of(:UncommunicativeName, /Inline::C#c/, /'c'/)
34
+ ruby.should reek_of(:UncommunicativeName, /Inline::C#module_name/, /'m'/)
35
+ ruby.should reek_of(:UncommunicativeName, /Inline::C#module_name/, /'x'/)
36
+ ruby.should reek_of(:UncommunicativeName, /Inline::C#parse_signature/, /'x'/)
37
+ ruby.should reek_of(:UtilityFunction, /Inline::C#strip_comments/)
38
+ ruby.report.should have_at_most(32).smells
39
+ end
40
+ end
@@ -0,0 +1,100 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+ describe 'sample gem source code' do
4
+ it "reports the correct smells in optparse.rb" do
5
+ ruby = File.new('spec/samples/optparse.rb').to_source
6
+ ruby.should reek_of(:ControlCouple, /OptionParser#List#accept/, /pat/)
7
+ ruby.should reek_of(:ControlCouple, /OptionParser#List#update/, /lopts/)
8
+ ruby.should reek_of(:ControlCouple, /OptionParser#List#update/, /sopts/)
9
+ ruby.should reek_of(:ControlCouple, /OptionParser#ParseError#set_option/, /eq/)
10
+ ruby.should reek_of(:ControlCouple, /OptionParser#Switch#NoArgument#parse/, /arg/)
11
+ ruby.should reek_of(:ControlCouple, /OptionParser#Switch#OptionalArgument#parse/, /arg/)
12
+ ruby.should reek_of(:ControlCouple, /OptionParser#Switch#RequiredArgument#parse/, /arg/)
13
+ ruby.should reek_of(:ControlCouple, /OptionParser#parse_in_order/, /setter/)
14
+ ruby.should reek_of(:Duplication, /OptionParser#Completion::complete/, /candidates.size/)
15
+ ruby.should reek_of(:Duplication, /OptionParser#Completion::complete/, /k.id2name/)
16
+ ruby.should reek_of(:Duplication, /OptionParser#Switch#parse_arg/, /s.length/)
17
+ ruby.should reek_of(:Duplication, /OptionParser#Switch#summarize/, /block.max/)
18
+ ruby.should reek_of(:Duplication, /OptionParser#Switch#summarize/, /block.max.to_i/)
19
+ ruby.should reek_of(:Duplication, /OptionParser#Switch#summarize/, /indent.+\(l\)/)
20
+ ruby.should reek_of(:Duplication, /OptionParser#Switch#summarize/, /left.collect/)
21
+ ruby.should reek_of(:Duplication, /OptionParser#Switch#summarize/, /left.shift/)
22
+ ruby.should reek_of(:Duplication, /OptionParser#Switch#summarize/, /left\[-1\]/)
23
+ ruby.should reek_of(:Duplication, /OptionParser#Switch#summarize/, /s.length/)
24
+ ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /default_style.guess\(arg=a\)/)
25
+ ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /long.<<\(o=q.downcase\)/)
26
+ ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /pattern.method\(convert\)/)
27
+ ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /pattern.method\(convert\).to_proc/)
28
+ ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /pattern.respond_to\?\(convert\)/)
29
+ ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /q.downcase/)
30
+ ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /sdesc.<<\("-\#\{q\}"\)/)
31
+ ruby.should reek_of(:Duplication, /OptionParser#order/, /argv\[0\]/)
32
+ ruby.should reek_of(:Duplication, /OptionParser#parse/, /argv\[0\]/)
33
+ ruby.should reek_of(:Duplication, /OptionParser#parse_in_order/, /\$\!.set_option\(arg, true\)/)
34
+ ruby.should reek_of(:Duplication, /OptionParser#parse_in_order/, /cb.call\(val\)/)
35
+ ruby.should reek_of(:Duplication, /OptionParser#parse_in_order/, /setter.call\(sw.switch_name, val\)/)
36
+ ruby.should reek_of(:Duplication, /OptionParser#parse_in_order/, /sw.block/)
37
+ ruby.should reek_of(:Duplication, /OptionParser#parse_in_order/, /sw.switch_name/)
38
+ ruby.should reek_of(:Duplication, /OptionParser#permute/, /argv\[0\]/)
39
+ ruby.should reek_of(:FeatureEnvy, /OptionParser#Completion::complete/, /candidates/)
40
+ ruby.should reek_of(:FeatureEnvy, /OptionParser#List#accept/, /pat/)
41
+ ruby.should reek_of(:FeatureEnvy, /OptionParser#Switch#summarize/, /left/)
42
+ ruby.should reek_of(:FeatureEnvy, /OptionParser#order/, /argv/)
43
+ ruby.should reek_of(:FeatureEnvy, /OptionParser#parse/, /argv/)
44
+ ruby.should reek_of(:FeatureEnvy, /OptionParser#permute/, /argv/)
45
+ ruby.should reek_of(:LargeClass, /OptionParser/)
46
+ ruby.should reek_of(:LongMethod, /OptionParser#Completion::complete/)
47
+ ruby.should reek_of(:LongMethod, /OptionParser#List#update/)
48
+ ruby.should reek_of(:LongMethod, /OptionParser#Switch#PlacedArgument#parse/)
49
+ ruby.should reek_of(:LongMethod, /OptionParser#Switch#parse_arg/)
50
+ ruby.should reek_of(:LongMethod, /OptionParser#Switch#summarize/)
51
+ ruby.should reek_of(:LongMethod, /OptionParser#getopts/)
52
+ ruby.should reek_of(:LongMethod, /OptionParser#make_switch/)
53
+ ruby.should reek_of(:LongMethod, /OptionParser#parse_in_order/)
54
+ ruby.should reek_of(:LongParameterList, /OptionParser#List#complete/)
55
+ ruby.should reek_of(:LongParameterList, /OptionParser#List#update/)
56
+ ruby.should reek_of(:LongParameterList, /OptionParser#Switch#initialize/)
57
+ ruby.should reek_of(:LongParameterList, /OptionParser#Switch#summarize/)
58
+ ruby.should reek_of(:LongParameterList, /OptionParser#complete/)
59
+ ruby.should reek_of(:LongParameterList, /OptionParser#summarize/)
60
+ ruby.should reek_of(:NestedIterators, /OptionParser#CompletingHash#match/)
61
+ ruby.should reek_of(:NestedIterators, /OptionParser#Switch#summarize/)
62
+ ruby.should reek_of(:NestedIterators, /OptionParser#block/)
63
+ ruby.should reek_of(:NestedIterators, /OptionParser#complete/)
64
+ ruby.should reek_of(:NestedIterators, /OptionParser#make_switch/)
65
+ ruby.should reek_of(:NestedIterators, /OptionParser#make_switch/)
66
+ ruby.should reek_of(:NestedIterators, /OptionParser#parse_in_order/)
67
+ ruby.should reek_of(:NestedIterators, /OptionParser#parse_in_order/)
68
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#Completion::complete/, /'k'/)
69
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#Completion::complete/, /'v'/)
70
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#List#accept/, /'t'/)
71
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#List#reject/, /'t'/)
72
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#List#update/, /'o'/)
73
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#Switch#add_banner/, /'s'/)
74
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#Switch#parse_arg/, /'m'/)
75
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#Switch#parse_arg/, /'s'/)
76
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#Switch#self.guess/, /'t'/)
77
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#Switch#self.incompatible_argument_styles/, /'t'/)
78
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#Switch#summarize/, /'l'/)
79
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#Switch#summarize/, /'r'/)
80
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#Switch#summarize/, /'s'/)
81
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#block/, /'f'/)
82
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#block/, /'k'/)
83
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#block/, /'o'/)
84
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#block/, /'s'/)
85
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#block/, /'v'/)
86
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#load/, /'s'/)
87
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#make_switch/, /'a'/)
88
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#make_switch/, /'n'/)
89
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#make_switch/, /'o'/)
90
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#make_switch/, /'q'/)
91
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#make_switch/, /'s'/)
92
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#make_switch/, /'c'/)
93
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#make_switch/, /'v'/)
94
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#search/, /'k'/)
95
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#summarize/, /'l'/)
96
+ ruby.should reek_of(:UncommunicativeName, /OptionParser#ver/, /'v'/)
97
+ ruby.should reek_of(:UncommunicativeName, /block/, /'q'/)
98
+ ruby.report.should have_at_most(92).smells
99
+ end
100
+ end
@@ -0,0 +1,93 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+ describe 'sample gem source code' do
4
+ it "reports the correct smells in redcloth.rb" do
5
+ ruby = File.new('spec/samples/redcloth.rb').to_source
6
+ ruby.should reek_of(:ControlCouple, /RedCloth#blocks\/block/, /deep_code/)
7
+ ruby.should reek_of(:ControlCouple, /RedCloth#check_refs/, /text/)
8
+ ruby.should reek_of(:ControlCouple, /RedCloth#pba/, /text_in/)
9
+ ruby.should reek_of(:ControlCouple, /RedCloth#textile_bq/, /atts/)
10
+ ruby.should reek_of(:ControlCouple, /RedCloth#textile_bq/, /cite/)
11
+ ruby.should reek_of(:ControlCouple, /RedCloth#textile_fn_/, /atts/)
12
+ ruby.should reek_of(:ControlCouple, /RedCloth#textile_p/, /atts/)
13
+ ruby.should reek_of(:Duplication, /RedCloth#block_textile_lists/, /depth.last/)
14
+ ruby.should reek_of(:Duplication, /RedCloth#block_textile_lists/, /depth.last.length/)
15
+ ruby.should reek_of(:Duplication, /RedCloth#block_textile_lists/, /depth\[i\]/)
16
+ ruby.should reek_of(:Duplication, /RedCloth#block_textile_lists/, /line_id.-\(1\)/)
17
+ ruby.should reek_of(:Duplication, /RedCloth#block_textile_lists/, /lines\[line_id.-\(1\)\]/)
18
+ ruby.should reek_of(:Duplication, /RedCloth#block_textile_lists/, /tl.length/)
19
+ ruby.should reek_of(:Duplication, /RedCloth#clean_html/, /tags\[tag\]/)
20
+ ruby.should reek_of(:Duplication, /RedCloth#pba/, /\$1.length/)
21
+ ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /@pre_list.last/)
22
+ ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /@pre_list.last.<<\(line\)/)
23
+ ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /codepre.-\(used_offtags.length\)/)
24
+ ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /codepre.-\(used_offtags.length\).>\(0\)/)
25
+ ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /codepre.zero?/)
26
+ ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /used_offtags.length/)
27
+ ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /used_offtags\[notextile\]/)
28
+ ruby.should reek_of(:FeatureEnvy, /RedCloth#clean_html/, /tags/)
29
+ ruby.should reek_of(:FeatureEnvy, /RedCloth#clean_white_space/, /text/)
30
+ ruby.should reek_of(:FeatureEnvy, /RedCloth#flush_left/, /indt/)
31
+ ruby.should reek_of(:FeatureEnvy, /RedCloth#flush_left/, /text/)
32
+ ruby.should reek_of(:FeatureEnvy, /RedCloth#htmlesc/, /str/)
33
+ ruby.should reek_of(:FeatureEnvy, /RedCloth#no_textile/, /text/)
34
+ ruby.should reek_of(:FeatureEnvy, /RedCloth#pba/, /style/)
35
+ ruby.should reek_of(:FeatureEnvy, /RedCloth#pba/, /text/)
36
+ ruby.should reek_of(:LargeClass, /RedCloth/)
37
+ ruby.should reek_of(:LongMethod, /RedCloth#block_markdown_bq/)
38
+ ruby.should reek_of(:LongMethod, /RedCloth#block_textile_lists/)
39
+ ruby.should reek_of(:LongMethod, /RedCloth#block_textile_table/)
40
+ ruby.should reek_of(:LongMethod, /RedCloth#blocks/)
41
+ ruby.should reek_of(:LongMethod, /RedCloth#clean_html/)
42
+ ruby.should reek_of(:LongMethod, /RedCloth#clean_white_space/)
43
+ ruby.should reek_of(:LongMethod, /RedCloth#glyphs_textile/)
44
+ ruby.should reek_of(:LongMethod, /RedCloth#inline_markdown_link/)
45
+ ruby.should reek_of(:LongMethod, /RedCloth#inline_markdown_reflink/)
46
+ ruby.should reek_of(:LongMethod, /RedCloth#inline_textile_image/)
47
+ ruby.should reek_of(:LongMethod, /RedCloth#inline_textile_link/)
48
+ ruby.should reek_of(:LongMethod, /RedCloth#inline_textile_span/)
49
+ ruby.should reek_of(:LongMethod, /RedCloth#pba/)
50
+ ruby.should reek_of(:LongMethod, /RedCloth#rip_offtags/)
51
+ ruby.should reek_of(:LongMethod, /RedCloth#to_html/)
52
+ ruby.should reek_of(:LongParameterList, /RedCloth#textile_bq/)
53
+ ruby.should reek_of(:LongParameterList, /RedCloth#textile_fn_/)
54
+ ruby.should reek_of(:LongParameterList, /RedCloth#textile_p/)
55
+ ruby.should reek_of(:NestedIterators, /RedCloth#block_textile_lists/)
56
+ ruby.should reek_of(:NestedIterators, /RedCloth#block_textile_lists/)
57
+ ruby.should reek_of(:NestedIterators, /RedCloth#block_textile_table/)
58
+ ruby.should reek_of(:NestedIterators, /RedCloth#block_textile_table/)
59
+ ruby.should reek_of(:NestedIterators, /RedCloth#blocks/)
60
+ ruby.should reek_of(:NestedIterators, /RedCloth#clean_html/)
61
+ ruby.should reek_of(:NestedIterators, /RedCloth#clean_html/)
62
+ ruby.should reek_of(:NestedIterators, /RedCloth#inline/)
63
+ ruby.should reek_of(:NestedIterators, /RedCloth#inline_textile_span/)
64
+ ruby.should reek_of(:UncommunicativeName, /RedCloth#block/, /'a'/)
65
+ ruby.should reek_of(:UncommunicativeName, /RedCloth#block/, /'b'/)
66
+ ruby.should reek_of(:UncommunicativeName, /RedCloth#block_textile_lists/, /'i'/)
67
+ ruby.should reek_of(:UncommunicativeName, /RedCloth#block_textile_lists/, /'v'/)
68
+ ruby.should reek_of(:UncommunicativeName, /RedCloth#block_textile_table/, /'x'/)
69
+ ruby.should reek_of(:UncommunicativeName, /RedCloth#clean_html/, /'q'/)
70
+ ruby.should reek_of(:UncommunicativeName, /RedCloth#clean_html/, /'q2'/)
71
+ ruby.should reek_of(:UncommunicativeName, /RedCloth#initialize/, /'r'/)
72
+ ruby.should reek_of(:UncommunicativeName, /RedCloth#inline_markdown_link/, /'m'/)
73
+ ruby.should reek_of(:UncommunicativeName, /RedCloth#inline_markdown_reflink/, /'m'/)
74
+ ruby.should reek_of(:UncommunicativeName, /RedCloth#inline_textile_code/, /'m'/)
75
+ ruby.should reek_of(:UncommunicativeName, /RedCloth#inline_textile_image/, /'m'/)
76
+ ruby.should reek_of(:UncommunicativeName, /RedCloth#inline_textile_link/, /'m'/)
77
+ ruby.should reek_of(:UncommunicativeName, /RedCloth#inline_textile_span/, /'m'/)
78
+ ruby.should reek_of(:UncommunicativeName, /RedCloth#refs_markdown/, /'m'/)
79
+ ruby.should reek_of(:UncommunicativeName, /RedCloth#refs_textile/, /'m'/)
80
+ ruby.should reek_of(:UncommunicativeName, /RedCloth#retrieve/, /'i'/)
81
+ ruby.should reek_of(:UncommunicativeName, /RedCloth#retrieve/, /'r'/)
82
+ ruby.should reek_of(:UtilityFunction, /RedCloth#block_markdown_rule/)
83
+ ruby.should reek_of(:UtilityFunction, /RedCloth#clean_html/)
84
+ ruby.should reek_of(:UtilityFunction, /RedCloth#flush_left/)
85
+ ruby.should reek_of(:UtilityFunction, /RedCloth#footnote_ref/)
86
+ ruby.should reek_of(:UtilityFunction, /RedCloth#h_align/)
87
+ ruby.should reek_of(:UtilityFunction, /RedCloth#htmlesc/)
88
+ ruby.should reek_of(:UtilityFunction, /RedCloth#incoming_entities/)
89
+ ruby.should reek_of(:UtilityFunction, /RedCloth#no_textile/)
90
+ ruby.should reek_of(:UtilityFunction, /RedCloth#v_align/)
91
+ ruby.report.should have_at_most(85).smells
92
+ end
93
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ $:.unshift File.dirname(__FILE__) + '/../lib'
2
+
1
3
  begin
2
4
  require 'spec'
3
5
  rescue LoadError
@@ -6,4 +8,4 @@ rescue LoadError
6
8
  require 'spec'
7
9
  end
8
10
 
9
- $:.unshift File.dirname(__FILE__) + '/../lib'
11
+ require 'reek/spec'
data/tasks/reek.rake CHANGED
@@ -1,16 +1,7 @@
1
1
  require 'reek/rake_task'
2
- require 'flay'
3
2
 
4
3
  Reek::RakeTask.new do |t|
5
4
  t.fail_on_error = true
6
5
  t.verbose = false
7
- # t.sort = 'smell'
8
- end
9
-
10
- desc 'Check for code duplication'
11
- task 'flay' do
12
- files = FileList['lib/**/*.rb']
13
- flayer = Flay.new(16)
14
- flayer.process(*files)
15
- flayer.report
6
+ # t.reek_opts = '-f "Smell: %s: %c %w"'
16
7
  end
data/tasks/rspec.rake CHANGED
@@ -1,40 +1,21 @@
1
- require 'rake/clean'
1
+ require 'spec'
2
+ require 'spec/rake/spectask'
2
3
 
3
- begin
4
- require 'spec'
5
- rescue LoadError
6
- require 'rubygems'
7
- require 'spec'
8
- end
9
- begin
10
- require 'spec/rake/spectask'
11
- require 'spec/rake/verify_rcov'
12
- rescue LoadError
13
- puts <<-EOS
14
- To use rspec for testing you must install rspec gem:
15
- gem install rspec
16
- EOS
17
- exit(0)
18
- end
4
+ namespace 'rspec' do
5
+ FAST = FileList['spec/reek/**/*_spec.rb']
6
+ SLOW = FileList['spec/integration/**/*_spec.rb', 'spec/samples/**/*_spec.rb']
19
7
 
20
- REPORT_DIR = 'spec/output/coverage'
21
- CLEAN.include(REPORT_DIR)
8
+ Spec::Rake::SpecTask.new('fast') do |t|
9
+ t.spec_files = FAST
10
+ t.ruby_opts = ['-Ilib']
11
+ t.rcov = false
12
+ end
22
13
 
23
- desc "runs the specs"
24
- Spec::Rake::SpecTask.new(:spec) do |t|
25
- t.spec_files = FileList['spec/**/*_spec.rb']
14
+ Spec::Rake::SpecTask.new('all') do |t|
15
+ t.spec_files = FAST + SLOW
16
+ t.rcov = false
17
+ end
26
18
  end
27
19
 
28
- desc "runs the specs and reports coverage in #{REPORT_DIR}"
29
- Spec::Rake::SpecTask.new(:spec_rcov) do |t|
30
- t.spec_files = FileList['spec/**/*_spec.rb']
31
- t.rcov = true
32
- t.rcov_dir = REPORT_DIR
33
- t.rcov_opts = ['--exclude', 'spec,\.autotest']
34
- end
35
-
36
- desc "runs the specs and checks for 100% coverage"
37
- RCov::VerifyTask.new(:rcov => :spec_rcov) do |t|
38
- t.index_html = "#{REPORT_DIR}/index.html"
39
- t.threshold = 100
40
- end
20
+ desc 'runs the unit tests'
21
+ task 'spec' => 'rspec:fast'