reek 1.3.8 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +11 -0
  3. data/README.md +22 -14
  4. data/Rakefile +2 -15
  5. data/assets/html_output.html.erb +103 -0
  6. data/features/command_line_interface/options.feature +3 -0
  7. data/features/command_line_interface/smell_selection.feature +19 -0
  8. data/features/rake_task/rake_task.feature +1 -1
  9. data/features/reports/reports.feature +16 -0
  10. data/features/reports/yaml.feature +26 -23
  11. data/features/samples.feature +2 -1
  12. data/features/step_definitions/reek_steps.rb +15 -15
  13. data/features/support/env.rb +7 -9
  14. data/lib/reek/cli/application.rb +2 -4
  15. data/lib/reek/cli/command.rb +12 -0
  16. data/lib/reek/cli/help_command.rb +3 -6
  17. data/lib/reek/cli/options.rb +147 -0
  18. data/lib/reek/cli/reek_command.rb +18 -14
  19. data/lib/reek/cli/report/formatter.rb +56 -0
  20. data/lib/reek/cli/report/report.rb +106 -0
  21. data/lib/reek/cli/report/strategy.rb +63 -0
  22. data/lib/reek/cli/version_command.rb +3 -6
  23. data/lib/reek/config_file_exception.rb +0 -1
  24. data/lib/reek/core/code_context.rb +1 -3
  25. data/lib/reek/core/code_parser.rb +13 -12
  26. data/lib/reek/core/method_context.rb +13 -2
  27. data/lib/reek/core/module_context.rb +0 -4
  28. data/lib/reek/core/object_refs.rb +2 -3
  29. data/lib/reek/core/singleton_method_context.rb +0 -2
  30. data/lib/reek/core/smell_configuration.rb +3 -5
  31. data/lib/reek/core/smell_repository.rb +7 -8
  32. data/lib/reek/core/sniffer.rb +4 -10
  33. data/lib/reek/core/stop_context.rb +2 -4
  34. data/lib/reek/core/warning_collector.rb +0 -1
  35. data/lib/reek/examiner.rb +19 -17
  36. data/lib/reek/rake/task.rb +7 -10
  37. data/lib/reek/smell_warning.rb +4 -8
  38. data/lib/reek/smells.rb +0 -1
  39. data/lib/reek/smells/attribute.rb +8 -11
  40. data/lib/reek/smells/boolean_parameter.rb +5 -7
  41. data/lib/reek/smells/class_variable.rb +6 -7
  42. data/lib/reek/smells/control_parameter.rb +78 -45
  43. data/lib/reek/smells/data_clump.rb +13 -16
  44. data/lib/reek/smells/duplicate_method_call.rb +13 -11
  45. data/lib/reek/smells/feature_envy.rb +6 -7
  46. data/lib/reek/smells/irresponsible_module.rb +4 -6
  47. data/lib/reek/smells/long_parameter_list.rb +5 -7
  48. data/lib/reek/smells/long_yield_list.rb +2 -4
  49. data/lib/reek/smells/nested_iterators.rb +12 -22
  50. data/lib/reek/smells/nil_check.rb +35 -46
  51. data/lib/reek/smells/prima_donna_method.rb +24 -16
  52. data/lib/reek/smells/repeated_conditional.rb +8 -10
  53. data/lib/reek/smells/smell_detector.rb +9 -7
  54. data/lib/reek/smells/too_many_instance_variables.rb +7 -9
  55. data/lib/reek/smells/too_many_methods.rb +6 -8
  56. data/lib/reek/smells/too_many_statements.rb +4 -6
  57. data/lib/reek/smells/uncommunicative_method_name.rb +5 -7
  58. data/lib/reek/smells/uncommunicative_module_name.rb +5 -7
  59. data/lib/reek/smells/uncommunicative_parameter_name.rb +7 -9
  60. data/lib/reek/smells/uncommunicative_variable_name.rb +15 -18
  61. data/lib/reek/smells/unused_parameters.rb +5 -45
  62. data/lib/reek/smells/utility_function.rb +9 -10
  63. data/lib/reek/source.rb +0 -1
  64. data/lib/reek/source/code_comment.rb +7 -8
  65. data/lib/reek/source/config_file.rb +2 -4
  66. data/lib/reek/source/core_extras.rb +1 -1
  67. data/lib/reek/source/reference_collector.rb +1 -2
  68. data/lib/reek/source/sexp_extensions.rb +93 -10
  69. data/lib/reek/source/sexp_formatter.rb +2 -3
  70. data/lib/reek/source/sexp_node.rb +19 -15
  71. data/lib/reek/source/source_code.rb +4 -14
  72. data/lib/reek/source/source_file.rb +3 -5
  73. data/lib/reek/source/source_locator.rb +5 -6
  74. data/lib/reek/source/source_repository.rb +3 -3
  75. data/lib/reek/source/tree_dresser.rb +2 -2
  76. data/lib/reek/spec.rb +1 -2
  77. data/lib/reek/spec/should_reek.rb +8 -5
  78. data/lib/reek/spec/should_reek_of.rb +6 -4
  79. data/lib/reek/spec/should_reek_only_of.rb +10 -6
  80. data/lib/reek/version.rb +1 -1
  81. data/reek.gemspec +34 -30
  82. data/spec/gem/updates_spec.rb +3 -4
  83. data/spec/gem/yard_spec.rb +1 -2
  84. data/spec/matchers/smell_of_matcher.rb +12 -14
  85. data/spec/quality/reek_source_spec.rb +42 -0
  86. data/spec/reek/cli/help_command_spec.rb +7 -5
  87. data/spec/reek/cli/report_spec.rb +89 -22
  88. data/spec/reek/cli/version_command_spec.rb +8 -6
  89. data/spec/reek/core/code_context_spec.rb +25 -26
  90. data/spec/reek/core/code_parser_spec.rb +6 -6
  91. data/spec/reek/core/method_context_spec.rb +18 -18
  92. data/spec/reek/core/module_context_spec.rb +5 -5
  93. data/spec/reek/core/object_refs_spec.rb +21 -22
  94. data/spec/reek/core/smell_configuration_spec.rb +22 -21
  95. data/spec/reek/core/stop_context_spec.rb +2 -2
  96. data/spec/reek/core/warning_collector_spec.rb +3 -3
  97. data/spec/reek/examiner_spec.rb +9 -9
  98. data/spec/reek/smell_warning_spec.rb +29 -29
  99. data/spec/reek/smells/attribute_spec.rb +6 -6
  100. data/spec/reek/smells/behaves_like_variable_detector.rb +6 -6
  101. data/spec/reek/smells/boolean_parameter_spec.rb +17 -17
  102. data/spec/reek/smells/class_variable_spec.rb +9 -9
  103. data/spec/reek/smells/control_parameter_spec.rb +161 -137
  104. data/spec/reek/smells/data_clump_spec.rb +22 -19
  105. data/spec/reek/smells/duplicate_method_call_spec.rb +71 -27
  106. data/spec/reek/smells/feature_envy_spec.rb +32 -32
  107. data/spec/reek/smells/irresponsible_module_spec.rb +21 -21
  108. data/spec/reek/smells/long_parameter_list_spec.rb +14 -14
  109. data/spec/reek/smells/long_yield_list_spec.rb +6 -6
  110. data/spec/reek/smells/nested_iterators_spec.rb +21 -21
  111. data/spec/reek/smells/nil_check_spec.rb +23 -15
  112. data/spec/reek/smells/prima_donna_method_spec.rb +5 -5
  113. data/spec/reek/smells/repeated_conditional_spec.rb +14 -14
  114. data/spec/reek/smells/smell_detector_shared.rb +9 -9
  115. data/spec/reek/smells/too_many_instance_variables_spec.rb +12 -12
  116. data/spec/reek/smells/too_many_methods_spec.rb +10 -10
  117. data/spec/reek/smells/too_many_statements_spec.rb +41 -41
  118. data/spec/reek/smells/uncommunicative_method_name_spec.rb +4 -4
  119. data/spec/reek/smells/uncommunicative_module_name_spec.rb +12 -12
  120. data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +21 -21
  121. data/spec/reek/smells/uncommunicative_variable_name_spec.rb +49 -49
  122. data/spec/reek/smells/unused_parameters_spec.rb +26 -16
  123. data/spec/reek/smells/utility_function_spec.rb +20 -20
  124. data/spec/reek/source/code_comment_spec.rb +37 -37
  125. data/spec/reek/source/object_source_spec.rb +5 -5
  126. data/spec/reek/source/reference_collector_spec.rb +9 -9
  127. data/spec/reek/source/sexp_extensions_spec.rb +73 -52
  128. data/spec/reek/source/sexp_formatter_spec.rb +3 -4
  129. data/spec/reek/source/sexp_node_spec.rb +3 -3
  130. data/spec/reek/source/source_code_spec.rb +16 -15
  131. data/spec/reek/source/tree_dresser_spec.rb +2 -2
  132. data/spec/reek/spec/should_reek_of_spec.rb +11 -11
  133. data/spec/reek/spec/should_reek_only_of_spec.rb +11 -11
  134. data/spec/reek/spec/should_reek_spec.rb +11 -11
  135. data/spec/samples/one_smelly_file/dirty.rb +3 -0
  136. data/spec/spec_helper.rb +0 -6
  137. data/tasks/develop.rake +8 -16
  138. data/tasks/reek.rake +5 -13
  139. data/tasks/test.rake +5 -22
  140. metadata +56 -34
  141. data/lib/reek/cli/command_line.rb +0 -126
  142. data/lib/reek/cli/report.rb +0 -138
