reek 1.6.6 → 2.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.
- checksums.yaml +4 -4
- data/CHANGELOG +6 -9
- data/features/command_line_interface/options.feature +20 -16
- data/features/command_line_interface/stdin.feature +1 -1
- data/features/rake_task/rake_task.feature +0 -12
- data/features/reports/reports.feature +63 -23
- data/features/reports/yaml.feature +3 -3
- data/features/samples.feature +3 -3
- data/lib/reek/cli/application.rb +5 -5
- data/lib/reek/cli/input.rb +1 -1
- data/lib/reek/cli/option_interpreter.rb +77 -0
- data/lib/reek/cli/options.rb +89 -82
- data/lib/reek/cli/report/formatter.rb +33 -24
- data/lib/reek/cli/report/heading_formatter.rb +45 -0
- data/lib/reek/cli/report/location_formatter.rb +23 -0
- data/lib/reek/cli/report/report.rb +32 -17
- data/lib/reek/configuration/app_configuration.rb +2 -2
- data/lib/reek/configuration/configuration_file_finder.rb +10 -10
- data/lib/reek/core/smell_repository.rb +3 -28
- data/lib/reek/rake/task.rb +35 -76
- data/lib/reek/smell_warning.rb +31 -16
- data/lib/reek/smells/nested_iterators.rb +1 -1
- data/lib/reek/smells/smell_detector.rb +9 -0
- data/lib/reek/smells/utility_function.rb +2 -1
- data/lib/reek/spec/should_reek.rb +0 -3
- data/lib/reek/spec/should_reek_of.rb +61 -12
- data/lib/reek/spec/should_reek_only_of.rb +12 -10
- data/lib/reek/version.rb +1 -1
- data/reek.gemspec +2 -2
- data/spec/factories/factories.rb +2 -5
- data/spec/reek/cli/html_report_spec.rb +28 -0
- data/spec/reek/cli/option_interperter_spec.rb +14 -0
- data/spec/reek/cli/text_report_spec.rb +95 -0
- data/spec/reek/cli/yaml_report_spec.rb +23 -0
- data/spec/reek/configuration/configuration_file_finder_spec.rb +5 -6
- data/spec/reek/core/module_context_spec.rb +1 -1
- data/spec/reek/core/smell_repository_spec.rb +17 -0
- data/spec/reek/smell_warning_spec.rb +9 -11
- data/spec/reek/smells/boolean_parameter_spec.rb +11 -11
- data/spec/reek/smells/control_parameter_spec.rb +40 -40
- data/spec/reek/smells/data_clump_spec.rb +17 -17
- data/spec/reek/smells/duplicate_method_call_spec.rb +56 -33
- data/spec/reek/smells/feature_envy_spec.rb +44 -40
- data/spec/reek/smells/irresponsible_module_spec.rb +1 -1
- data/spec/reek/smells/long_parameter_list_spec.rb +12 -12
- data/spec/reek/smells/long_yield_list_spec.rb +4 -4
- data/spec/reek/smells/module_initialize_spec.rb +3 -3
- data/spec/reek/smells/nested_iterators_spec.rb +71 -52
- data/spec/reek/smells/nil_check_spec.rb +6 -6
- data/spec/reek/smells/prima_donna_method_spec.rb +2 -2
- data/spec/reek/smells/too_many_statements_spec.rb +34 -34
- data/spec/reek/smells/uncommunicative_method_name_spec.rb +1 -1
- data/spec/reek/smells/uncommunicative_module_name_spec.rb +7 -3
- data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +12 -12
- data/spec/reek/smells/uncommunicative_variable_name_spec.rb +28 -38
- data/spec/reek/smells/unused_parameters_spec.rb +16 -17
- data/spec/reek/smells/utility_function_spec.rb +21 -8
- data/spec/reek/spec/should_reek_of_spec.rb +18 -5
- data/spec/reek/spec/should_reek_only_of_spec.rb +7 -1
- data/spec/spec_helper.rb +22 -14
- metadata +15 -20
- data/lib/reek/cli/help_command.rb +0 -15
- data/lib/reek/cli/report/strategy.rb +0 -64
- data/lib/reek/cli/version_command.rb +0 -16
- data/spec/matchers/smell_of_matcher.rb +0 -95
- data/spec/reek/cli/help_command_spec.rb +0 -25
- data/spec/reek/cli/report_spec.rb +0 -132
- data/spec/reek/cli/version_command_spec.rb +0 -31
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'reek/examiner'
|
3
|
+
require 'reek/cli/report/report'
|
4
|
+
require 'reek/cli/report/formatter'
|
5
|
+
|
6
|
+
include Reek
|
7
|
+
include Reek::Cli
|
8
|
+
|
9
|
+
describe Report::YamlReport do
|
10
|
+
let(:instance) { Report::YamlReport.new }
|
11
|
+
|
12
|
+
context 'empty source' do
|
13
|
+
let(:examiner) { Examiner.new('') }
|
14
|
+
|
15
|
+
before do
|
16
|
+
instance.add_examiner examiner
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'prints empty yaml' do
|
20
|
+
expect { instance.show }.to output(/^--- \[\]\n.*$/).to_stdout
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -8,19 +8,18 @@ describe ConfigurationFileFinder do
|
|
8
8
|
describe '.find' do
|
9
9
|
let(:sample_config_path) { Pathname.new('spec/samples/simple_configuration.reek') }
|
10
10
|
let(:config_path_same_level) { Pathname.new('spec/samples/simple_configuration.reek') }
|
11
|
-
let(:
|
12
|
-
let(:
|
13
|
-
let(:application_without_options) { nil }
|
11
|
+
let(:options_with_config_file) { double(config_file: sample_config_path) }
|
12
|
+
let(:options_without_config_file) { double(config_file: nil) }
|
14
13
|
|
15
14
|
it 'should return the config file we passed as cli option if given' do
|
16
|
-
expect(ConfigurationFileFinder.find(
|
15
|
+
expect(ConfigurationFileFinder.find(options_with_config_file)).to eq(sample_config_path)
|
17
16
|
end
|
18
17
|
|
19
18
|
it 'should return the first configuration file it can find in the current directory' do
|
20
19
|
allow(ConfigurationFileFinder).to receive(:detect_or_traverse_up).
|
21
20
|
and_return config_path_same_level
|
22
21
|
|
23
|
-
expect(ConfigurationFileFinder.find(
|
22
|
+
expect(ConfigurationFileFinder.find(options_without_config_file)).
|
24
23
|
to eq(config_path_same_level)
|
25
24
|
end
|
26
25
|
|
@@ -29,7 +28,7 @@ describe ConfigurationFileFinder do
|
|
29
28
|
allow(ConfigurationFileFinder).to receive(:configuration_in_file_system).and_return nil
|
30
29
|
expect(ConfigurationFileFinder).to receive(:configuration_in_home_directory).once
|
31
30
|
|
32
|
-
ConfigurationFileFinder.find
|
31
|
+
ConfigurationFileFinder.find nil
|
33
32
|
end
|
34
33
|
end
|
35
34
|
end
|
@@ -10,7 +10,7 @@ describe ModuleContext do
|
|
10
10
|
module Fred
|
11
11
|
def simple(x) x + 1; end
|
12
12
|
end
|
13
|
-
').to reek_of(:UncommunicativeParameterName,
|
13
|
+
').to reek_of(:UncommunicativeParameterName, name: 'x')
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'should not report module with empty class' do
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'reek/core/smell_repository'
|
3
|
+
|
4
|
+
include Reek::Core
|
5
|
+
|
6
|
+
describe SmellRepository do
|
7
|
+
describe '.smell_types' do
|
8
|
+
it 'should include existing smell_types' do
|
9
|
+
expect(SmellRepository.smell_types).to include(Reek::Smells::IrresponsibleModule)
|
10
|
+
expect(SmellRepository.smell_types).to include(Reek::Smells::TooManyStatements)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should exclude certain smell_types' do
|
14
|
+
expect(SmellRepository.smell_types).to_not include(Reek::Smells::SmellDetector)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -89,7 +89,7 @@ describe SmellWarning do
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
context '
|
92
|
+
context '#yaml_hash' do
|
93
93
|
before :each do
|
94
94
|
@message = 'test message'
|
95
95
|
@lines = [24, 513]
|
@@ -100,18 +100,16 @@ describe SmellWarning do
|
|
100
100
|
|
101
101
|
shared_examples_for 'common fields' do
|
102
102
|
it 'includes the smell type' do
|
103
|
-
expect(@yaml).to
|
103
|
+
expect(@yaml['smell_type']).to eq 'FeatureEnvy'
|
104
104
|
end
|
105
105
|
it 'includes the context' do
|
106
|
-
expect(@yaml).to
|
106
|
+
expect(@yaml['context']).to eq @context_name
|
107
107
|
end
|
108
108
|
it 'includes the message' do
|
109
|
-
expect(@yaml).to
|
109
|
+
expect(@yaml['message']).to eq @message
|
110
110
|
end
|
111
111
|
it 'includes the line numbers' do
|
112
|
-
@lines.
|
113
|
-
expect(@yaml).to match(/lines:[\s\d-]*- #{line}/)
|
114
|
-
end
|
112
|
+
expect(@yaml['lines']).to match_array @lines
|
115
113
|
end
|
116
114
|
end
|
117
115
|
|
@@ -125,20 +123,20 @@ describe SmellWarning do
|
|
125
123
|
lines: @lines,
|
126
124
|
message: @message,
|
127
125
|
parameters: @parameters)
|
128
|
-
@yaml = @warning.
|
126
|
+
@yaml = @warning.yaml_hash
|
129
127
|
end
|
130
128
|
|
131
129
|
it_should_behave_like 'common fields'
|
132
130
|
|
133
131
|
it 'includes the smell type' do
|
134
|
-
expect(@yaml).to
|
132
|
+
expect(@yaml['smell_type']).to eq @smell_type
|
135
133
|
end
|
136
134
|
it 'includes the source' do
|
137
|
-
expect(@yaml).to
|
135
|
+
expect(@yaml['source']).to eq @source
|
138
136
|
end
|
139
137
|
it 'includes the parameters' do
|
140
138
|
@parameters.each do |key, value|
|
141
|
-
expect(@yaml).to
|
139
|
+
expect(@yaml[key]).to eq value
|
142
140
|
end
|
143
141
|
end
|
144
142
|
end
|
@@ -8,35 +8,35 @@ describe BooleanParameter do
|
|
8
8
|
context 'parameter defaulted with boolean' do
|
9
9
|
context 'in a method' do
|
10
10
|
it 'reports a parameter defaulted to true' do
|
11
|
-
src = 'def cc(arga = true) end'
|
12
|
-
expect(src).to
|
11
|
+
src = 'def cc(arga = true); arga; end'
|
12
|
+
expect(src).to reek_of(:BooleanParameter, name: 'arga')
|
13
13
|
end
|
14
|
+
|
14
15
|
it 'reports a parameter defaulted to false' do
|
15
16
|
src = 'def cc(arga = false) end'
|
16
|
-
expect(src).to
|
17
|
+
expect(src).to reek_of(BooleanParameter, name: 'arga')
|
17
18
|
end
|
19
|
+
|
18
20
|
it 'reports two parameters defaulted to booleans' do
|
19
21
|
src = 'def cc(nowt, arga = true, argb = false, &blk) end'
|
20
|
-
expect(src).to
|
21
|
-
|
22
|
-
{ name: 'argb' })
|
22
|
+
expect(src).to reek_of(BooleanParameter, name: 'arga')
|
23
|
+
expect(src).to reek_of(BooleanParameter, name: 'argb')
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
27
|
context 'in a singleton method' do
|
27
28
|
it 'reports a parameter defaulted to true' do
|
28
29
|
src = 'def self.cc(arga = true) end'
|
29
|
-
expect(src).to
|
30
|
+
expect(src).to reek_of(BooleanParameter, name: 'arga')
|
30
31
|
end
|
31
32
|
it 'reports a parameter defaulted to false' do
|
32
33
|
src = 'def fred.cc(arga = false) end'
|
33
|
-
expect(src).to
|
34
|
+
expect(src).to reek_of(BooleanParameter, name: 'arga')
|
34
35
|
end
|
35
36
|
it 'reports two parameters defaulted to booleans' do
|
36
37
|
src = 'def Module.cc(nowt, arga = true, argb = false, &blk) end'
|
37
|
-
expect(src).to
|
38
|
-
|
39
|
-
{ name: 'argb' })
|
38
|
+
expect(src).to reek_of(BooleanParameter, name: 'arga')
|
39
|
+
expect(src).to reek_of(BooleanParameter, name: 'argb')
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -15,94 +15,94 @@ describe ControlParameter do
|
|
15
15
|
context 'parameter not used to determine code path' do
|
16
16
|
it 'does not report a ternary check on an ivar' do
|
17
17
|
src = 'def simple(arga) @ivar ? arga : 3 end'
|
18
|
-
expect(src).not_to
|
18
|
+
expect(src).not_to reek_of(ControlParameter)
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'does not report a ternary check on a lvar' do
|
22
22
|
src = 'def simple(arga) lvar = 27; lvar ? arga : @ivar end'
|
23
|
-
expect(src).not_to
|
23
|
+
expect(src).not_to reek_of(ControlParameter)
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'does not report when parameter is unused' do
|
27
27
|
src = 'def simple(arg) test = 1 end'
|
28
|
-
expect(src).not_to
|
28
|
+
expect(src).not_to reek_of(ControlParameter)
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'does not report when parameter is used inside conditional' do
|
32
32
|
src = 'def simple(arg) if true then puts arg end end'
|
33
|
-
expect(src).not_to
|
33
|
+
expect(src).not_to reek_of(ControlParameter)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
context 'parameter only used to determine code path' do
|
38
38
|
it 'reports a ternary check on a parameter' do
|
39
39
|
src = 'def simple(arga) arga ? @ivar : 3 end'
|
40
|
-
expect(src).to
|
40
|
+
expect(src).to reek_of(ControlParameter, name: 'arga')
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'reports a couple inside a block' do
|
44
44
|
src = 'def blocks(arg) @text.map { |blk| arg ? blk : "#{blk}" } end'
|
45
|
-
expect(src).to
|
45
|
+
expect(src).to reek_of(ControlParameter, name: 'arg')
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'reports on an if statement modifier' do
|
49
49
|
src = 'def simple(arg) args = {}; args.merge(\'a\' => \'A\') if arg end'
|
50
|
-
expect(src).to
|
50
|
+
expect(src).to reek_of(ControlParameter, name: 'arg')
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'reports on an unless statement modifier' do
|
54
54
|
src = 'def simple(arg) args = {}; args.merge(\'a\' => \'A\') unless arg end'
|
55
|
-
expect(src).to
|
55
|
+
expect(src).to reek_of(ControlParameter, name: 'arg')
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'reports on if control expression' do
|
59
59
|
src = 'def simple(arg) args = {}; if arg then args.merge(\'a\' => \'A\') end end'
|
60
|
-
expect(src).to
|
60
|
+
expect(src).to reek_of(ControlParameter, name: 'arg')
|
61
61
|
end
|
62
62
|
|
63
63
|
it 'reports on if control expression with &&' do
|
64
64
|
src = 'def simple(arg) if arg && true then puts "arg" end end'
|
65
|
-
expect(src).to
|
65
|
+
expect(src).to reek_of(ControlParameter, name: 'arg')
|
66
66
|
end
|
67
67
|
|
68
68
|
it 'reports on if control expression with preceding &&' do
|
69
69
|
src = 'def simple(arg) if true && arg then puts "arg" end end'
|
70
|
-
expect(src).to
|
70
|
+
expect(src).to reek_of(ControlParameter, name: 'arg')
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'reports on if control expression with two && conditions' do
|
74
74
|
src = 'def simple(a) ag = {}; if a && true && true then puts "2" end end'
|
75
|
-
expect(src).to
|
75
|
+
expect(src).to reek_of(ControlParameter, name: 'a')
|
76
76
|
end
|
77
77
|
|
78
78
|
it 'reports on if control expression with ||' do
|
79
79
|
src = 'def simple(arg) args = {}; if arg || true then puts "arg" end end'
|
80
|
-
expect(src).to
|
80
|
+
expect(src).to reek_of(ControlParameter, name: 'arg')
|
81
81
|
end
|
82
82
|
|
83
83
|
it 'reports on if control expression with or' do
|
84
84
|
src = 'def simple(arg) args = {}; if arg or true then puts "arg" end end'
|
85
|
-
expect(src).to
|
85
|
+
expect(src).to reek_of(ControlParameter, name: 'arg')
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'reports on if control expression with if' do
|
89
89
|
src = 'def simple(arg) args = {}; if (arg if true) then puts "arg" end end'
|
90
|
-
expect(src).to
|
90
|
+
expect(src).to reek_of(ControlParameter, name: 'arg')
|
91
91
|
end
|
92
92
|
|
93
93
|
it 'reports on && notation' do
|
94
94
|
src = 'def simple(arg) args = {}; arg && args.merge(\'a\' => \'A\') end'
|
95
|
-
expect(src).to
|
95
|
+
expect(src).to reek_of(ControlParameter, name: 'arg')
|
96
96
|
end
|
97
97
|
|
98
98
|
it 'reports on || notation' do
|
99
99
|
src = 'def simple(arg) args = {}; arg || args.merge(\'a\' => \'A\') end'
|
100
|
-
expect(src).to
|
100
|
+
expect(src).to reek_of(ControlParameter, name: 'arg')
|
101
101
|
end
|
102
102
|
|
103
103
|
it 'reports on case statement' do
|
104
104
|
src = 'def simple(arg) case arg when nil; nil when false; nil else nil end end'
|
105
|
-
expect(src).to
|
105
|
+
expect(src).to reek_of(ControlParameter, name: 'arg')
|
106
106
|
end
|
107
107
|
|
108
108
|
it 'reports on nested if statements that are both control parameters' do
|
@@ -114,7 +114,7 @@ describe ControlParameter do
|
|
114
114
|
end
|
115
115
|
end
|
116
116
|
EOS
|
117
|
-
expect(src).to
|
117
|
+
expect(src).to reek_of(ControlParameter, name: 'arg')
|
118
118
|
end
|
119
119
|
|
120
120
|
it 'reports on nested if statements where the inner if is a control parameter' do
|
@@ -126,32 +126,32 @@ describe ControlParameter do
|
|
126
126
|
end
|
127
127
|
end
|
128
128
|
EOS
|
129
|
-
expect(src).to
|
129
|
+
expect(src).to reek_of(ControlParameter, name: 'arg')
|
130
130
|
end
|
131
131
|
|
132
132
|
it 'reports on explicit comparison in the condition' do
|
133
133
|
src = 'def simple(arg) if arg == :foo then :foo else :bar end end'
|
134
|
-
expect(src).to
|
134
|
+
expect(src).to reek_of(ControlParameter)
|
135
135
|
end
|
136
136
|
|
137
137
|
it 'reports on explicit negative comparison in the condition' do
|
138
138
|
src = 'def simple(arg) if arg != :foo then :bar else :foo end end'
|
139
|
-
expect(src).to
|
139
|
+
expect(src).to reek_of(ControlParameter)
|
140
140
|
end
|
141
141
|
|
142
142
|
it 'reports when the argument is compared to a regexp' do
|
143
143
|
src = 'def simple(arg) if arg =~ /foo/ then :foo else :bar end end'
|
144
|
-
expect(src).to
|
144
|
+
expect(src).to reek_of(ControlParameter)
|
145
145
|
end
|
146
146
|
|
147
147
|
it 'reports when the argument is reverse-compared to a regexp' do
|
148
148
|
src = 'def simple(arg) if /foo/ =~ arg then :foo else :bar end end'
|
149
|
-
expect(src).to
|
149
|
+
expect(src).to reek_of(ControlParameter)
|
150
150
|
end
|
151
151
|
|
152
152
|
it 'reports when the argument is used in a complex regexp' do
|
153
153
|
src = 'def simple(arg) if /foo#{arg}/ =~ bar then :foo else :bar end end'
|
154
|
-
expect(src).to
|
154
|
+
expect(src).to reek_of(ControlParameter)
|
155
155
|
end
|
156
156
|
|
157
157
|
it 'reports when the argument is a block parameter' do
|
@@ -160,64 +160,64 @@ describe ControlParameter do
|
|
160
160
|
bar(blk || proc {})
|
161
161
|
end
|
162
162
|
EOS
|
163
|
-
expect(src).to
|
163
|
+
expect(src).to reek_of(ControlParameter)
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
167
167
|
context 'parameter used besides determining code path' do
|
168
168
|
it 'does not report on if conditional expression' do
|
169
169
|
src = 'def simple(arg) if arg then use(arg) else use(@other) end end'
|
170
|
-
expect(src).not_to
|
170
|
+
expect(src).not_to reek_of(ControlParameter)
|
171
171
|
end
|
172
172
|
|
173
173
|
it 'does not report on an if statement modifier' do
|
174
174
|
src = 'def simple(arg) args = {}; args.merge(\'a\' => arg) if arg end'
|
175
|
-
expect(src).not_to
|
175
|
+
expect(src).not_to reek_of(ControlParameter)
|
176
176
|
end
|
177
177
|
|
178
178
|
it 'does not report on an unless statement modifier' do
|
179
179
|
src = 'def simple(arg) args = {}; args.merge(\'a\' => arg) unless arg end'
|
180
|
-
expect(src).not_to
|
180
|
+
expect(src).not_to reek_of(ControlParameter)
|
181
181
|
end
|
182
182
|
|
183
183
|
it 'does not report on if control expression' do
|
184
184
|
src = 'def simple(arg) args = {}; if arg then args.merge(\'a\' => arg) end end'
|
185
|
-
expect(src).not_to
|
185
|
+
expect(src).not_to reek_of(ControlParameter)
|
186
186
|
end
|
187
187
|
|
188
188
|
it 'does not report on if control expression with &&' do
|
189
189
|
src = 'def simple(arg) if arg && true then puts arg end end'
|
190
|
-
expect(src).not_to
|
190
|
+
expect(src).not_to reek_of(ControlParameter)
|
191
191
|
end
|
192
192
|
|
193
193
|
it 'does not report on && notation' do
|
194
194
|
src = 'def simple(arg) args = {}; arg && args.merge(\'a\' => arg) end'
|
195
|
-
expect(src).not_to
|
195
|
+
expect(src).not_to reek_of(ControlParameter)
|
196
196
|
end
|
197
197
|
|
198
198
|
it 'does not report on || notation' do
|
199
199
|
src = 'def simple(arg) args = {}; arg || args.merge(\'a\' => arg) end'
|
200
|
-
expect(src).not_to
|
200
|
+
expect(src).not_to reek_of(ControlParameter)
|
201
201
|
end
|
202
202
|
|
203
203
|
it 'does not report when parameter is used outside conditional' do
|
204
204
|
src = 'def simple(arg) puts arg; if arg then @a = 1 end end'
|
205
|
-
expect(src).not_to
|
205
|
+
expect(src).not_to reek_of(ControlParameter)
|
206
206
|
end
|
207
207
|
|
208
208
|
it 'does not report when parameter is used as a method call argument in a condition' do
|
209
209
|
src = 'def simple(arg) if foo(arg) then @a = 1 end end'
|
210
|
-
expect(src).not_to
|
210
|
+
expect(src).not_to reek_of(ControlParameter)
|
211
211
|
end
|
212
212
|
|
213
213
|
it 'does not report when parameter is used as a method call receiver in a condition' do
|
214
214
|
src = 'def simple(arg) if arg.foo? then @a = 1 end end'
|
215
|
-
expect(src).not_to
|
215
|
+
expect(src).not_to reek_of(ControlParameter)
|
216
216
|
end
|
217
217
|
|
218
218
|
it 'does not report when the argument is a hash on which we access a key' do
|
219
219
|
src = 'def simple(arg) if arg[\'a\'] then puts \'a\' else puts \'b\' end end'
|
220
|
-
expect(src).not_to
|
220
|
+
expect(src).not_to reek_of ControlParameter
|
221
221
|
end
|
222
222
|
|
223
223
|
it 'does not report when used in first conditional but not second' do
|
@@ -231,7 +231,7 @@ describe ControlParameter do
|
|
231
231
|
end
|
232
232
|
end
|
233
233
|
EOS
|
234
|
-
expect(src).not_to
|
234
|
+
expect(src).not_to reek_of(ControlParameter)
|
235
235
|
end
|
236
236
|
|
237
237
|
it 'does not report when used in second conditional but not first' do
|
@@ -245,7 +245,7 @@ describe ControlParameter do
|
|
245
245
|
end
|
246
246
|
end
|
247
247
|
EOS
|
248
|
-
expect(src).not_to
|
248
|
+
expect(src).not_to reek_of(ControlParameter)
|
249
249
|
end
|
250
250
|
|
251
251
|
it 'does not report when used in body of control flow operator' do
|
@@ -260,7 +260,7 @@ describe ControlParameter do
|
|
260
260
|
qux or quuz(arg)
|
261
261
|
end
|
262
262
|
EOS
|
263
|
-
expect(src).not_to
|
263
|
+
expect(src).not_to reek_of(ControlParameter)
|
264
264
|
end
|
265
265
|
end
|
266
266
|
|