reek 1.3.8 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +11 -0
- data/README.md +22 -14
- data/Rakefile +2 -15
- data/assets/html_output.html.erb +103 -0
- data/features/command_line_interface/options.feature +3 -0
- data/features/command_line_interface/smell_selection.feature +19 -0
- data/features/rake_task/rake_task.feature +1 -1
- data/features/reports/reports.feature +16 -0
- data/features/reports/yaml.feature +26 -23
- data/features/samples.feature +2 -1
- data/features/step_definitions/reek_steps.rb +15 -15
- data/features/support/env.rb +7 -9
- data/lib/reek/cli/application.rb +2 -4
- data/lib/reek/cli/command.rb +12 -0
- data/lib/reek/cli/help_command.rb +3 -6
- data/lib/reek/cli/options.rb +147 -0
- data/lib/reek/cli/reek_command.rb +18 -14
- data/lib/reek/cli/report/formatter.rb +56 -0
- data/lib/reek/cli/report/report.rb +106 -0
- data/lib/reek/cli/report/strategy.rb +63 -0
- data/lib/reek/cli/version_command.rb +3 -6
- data/lib/reek/config_file_exception.rb +0 -1
- data/lib/reek/core/code_context.rb +1 -3
- data/lib/reek/core/code_parser.rb +13 -12
- data/lib/reek/core/method_context.rb +13 -2
- data/lib/reek/core/module_context.rb +0 -4
- data/lib/reek/core/object_refs.rb +2 -3
- data/lib/reek/core/singleton_method_context.rb +0 -2
- data/lib/reek/core/smell_configuration.rb +3 -5
- data/lib/reek/core/smell_repository.rb +7 -8
- data/lib/reek/core/sniffer.rb +4 -10
- data/lib/reek/core/stop_context.rb +2 -4
- data/lib/reek/core/warning_collector.rb +0 -1
- data/lib/reek/examiner.rb +19 -17
- data/lib/reek/rake/task.rb +7 -10
- data/lib/reek/smell_warning.rb +4 -8
- data/lib/reek/smells.rb +0 -1
- data/lib/reek/smells/attribute.rb +8 -11
- data/lib/reek/smells/boolean_parameter.rb +5 -7
- data/lib/reek/smells/class_variable.rb +6 -7
- data/lib/reek/smells/control_parameter.rb +78 -45
- data/lib/reek/smells/data_clump.rb +13 -16
- data/lib/reek/smells/duplicate_method_call.rb +13 -11
- data/lib/reek/smells/feature_envy.rb +6 -7
- data/lib/reek/smells/irresponsible_module.rb +4 -6
- data/lib/reek/smells/long_parameter_list.rb +5 -7
- data/lib/reek/smells/long_yield_list.rb +2 -4
- data/lib/reek/smells/nested_iterators.rb +12 -22
- data/lib/reek/smells/nil_check.rb +35 -46
- data/lib/reek/smells/prima_donna_method.rb +24 -16
- data/lib/reek/smells/repeated_conditional.rb +8 -10
- data/lib/reek/smells/smell_detector.rb +9 -7
- data/lib/reek/smells/too_many_instance_variables.rb +7 -9
- data/lib/reek/smells/too_many_methods.rb +6 -8
- data/lib/reek/smells/too_many_statements.rb +4 -6
- data/lib/reek/smells/uncommunicative_method_name.rb +5 -7
- data/lib/reek/smells/uncommunicative_module_name.rb +5 -7
- data/lib/reek/smells/uncommunicative_parameter_name.rb +7 -9
- data/lib/reek/smells/uncommunicative_variable_name.rb +15 -18
- data/lib/reek/smells/unused_parameters.rb +5 -45
- data/lib/reek/smells/utility_function.rb +9 -10
- data/lib/reek/source.rb +0 -1
- data/lib/reek/source/code_comment.rb +7 -8
- data/lib/reek/source/config_file.rb +2 -4
- data/lib/reek/source/core_extras.rb +1 -1
- data/lib/reek/source/reference_collector.rb +1 -2
- data/lib/reek/source/sexp_extensions.rb +93 -10
- data/lib/reek/source/sexp_formatter.rb +2 -3
- data/lib/reek/source/sexp_node.rb +19 -15
- data/lib/reek/source/source_code.rb +4 -14
- data/lib/reek/source/source_file.rb +3 -5
- data/lib/reek/source/source_locator.rb +5 -6
- data/lib/reek/source/source_repository.rb +3 -3
- data/lib/reek/source/tree_dresser.rb +2 -2
- data/lib/reek/spec.rb +1 -2
- data/lib/reek/spec/should_reek.rb +8 -5
- data/lib/reek/spec/should_reek_of.rb +6 -4
- data/lib/reek/spec/should_reek_only_of.rb +10 -6
- data/lib/reek/version.rb +1 -1
- data/reek.gemspec +34 -30
- data/spec/gem/updates_spec.rb +3 -4
- data/spec/gem/yard_spec.rb +1 -2
- data/spec/matchers/smell_of_matcher.rb +12 -14
- data/spec/quality/reek_source_spec.rb +42 -0
- data/spec/reek/cli/help_command_spec.rb +7 -5
- data/spec/reek/cli/report_spec.rb +89 -22
- data/spec/reek/cli/version_command_spec.rb +8 -6
- data/spec/reek/core/code_context_spec.rb +25 -26
- data/spec/reek/core/code_parser_spec.rb +6 -6
- data/spec/reek/core/method_context_spec.rb +18 -18
- data/spec/reek/core/module_context_spec.rb +5 -5
- data/spec/reek/core/object_refs_spec.rb +21 -22
- data/spec/reek/core/smell_configuration_spec.rb +22 -21
- data/spec/reek/core/stop_context_spec.rb +2 -2
- data/spec/reek/core/warning_collector_spec.rb +3 -3
- data/spec/reek/examiner_spec.rb +9 -9
- data/spec/reek/smell_warning_spec.rb +29 -29
- data/spec/reek/smells/attribute_spec.rb +6 -6
- data/spec/reek/smells/behaves_like_variable_detector.rb +6 -6
- data/spec/reek/smells/boolean_parameter_spec.rb +17 -17
- data/spec/reek/smells/class_variable_spec.rb +9 -9
- data/spec/reek/smells/control_parameter_spec.rb +161 -137
- data/spec/reek/smells/data_clump_spec.rb +22 -19
- data/spec/reek/smells/duplicate_method_call_spec.rb +71 -27
- data/spec/reek/smells/feature_envy_spec.rb +32 -32
- data/spec/reek/smells/irresponsible_module_spec.rb +21 -21
- data/spec/reek/smells/long_parameter_list_spec.rb +14 -14
- data/spec/reek/smells/long_yield_list_spec.rb +6 -6
- data/spec/reek/smells/nested_iterators_spec.rb +21 -21
- data/spec/reek/smells/nil_check_spec.rb +23 -15
- data/spec/reek/smells/prima_donna_method_spec.rb +5 -5
- data/spec/reek/smells/repeated_conditional_spec.rb +14 -14
- data/spec/reek/smells/smell_detector_shared.rb +9 -9
- data/spec/reek/smells/too_many_instance_variables_spec.rb +12 -12
- data/spec/reek/smells/too_many_methods_spec.rb +10 -10
- data/spec/reek/smells/too_many_statements_spec.rb +41 -41
- data/spec/reek/smells/uncommunicative_method_name_spec.rb +4 -4
- data/spec/reek/smells/uncommunicative_module_name_spec.rb +12 -12
- data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +21 -21
- data/spec/reek/smells/uncommunicative_variable_name_spec.rb +49 -49
- data/spec/reek/smells/unused_parameters_spec.rb +26 -16
- data/spec/reek/smells/utility_function_spec.rb +20 -20
- data/spec/reek/source/code_comment_spec.rb +37 -37
- data/spec/reek/source/object_source_spec.rb +5 -5
- data/spec/reek/source/reference_collector_spec.rb +9 -9
- data/spec/reek/source/sexp_extensions_spec.rb +73 -52
- data/spec/reek/source/sexp_formatter_spec.rb +3 -4
- data/spec/reek/source/sexp_node_spec.rb +3 -3
- data/spec/reek/source/source_code_spec.rb +16 -15
- data/spec/reek/source/tree_dresser_spec.rb +2 -2
- data/spec/reek/spec/should_reek_of_spec.rb +11 -11
- data/spec/reek/spec/should_reek_only_of_spec.rb +11 -11
- data/spec/reek/spec/should_reek_spec.rb +11 -11
- data/spec/samples/one_smelly_file/dirty.rb +3 -0
- data/spec/spec_helper.rb +0 -6
- data/tasks/develop.rake +8 -16
- data/tasks/reek.rake +5 -13
- data/tasks/test.rake +5 -22
- metadata +56 -34
- data/lib/reek/cli/command_line.rb +0 -126
- 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
|
7
|
+
describe '::format' do
|
8
8
|
it 'formats a simple s-expression' do
|
9
9
|
result = SexpFormatter.format s(:lvar, :foo)
|
10
|
-
result.
|
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.
|
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.
|
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.
|
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.
|
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
|
-
@
|
16
|
+
@old_std_err = $stderr
|
17
|
+
$stderr = @catcher
|
17
18
|
end
|
18
19
|
|
19
|
-
shared_examples_for
|
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.
|
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.
|
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.
|
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.
|
41
|
+
expect(@catcher.string).to match(error_message)
|
41
42
|
end
|
42
43
|
end
|
43
44
|
|
44
|
-
context
|
45
|
+
context 'with a RubyParser::SyntaxError' do
|
45
46
|
let(:error_class) { RubyParser::SyntaxError }
|
46
47
|
|
47
48
|
before do
|
48
|
-
parser.
|
49
|
+
allow(parser).to receive(:parse).and_raise(error_class.new(error_message))
|
49
50
|
end
|
50
51
|
|
51
|
-
it_should_behave_like
|
52
|
+
it_should_behave_like 'handling and recording the error'
|
52
53
|
end
|
53
54
|
|
54
|
-
context
|
55
|
+
context 'with a Racc::ParseError' do
|
55
56
|
let(:error_class) { Racc::ParseError }
|
56
57
|
|
57
58
|
before do
|
58
|
-
parser.
|
59
|
+
allow(parser).to receive(:parse).and_raise(error_class.new(error_message))
|
59
60
|
end
|
60
61
|
|
61
|
-
it_should_behave_like
|
62
|
+
it_should_behave_like 'handling and recording the error'
|
62
63
|
end
|
63
64
|
|
64
|
-
context
|
65
|
+
context 'with a generic error' do
|
65
66
|
let(:error_class) { RuntimeError }
|
66
67
|
|
67
68
|
before do
|
68
|
-
parser.
|
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
|
-
|
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).
|
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).
|
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.
|
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.
|
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.
|
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).
|
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).
|
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).
|
41
|
-
@matcher.
|
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).
|
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).
|
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).
|
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).
|
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.
|
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.
|
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.
|
24
|
+
expect(@examiner).to receive(:description).and_return(@source)
|
25
25
|
end
|
26
26
|
it 'reports the source' do
|
27
|
-
@matcher.
|
27
|
+
expect(@matcher.failure_message).to match(@source)
|
28
28
|
end
|
29
29
|
it 'reports the expected smell class' do
|
30
|
-
@matcher.
|
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.
|
78
|
+
expect(@match).to be_truthy
|
79
79
|
end
|
80
80
|
it 'reports the expected smell when no match was expected' do
|
81
|
-
@matcher.
|
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.
|
86
|
-
@matcher.
|
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).
|
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).
|
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.
|
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).
|
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).
|
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).
|
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.
|
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).
|
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).
|
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).
|
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.
|
70
|
+
expect(matcher.failure_message_when_negated).to match('UncommunicativeVariableName')
|
71
71
|
end
|
72
72
|
end
|
73
73
|
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
|
-
|
6
|
-
CONFIG_FILE = "#{CONFIG_DIR}/defaults.reek"
|
3
|
+
CONFIG_FILE = 'config/defaults.reek'
|
7
4
|
|
8
|
-
|
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' =>
|
24
|
-
task 'test:
|
25
|
-
task 'test:
|
26
|
-
task '
|
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
|
-
|
2
|
-
require 'reek/rake/task'
|
1
|
+
require 'reek/rake/task'
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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 =
|
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 =
|
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 =
|
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 =
|
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
|
|