@@ -4,16 +4,15 @@ require 'reek/source/sexp_formatter'
4
4
  include Reek::Source
5
5
 
6
6
  describe SexpFormatter do
7
- describe "::format" do
7
+ describe '::format' do
8
8
  it 'formats a simple s-expression' do
9
9
  result = SexpFormatter.format s(:lvar, :foo)
10
- result.should == "foo"
10
+ expect(result).to eq('foo')
11
11
  end
12
12
 
13
13
  it 'formats a more complex s-expression' do
14
14
  result = SexpFormatter.format s(:call, nil, :foo, s(:arglist, s(:lvar, :bar)))
15
- result.should == "foo(bar)"
15
+ expect(result).to eq('foo(bar)')
16
16
  end
17
17
  end
18
18
  end
19
-
@@ -8,7 +8,7 @@ describe SexpNode do
8
8
  it 'formats self' do
9
9
  @node = s(:self)
10
10
  @node.extend(SexpNode)
11
- @node.format_ruby.should == 'self'
11
+ expect(@node.format_ruby).to eq('self')
12
12
  end
13
13
  end
14
14
 
@@ -16,12 +16,12 @@ describe SexpNode do
16
16
  it 'hashes equal for equal sexps' do
17
17
  node1 = ast(:defn, s(:const2, :Fred, :jim), s(:call, :+, s(:lit, 4), :fred))
18
18
  node2 = ast(:defn, s(:const2, :Fred, :jim), s(:call, :+, s(:lit, 4), :fred))
19
- node1.hash.should == node2.hash
19
+ expect(node1.hash).to eq(node2.hash)
20
20
  end
21
21
  it 'hashes diferent for diferent sexps' do
22
22
  node1 = ast(:defn, s(:const2, :Fred, :jim), s(:call, :+, s(:lit, 4), :fred))
23
23
  node2 = ast(:defn, s(:const2, :Fred, :jim), s(:call, :+, s(:lit, 3), :fred))
24
- node1.hash.should_not == node2.hash
24
+ expect(node1.hash).not_to eq(node2.hash)
25
25
  end
26
26
  end
27
27
  end
@@ -13,59 +13,60 @@ describe SourceCode do
13
13
 
14
14
  before :each do
15
15
  @catcher = StringIO.new
16
- @old_err_io = (SourceCode.err_io = @catcher)
16
+ @old_std_err = $stderr
17
+ $stderr = @catcher
17
18
  end
18
19
 
19
- shared_examples_for "handling and recording the error" do
20
+ shared_examples_for 'handling and recording the error' do
20
21
  it 'does not raise an error' do
21
22
  src.syntax_tree
22
23
  end
23
24
 
24
25
  it 'returns an empty syntax tree' do
25
- src.syntax_tree.should == s()
26
+ expect(src.syntax_tree).to eq(s())
26
27
  end
27
28
 
28
29
  it 'records the syntax error' do
29
30
  src.syntax_tree
30
- @catcher.string.should match(error_class.name)
31
+ expect(@catcher.string).to match(error_class.name)
31
32
  end
32
33
 
33
34
  it 'records the source name' do
34
35
  src.syntax_tree
35
- @catcher.string.should match(source_name)
36
+ expect(@catcher.string).to match(source_name)
36
37
  end
37
38
 
38
39
  it 'records the error message' do
39
40
  src.syntax_tree
40
- @catcher.string.should match(error_message)
41
+ expect(@catcher.string).to match(error_message)
41
42
  end
42
43
  end
43
44
 
44
- context "with a RubyParser::SyntaxError" do
45
+ context 'with a RubyParser::SyntaxError' do
45
46
  let(:error_class) { RubyParser::SyntaxError }
46
47
 
47
48
  before do
48
- parser.stub(:parse).and_raise(error_class.new(error_message))
49
+ allow(parser).to receive(:parse).and_raise(error_class.new(error_message))
49
50
  end
50
51
 
51
- it_should_behave_like "handling and recording the error"
52
+ it_should_behave_like 'handling and recording the error'
52
53
  end
53
54
 
54
- context "with a Racc::ParseError" do
55
+ context 'with a Racc::ParseError' do
55
56
  let(:error_class) { Racc::ParseError }
56
57
 
57
58
  before do
58
- parser.stub(:parse).and_raise(error_class.new(error_message))
59
+ allow(parser).to receive(:parse).and_raise(error_class.new(error_message))
59
60
  end
60
61
 
61
- it_should_behave_like "handling and recording the error"
62
+ it_should_behave_like 'handling and recording the error'
62
63
  end
63
64
 
64
- context "with a generic error" do
65
+ context 'with a generic error' do
65
66
  let(:error_class) { RuntimeError }
66
67
 
67
68
  before do
68
- parser.stub(:parse).and_raise(error_class.new(error_message))
69
+ allow(parser).to receive(:parse).and_raise(error_class.new(error_message))
69
70
  end
70
71
 
71
72
  it 'raises the error' do
@@ -74,7 +75,7 @@ describe SourceCode do
74
75
  end
75
76
 
76
77
  after :each do
77
- SourceCode.err_io = @old_err_io
78
+ $stderr = @old_std_err
78
79
  end
79
80
  end
80
81
  end
@@ -9,10 +9,10 @@ describe TreeDresser do
9
9
  let(:dresser) { TreeDresser.new }
10
10
 
11
11
  it 'dresses :if sexp with IfNode' do
12
- dresser.dress(ifnode).should be_a Reek::Source::SexpExtensions::IfNode
12
+ expect(dresser.dress(ifnode)).to be_a Reek::Source::SexpExtensions::IfNode
13
13
  end
14
14
 
15
15
  it 'dresses :call sexp with CallNode' do
16
- dresser.dress(callnode).should be_a Reek::Source::SexpExtensions::CallNode
16
+ expect(dresser.dress(callnode)).to be_a Reek::Source::SexpExtensions::CallNode
17
17
  end
18
18
  end
@@ -11,13 +11,13 @@ describe ShouldReekOf do
11
11
  end
12
12
 
13
13
  it 'reports duplicate calls to @other.thing' do
14
- @ruby.should reek_of(:Duplication, /@other.thing[^\.]/)
14
+ expect(@ruby).to reek_of(:Duplication, /@other.thing[^\.]/)
15
15
  end
16
16
  it 'reports duplicate calls to @other.thing.foo' do
17
- @ruby.should reek_of(:Duplication, /@other.thing.foo/)
17
+ expect(@ruby).to reek_of(:Duplication, /@other.thing.foo/)
18
18
  end
19
19
  it 'does not report any feature envy' do
20
- @ruby.should_not reek_of(:FeatureEnvy)
20
+ expect(@ruby).not_to reek_of(:FeatureEnvy)
21
21
  end
22
22
  end
23
23
 
@@ -29,16 +29,16 @@ describe ShouldReekOf do
29
29
  end
30
30
 
31
31
  it 'matches a smelly String' do
32
- @matcher.matches?(@smelly_code).should be_true
32
+ expect(@matcher.matches?(@smelly_code)).to be_truthy
33
33
  end
34
34
 
35
35
  it 'doesnt match a fragrant String' do
36
- @matcher.matches?(@clean_code).should be_false
36
+ expect(@matcher.matches?(@clean_code)).to be_falsey
37
37
  end
38
38
 
39
39
  it 'reports the smells when should_not fails' do
40
- @matcher.matches?(@smelly_code).should be_true
41
- @matcher.failure_message_for_should_not.should match('UncommunicativeVariableName')
40
+ expect(@matcher.matches?(@smelly_code)).to be_truthy
41
+ expect(@matcher.failure_message_when_negated).to match('UncommunicativeVariableName')
42
42
  end
43
43
  end
44
44
 
@@ -50,11 +50,11 @@ describe ShouldReekOf do
50
50
  end
51
51
 
52
52
  it 'matches a smelly String' do
53
- @matcher.matches?(@smelly_dir).should be_true
53
+ expect(@matcher.matches?(@smelly_dir)).to be_truthy
54
54
  end
55
55
 
56
56
  it 'doesnt match a fragrant String' do
57
- @matcher.matches?(@clean_dir).should be_false
57
+ expect(@matcher.matches?(@clean_dir)).to be_falsey
58
58
  end
59
59
  end
60
60
 
@@ -66,11 +66,11 @@ describe ShouldReekOf do
66
66
  end
67
67
 
68
68
  it 'matches a smelly String' do
69
- @matcher.matches?(@smelly_file).should be_true
69
+ expect(@matcher.matches?(@smelly_file)).to be_truthy
70
70
  end
71
71
 
72
72
  it 'doesnt match a fragrant String' do
73
- @matcher.matches?(@clean_file).should be_false
73
+ expect(@matcher.matches?(@clean_file)).to be_falsey
74
74
  end
75
75
  end
76
76
  end
@@ -10,24 +10,24 @@ describe ShouldReekOnlyOf do
10
10
  @expected_context_name = 'SmellyClass#big_method'
11
11
  @matcher = ShouldReekOnlyOf.new(@expected_smell_class, [/#{@expected_context_name}/])
12
12
  @examiner = double('examiner').as_null_object
13
- @examiner.should_receive(:smells).and_return {smells}
13
+ expect(@examiner).to receive(:smells) { smells }
14
14
  @match = @matcher.matches_examiner?(@examiner)
15
15
  end
16
16
 
17
17
  shared_examples_for 'no match' do
18
18
  it 'does not match' do
19
- @match.should be_false
19
+ expect(@match).to be_falsey
20
20
  end
21
21
  context 'when a match was expected' do
22
22
  before :each do
23
23
  @source = 'the_path/to_a/source_file.rb'
24
- @examiner.should_receive(:description).and_return(@source)
24
+ expect(@examiner).to receive(:description).and_return(@source)
25
25
  end
26
26
  it 'reports the source' do
27
- @matcher.failure_message_for_should.should match(@source)
27
+ expect(@matcher.failure_message).to match(@source)
28
28
  end
29
29
  it 'reports the expected smell class' do
30
- @matcher.failure_message_for_should.should match(@expected_smell_class.to_s)
30
+ expect(@matcher.failure_message).to match(@expected_smell_class.to_s)
31
31
  end
32
32
  end
33
33
  end
@@ -53,7 +53,7 @@ describe ShouldReekOnlyOf do
53
53
  [
54
54
  SmellWarning.new('ControlCouple', 'context', [1], 'any old message'),
55
55
  SmellWarning.new('FeatureEnvy', 'context', [1], 'any old message')
56
- ]
56
+ ]
57
57
  end
58
58
 
59
59
  it_should_behave_like 'no match'
@@ -64,7 +64,7 @@ describe ShouldReekOnlyOf do
64
64
  [
65
65
  SmellWarning.new('ControlCouple', 'context', [1], 'any old message'),
66
66
  SmellWarning.new(@expected_smell_class.to_s, 'context', [1], "message mentioning #{@expected_context_name}")
67
- ]
67
+ ]
68
68
  end
69
69
 
70
70
  it_should_behave_like 'no match'
@@ -75,15 +75,15 @@ describe ShouldReekOnlyOf do
75
75
  [SmellWarning.new(@expected_smell_class.to_s, nil, [1], "message mentioning #{@expected_context_name}")]
76
76
  end
77
77
  it 'matches' do
78
- @match.should be_true
78
+ expect(@match).to be_truthy
79
79
  end
80
80
  it 'reports the expected smell when no match was expected' do
81
- @matcher.failure_message_for_should_not.should match(@expected_smell_class.to_s)
81
+ expect(@matcher.failure_message_when_negated).to match(@expected_smell_class.to_s)
82
82
  end
83
83
  it 'reports the source when no match was expected' do
84
84
  source = 'the_path/to_a/source_file.rb'
85
- @examiner.should_receive(:description).and_return(source)
86
- @matcher.failure_message_for_should_not.should match(source)
85
+ expect(@examiner).to receive(:description).and_return(source)
86
+ expect(@matcher.failure_message_when_negated).to match(source)
87
87
  end
88
88
  end
89
89
  end
@@ -12,16 +12,16 @@ describe ShouldReek do
12
12
  let(:smelly_code) { 'def x() y = 4; end' }
13
13
 
14
14
  it 'matches a smelly String' do
15
- matcher.matches?(smelly_code).should be_true
15
+ expect(matcher.matches?(smelly_code)).to be_truthy
16
16
  end
17
17
 
18
18
  it 'doesnt match a fragrant String' do
19
- matcher.matches?(clean_code).should be_false
19
+ expect(matcher.matches?(clean_code)).to be_falsey
20
20
  end
21
21
 
22
22
  it 'reports the smells when should_not fails' do
23
23
  matcher.matches?(smelly_code)
24
- matcher.failure_message_for_should_not.should match('UncommunicativeVariableName')
24
+ expect(matcher.failure_message_when_negated).to match('UncommunicativeVariableName')
25
25
  end
26
26
  end
27
27
 
@@ -31,20 +31,20 @@ describe ShouldReek do
31
31
  let(:masked_dir) { Dir['spec/samples/clean_due_to_masking/*.rb'] }
32
32
 
33
33
  it 'matches a smelly Dir' do
34
- matcher.matches?(smelly_dir).should be_true
34
+ expect(matcher.matches?(smelly_dir)).to be_truthy
35
35
  end
36
36
 
37
37
  it 'doesnt match a fragrant Dir' do
38
- matcher.matches?(clean_dir).should be_false
38
+ expect(matcher.matches?(clean_dir)).to be_falsey
39
39
  end
40
40
 
41
41
  it 'masks smells using the relevant configuration' do
42
- matcher.matches?(masked_dir).should be_false
42
+ expect(matcher.matches?(masked_dir)).to be_falsey
43
43
  end
44
44
 
45
45
  it 'reports the smells when should_not fails' do
46
46
  matcher.matches?(smelly_dir)
47
- matcher.failure_message_for_should_not.should match('UncommunicativeVariableName')
47
+ expect(matcher.failure_message_when_negated).to match('UncommunicativeVariableName')
48
48
  end
49
49
  end
50
50
 
@@ -54,20 +54,20 @@ describe ShouldReek do
54
54
  let(:masked_file) { File.new('spec/samples/clean_due_to_masking/dirty_one.rb') }
55
55
 
56
56
  it 'matches a smelly File' do
57
- matcher.matches?(smelly_file).should be_true
57
+ expect(matcher.matches?(smelly_file)).to be_truthy
58
58
  end
59
59
 
60
60
  it 'doesnt match a fragrant File' do
61
- matcher.matches?(clean_file).should be_false
61
+ expect(matcher.matches?(clean_file)).to be_falsey
62
62
  end
63
63
 
64
64
  it 'masks smells using the relevant configuration' do
65
- matcher.matches?(masked_file).should be_false
65
+ expect(matcher.matches?(masked_file)).to be_falsey
66
66
  end
67
67
 
68
68
  it 'reports the smells when should_not fails' do
69
69
  matcher.matches?(smelly_file)
70
- matcher.failure_message_for_should_not.should match('UncommunicativeVariableName')
70
+ expect(matcher.failure_message_when_negated).to match('UncommunicativeVariableName')
71
71
  end
72
72
  end
73
73
  end
@@ -0,0 +1,3 @@
1
+ class D
2
+ def a; end
3
+ end
data/spec/spec_helper.rb CHANGED
@@ -2,11 +2,6 @@ require 'reek/spec'
2
2
  require 'reek/source/tree_dresser'
3
3
 
4
4
  require 'matchers/smell_of_matcher'
5
- begin
6
- require 'debugger'
7
- rescue LoadError
8
- # Swallow error. Not required to run tests
9
- end
10
5
 
11
6
  SAMPLES_DIR = 'spec/samples'
12
7
 
@@ -18,7 +13,6 @@ end
18
13
 
19
14
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
20
15
  RSpec.configure do |config|
21
- config.treat_symbols_as_metadata_keys_with_true_values = true
22
16
  config.filter_run :focus
23
17
  config.run_all_when_everything_filtered = true
24
18
  end
data/tasks/develop.rake CHANGED
@@ -1,29 +1,21 @@
1
1
  require 'rake/clean'
2
- require 'reek/core/sniffer'
3
- require 'yaml'
4
2
 
5
- CONFIG_DIR = 'config'
6
- CONFIG_FILE = "#{CONFIG_DIR}/defaults.reek"
3
+ CONFIG_FILE = 'config/defaults.reek'
7
4
 
8
- CLOBBER.include(CONFIG_DIR)
9
-
10
- directory CONFIG_DIR
11
-
12
- file CONFIG_FILE => [CONFIG_DIR] do
5
+ file CONFIG_FILE do
13
6
  config = {}
7
+ require 'reek/core/sniffer'
14
8
  Reek::Core::SmellRepository.smell_classes.each do |klass|
15
9
  config[klass.name.split(/::/)[-1]] = klass.default_config
16
10
  end
17
11
  $stderr.puts "Creating #{CONFIG_FILE}"
12
+ require 'yaml'
18
13
  File.open(CONFIG_FILE, 'w') { |f| YAML.dump(config, f) }
19
14
  end
20
15
 
21
16
  task CONFIG_FILE => FileList['lib/reek/smells/*.rb']
22
17
 
23
- task 'test:spec' => [CONFIG_FILE]
24
- task 'test:slow' => [CONFIG_FILE]
25
- task 'test:rcov' => [CONFIG_FILE]
26
- task 'test:quality' => [CONFIG_FILE]
27
- task 'test:features' => [CONFIG_FILE]
28
- task 'reek' => [CONFIG_FILE]
29
- task 'check:manifest' => [CONFIG_FILE]
18
+ task 'test:spec' => CONFIG_FILE
19
+ task 'test:quality' => CONFIG_FILE
20
+ task 'test:features' => CONFIG_FILE
21
+ task 'reek' => CONFIG_FILE
data/tasks/reek.rake CHANGED
@@ -1,15 +1,7 @@
1
- begin
2
- require 'reek/rake/task'
1
+ require 'reek/rake/task'
3
2
 
4
- Reek::Rake::Task.new do |t|
5
- t.fail_on_error = true
6
- t.verbose = false
7
- t.reek_opts = '--quiet'
8
- end
9
- rescue Gem::LoadError
10
- end
11
-
12
- begin
13
- require 'metric_fu'
14
- rescue LoadError
3
+ Reek::Rake::Task.new do |t|
4
+ t.fail_on_error = true
5
+ t.verbose = false
6
+ t.reek_opts = '--quiet'
15
7
  end
data/tasks/test.rake CHANGED
@@ -1,48 +1,31 @@
1
- require 'rubygems'
2
- require 'cucumber'
3
1
  require 'cucumber/rake/task'
4
- require 'rspec'
5
2
  require 'rspec/core/rake_task'
6
3
 
7
4
  namespace 'test' do
8
- UNIT_TESTS = FileList['spec/reek/**/*_spec.rb']
9
-
10
5
  RSpec::Core::RakeTask.new('spec') do |t|
11
- t.pattern = UNIT_TESTS
12
- t.ruby_opts = ['-Ilib']
13
- t.rcov = false
6
+ t.pattern = 'spec/reek/**/*_spec.rb'
7
+ t.ruby_opts = ['-Ilib -w']
14
8
  end
15
9
 
16
10
  desc 'Tests various release attributes of the gem'
17
11
  RSpec::Core::RakeTask.new('gem') do |t|
18
- t.pattern = FileList['spec/gem/**/*_spec.rb']
19
- t.rcov = false
12
+ t.pattern = 'spec/gem/**/*_spec.rb'
20
13
  end
21
14
 
22
15
  desc 'Tests code quality'
23
16
  RSpec::Core::RakeTask.new('quality') do |t|
24
- t.pattern = FileList['quality/**/*_spec.rb']
17
+ t.pattern = 'spec/quality/**/*_spec.rb'
25
18
  t.ruby_opts = ['-Ilib']
26
- t.rcov = false
27
- end
28
-
29
- desc 'Runs all unit tests under RCov'
30
- RSpec::Core::RakeTask.new('rcov') do |t|
31
- t.pattern = UNIT_TESTS
32
- t.rcov = true
33
- t.rcov_opts = '-o build/coverage'
34
19
  end
35
20
 
36
21
  Cucumber::Rake::Task.new(:features) do |t|
37
- t.cucumber_opts = "features --format progress --color"
22
+ t.cucumber_opts = 'features --format progress --color'
38
23
  end
39
24
 
40
25
  desc 'Runs all unit tests and acceptance tests'
41
26
  task 'all' => ['test:spec', 'test:features']
42
27
  end
43
28
 
44
- task 'clobber_rcov' => 'test:clobber_rcov'
45
-
46
29
  desc 'Synonym for test:spec'
47
30
  task 'spec' => 'test:spec'
48
31