reek 2.0.4 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +13 -0
- data/.rubocop.yml +66 -0
- data/.ruby-gemset +1 -0
- data/.travis.yml +25 -0
- data/CHANGELOG +6 -0
- data/CONTRIBUTING.md +106 -0
- data/Gemfile +14 -0
- data/README.md +16 -21
- data/bin/reek +2 -2
- data/config/cucumber.yml +3 -0
- data/config/defaults.reek +1 -1
- data/features/command_line_interface/smell_selection.feature +4 -8
- data/features/command_line_interface/smells_count.feature +25 -32
- data/features/command_line_interface/stdin.feature +2 -2
- data/features/configuration_files/masking_smells.feature +30 -41
- data/features/configuration_files/overrides_defaults.feature +5 -3
- data/features/configuration_loading.feature +26 -23
- data/features/programmatic_access.feature +24 -0
- data/features/rake_task/rake_task.feature +25 -22
- data/features/reports/json.feature +24 -26
- data/features/reports/reports.feature +77 -103
- data/features/reports/yaml.feature +26 -20
- data/features/ruby_api/api.feature +4 -3
- data/features/samples.feature +21 -20
- data/features/step_definitions/.rubocop.yml +5 -0
- data/features/step_definitions/reek_steps.rb +16 -28
- data/features/step_definitions/sample_file_steps.rb +158 -0
- data/features/support/env.rb +16 -27
- data/lib/reek.rb +3 -3
- data/lib/reek/cli/application.rb +4 -4
- data/lib/reek/cli/command.rb +1 -1
- data/lib/reek/cli/input.rb +2 -4
- data/lib/reek/cli/option_interpreter.rb +9 -9
- data/lib/reek/cli/options.rb +5 -4
- data/lib/reek/cli/reek_command.rb +3 -3
- data/lib/reek/cli/report/formatter.rb +2 -2
- data/lib/reek/cli/report/heading_formatter.rb +1 -1
- data/lib/reek/cli/report/location_formatter.rb +1 -1
- data/lib/reek/cli/report/report.rb +4 -4
- data/lib/reek/configuration/app_configuration.rb +1 -1
- data/lib/reek/configuration/configuration_file_finder.rb +17 -32
- data/lib/reek/core/code_context.rb +1 -1
- data/lib/reek/core/method_context.rb +6 -2
- data/lib/reek/core/module_context.rb +2 -2
- data/lib/reek/core/singleton_method_context.rb +1 -1
- data/lib/reek/core/smell_repository.rb +3 -2
- data/lib/reek/core/tree_walker.rb +4 -4
- data/lib/reek/examiner.rb +4 -4
- data/lib/reek/smells/attribute.rb +3 -3
- data/lib/reek/smells/boolean_parameter.rb +2 -2
- data/lib/reek/smells/class_variable.rb +2 -2
- data/lib/reek/smells/control_parameter.rb +2 -2
- data/lib/reek/smells/data_clump.rb +2 -3
- data/lib/reek/smells/duplicate_method_call.rb +2 -2
- data/lib/reek/smells/feature_envy.rb +6 -2
- data/lib/reek/smells/irresponsible_module.rb +3 -3
- data/lib/reek/smells/long_parameter_list.rb +3 -3
- data/lib/reek/smells/long_yield_list.rb +2 -2
- data/lib/reek/smells/module_initialize.rb +2 -2
- data/lib/reek/smells/nested_iterators.rb +2 -2
- data/lib/reek/smells/nil_check.rb +2 -2
- data/lib/reek/smells/prima_donna_method.rb +2 -2
- data/lib/reek/smells/repeated_conditional.rb +3 -2
- data/lib/reek/smells/smell_detector.rb +2 -2
- data/lib/reek/smells/too_many_instance_variables.rb +2 -2
- data/lib/reek/smells/too_many_methods.rb +2 -2
- data/lib/reek/smells/too_many_statements.rb +2 -2
- data/lib/reek/smells/uncommunicative_method_name.rb +2 -2
- data/lib/reek/smells/uncommunicative_module_name.rb +2 -2
- data/lib/reek/smells/uncommunicative_parameter_name.rb +2 -2
- data/lib/reek/smells/uncommunicative_variable_name.rb +2 -2
- data/lib/reek/smells/unused_parameters.rb +2 -2
- data/lib/reek/smells/utility_function.rb +8 -9
- data/lib/reek/source/ast_node.rb +1 -1
- data/lib/reek/source/ast_node_class_map.rb +6 -6
- data/lib/reek/source/sexp_extensions.rb +11 -2
- data/lib/reek/source/source_code.rb +10 -2
- data/lib/reek/source/source_locator.rb +1 -3
- data/lib/reek/source/source_repository.rb +3 -4
- data/lib/reek/source/tree_dresser.rb +2 -2
- data/lib/reek/spec.rb +3 -3
- data/lib/reek/spec/should_reek.rb +3 -3
- data/lib/reek/spec/should_reek_of.rb +1 -1
- data/lib/reek/spec/should_reek_only_of.rb +3 -3
- data/lib/reek/version.rb +1 -1
- data/reek.gemspec +18 -24
- data/spec/factories/factories.rb +1 -1
- data/spec/gem/updates_spec.rb +1 -1
- data/spec/gem/yard_spec.rb +1 -1
- data/spec/quality/reek_source_spec.rb +1 -1
- data/spec/reek/cli/html_report_spec.rb +6 -9
- data/spec/reek/cli/json_report_spec.rb +6 -6
- data/spec/reek/cli/option_interperter_spec.rb +5 -5
- data/spec/reek/cli/text_report_spec.rb +16 -19
- data/spec/reek/cli/yaml_report_spec.rb +7 -10
- data/spec/reek/configuration/app_configuration_spec.rb +23 -25
- data/spec/reek/configuration/configuration_file_finder_spec.rb +46 -21
- data/spec/reek/core/code_context_spec.rb +17 -19
- data/spec/reek/core/method_context_spec.rb +15 -14
- data/spec/reek/core/module_context_spec.rb +5 -7
- data/spec/reek/core/object_refs_spec.rb +4 -6
- data/spec/reek/core/singleton_method_context_spec.rb +5 -7
- data/spec/reek/core/smell_configuration_spec.rb +5 -7
- data/spec/reek/core/smell_repository_spec.rb +8 -8
- data/spec/reek/core/stop_context_spec.rb +4 -7
- data/spec/reek/core/tree_walker_spec.rb +5 -7
- data/spec/reek/core/warning_collector_spec.rb +5 -7
- data/spec/reek/examiner_spec.rb +10 -12
- data/spec/reek/smell_warning_spec.rb +7 -9
- data/spec/reek/smells/attribute_spec.rb +6 -6
- data/spec/reek/smells/boolean_parameter_spec.rb +4 -4
- data/spec/reek/smells/class_variable_spec.rb +6 -6
- data/spec/reek/smells/control_parameter_spec.rb +4 -4
- data/spec/reek/smells/data_clump_spec.rb +4 -4
- data/spec/reek/smells/duplicate_method_call_spec.rb +6 -6
- data/spec/reek/smells/feature_envy_spec.rb +9 -10
- data/spec/reek/smells/irresponsible_module_spec.rb +7 -7
- data/spec/reek/smells/long_parameter_list_spec.rb +5 -5
- data/spec/reek/smells/long_yield_list_spec.rb +5 -5
- data/spec/reek/smells/module_initialize_spec.rb +3 -3
- data/spec/reek/smells/nested_iterators_spec.rb +4 -4
- data/spec/reek/smells/nil_check_spec.rb +5 -5
- data/spec/reek/smells/prima_donna_method_spec.rb +7 -4
- data/spec/reek/smells/repeated_conditional_spec.rb +12 -11
- data/spec/reek/smells/smell_detector_shared.rb +4 -5
- data/spec/reek/smells/too_many_instance_variables_spec.rb +4 -4
- data/spec/reek/smells/too_many_methods_spec.rb +11 -7
- data/spec/reek/smells/too_many_statements_spec.rb +6 -5
- data/spec/reek/smells/uncommunicative_method_name_spec.rb +4 -4
- data/spec/reek/smells/uncommunicative_module_name_spec.rb +7 -7
- data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +5 -5
- data/spec/reek/smells/uncommunicative_variable_name_spec.rb +9 -6
- data/spec/reek/smells/unused_parameters_spec.rb +3 -3
- data/spec/reek/smells/utility_function_spec.rb +41 -37
- data/spec/reek/source/code_comment_spec.rb +19 -17
- data/spec/reek/source/object_source_spec.rb +1 -3
- data/spec/reek/source/reference_collector_spec.rb +5 -6
- data/spec/reek/source/sexp_extensions_spec.rb +9 -11
- data/spec/reek/source/sexp_formatter_spec.rb +7 -8
- data/spec/reek/source/sexp_node_spec.rb +3 -5
- data/spec/reek/source/source_code_spec.rb +9 -9
- data/spec/reek/source/tree_dresser_spec.rb +4 -6
- data/spec/reek/spec/should_reek_of_spec.rb +11 -10
- data/spec/reek/spec/should_reek_only_of_spec.rb +4 -7
- data/spec/reek/spec/should_reek_spec.rb +4 -7
- data/spec/samples/{overrides/masked/lower.reek → masked_by_dotfile/.reek} +3 -1
- data/spec/spec_helper.rb +4 -4
- data/tasks/develop.rake +1 -1
- data/tasks/reek.rake +1 -1
- metadata +72 -86
- data/features/support/hooks.rb +0 -15
- data/lib/reek/source.rb +0 -16
- data/lib/reek/source/core_extras.rb +0 -46
- data/lib/reek/source/source_file.rb +0 -16
- data/spec/samples/config/allow_duplication.reek +0 -3
- data/spec/samples/config/deeper_nested_iterators.reek +0 -3
- data/spec/samples/configuration_loading/minimal_dirty.rb +0 -4
- data/spec/samples/configuration_loading/reek-test-run-disable_smells.reek +0 -7
- data/spec/samples/configuration_loading/reek-test-run-enable_smells.reek +0 -7
- data/spec/samples/corrupt_config_file/corrupt.reek +0 -1
- data/spec/samples/corrupt_config_file/dirty.rb +0 -8
- data/spec/samples/demo/demo.rb +0 -8
- data/spec/samples/empty_config_file/dirty.rb +0 -8
- data/spec/samples/empty_config_file/empty.reek +0 -0
- data/spec/samples/inline_config/dirty.rb +0 -16
- data/spec/samples/inline_config/masked.reek +0 -7
- data/spec/samples/mask_some/dirty.rb +0 -8
- data/spec/samples/mask_some/some.reek +0 -8
- data/spec/samples/masked/dirty.rb +0 -8
- data/spec/samples/masked/masked.reek +0 -5
- data/spec/samples/minimal_smelly_and_masked/config.reek +0 -7
- data/spec/samples/minimal_smelly_and_masked/minimal_dirty.rb +0 -4
- data/spec/samples/mixed_results/clean_one.rb +0 -7
- data/spec/samples/mixed_results/clean_three.rb +0 -7
- data/spec/samples/mixed_results/clean_two.rb +0 -7
- data/spec/samples/mixed_results/dirty_one.rb +0 -8
- data/spec/samples/mixed_results/dirty_two.rb +0 -8
- data/spec/samples/not_quite_masked/dirty.rb +0 -8
- data/spec/samples/not_quite_masked/masked.reek +0 -5
- data/spec/samples/not_quite_masked/smelly.rb +0 -3
- data/spec/samples/one_smelly_file/dirty.rb +0 -3
- data/spec/samples/overrides/masked/dirty.rb +0 -8
- data/spec/samples/overrides/upper.reek +0 -5
- data/spec/samples/overrides_defaults/camel_case.rb +0 -14
- data/spec/samples/overrides_defaults/config.reek +0 -6
- data/spec/samples/standard_smelly/dirty.rb +0 -8
- data/spec/samples/standard_smelly/minimal_dirty.rb +0 -4
- data/spec/samples/three_smelly_files/dirty_one.rb +0 -3
- data/spec/samples/three_smelly_files/dirty_three.rb +0 -5
- data/spec/samples/three_smelly_files/dirty_two.rb +0 -4
@@ -1,14 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/reek/core/method_context'
|
3
|
+
require_relative '../../../lib/reek/core/stop_context'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
describe MethodContext, 'matching' do
|
5
|
+
describe Reek::Core::MethodContext, 'matching' do
|
8
6
|
before :each do
|
9
7
|
exp = double('exp').as_null_object
|
10
8
|
expect(exp).to receive(:full_name).at_least(:once).and_return('mod')
|
11
|
-
@element = MethodContext.new(StopContext.new, exp)
|
9
|
+
@element = Reek::Core::MethodContext.new(Reek::Core::StopContext.new, exp)
|
12
10
|
end
|
13
11
|
|
14
12
|
it 'should recognise itself in a collection of names' do
|
@@ -22,33 +20,36 @@ describe MethodContext, 'matching' do
|
|
22
20
|
end
|
23
21
|
end
|
24
22
|
|
25
|
-
describe MethodContext do
|
23
|
+
describe Reek::Core::MethodContext do
|
26
24
|
it 'should record ivars as refs to self' do
|
27
|
-
|
25
|
+
sexp = s(:def, :feed, s(:args), nil)
|
26
|
+
mctx = Reek::Core::MethodContext.new(Reek::Core::StopContext.new, sexp)
|
28
27
|
expect(mctx.envious_receivers).to eq([])
|
29
28
|
mctx.record_call_to(s(:send, s(:ivar, :@cow), :feed_to))
|
30
29
|
expect(mctx.envious_receivers).to eq([])
|
31
30
|
end
|
32
31
|
|
33
32
|
it 'should count calls to self' do
|
34
|
-
|
33
|
+
sexp = s(:def, :equals, s(:args), nil)
|
34
|
+
mctx = Reek::Core::MethodContext.new(Reek::Core::StopContext.new, sexp)
|
35
35
|
mctx.refs.record_reference_to([:lvar, :other])
|
36
36
|
mctx.record_call_to(s(:send, s(:self), :thing))
|
37
37
|
expect(mctx.envious_receivers).to be_empty
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'should recognise a call on self' do
|
41
|
-
|
41
|
+
sexp = s(:def, :deep, s(:args), nil)
|
42
|
+
mc = Reek::Core::MethodContext.new(Reek::Core::StopContext.new, sexp)
|
42
43
|
mc.record_call_to(s(:send, s(:lvar, :text), :each, s(:arglist)))
|
43
44
|
mc.record_call_to(s(:send, nil, :shelve, s(:arglist)))
|
44
45
|
expect(mc.envious_receivers).to be_empty
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
48
|
-
describe MethodParameters, 'default assignments' do
|
49
|
+
describe Reek::Core::MethodParameters, 'default assignments' do
|
49
50
|
def assignments_from(src)
|
50
|
-
exp = src.
|
51
|
-
ctx = MethodContext.new(StopContext.new, exp)
|
51
|
+
exp = Reek::Source::SourceCode.from(src).syntax_tree
|
52
|
+
ctx = Reek::Core::MethodContext.new(Reek::Core::StopContext.new, exp)
|
52
53
|
ctx.parameters.default_assignments
|
53
54
|
end
|
54
55
|
|
@@ -1,10 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/reek/core/module_context'
|
3
|
+
require_relative '../../../lib/reek/core/stop_context'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
describe ModuleContext do
|
5
|
+
describe Reek::Core::ModuleContext do
|
8
6
|
it 'should report module name for smell in method' do
|
9
7
|
expect('
|
10
8
|
module Fred
|
@@ -21,7 +19,7 @@ module Fred
|
|
21
19
|
end
|
22
20
|
end
|
23
21
|
|
24
|
-
describe ModuleContext do
|
22
|
+
describe Reek::Core::ModuleContext do
|
25
23
|
it 'should recognise global constant' do
|
26
24
|
expect('# module for test
|
27
25
|
module ::Global
|
@@ -1,11 +1,9 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/reek/core/object_refs'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
describe ObjectRefs do
|
4
|
+
describe Reek::Core::ObjectRefs do
|
7
5
|
before(:each) do
|
8
|
-
@refs = ObjectRefs.new
|
6
|
+
@refs = Reek::Core::ObjectRefs.new
|
9
7
|
end
|
10
8
|
|
11
9
|
context 'when empty' do
|
@@ -1,9 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/reek/core/module_context'
|
3
|
+
require_relative '../../../lib/reek/core/singleton_method_context'
|
4
|
+
require_relative '../../../lib/reek/core/stop_context'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
describe SingletonMethodContext do
|
6
|
+
describe Reek::Core::SingletonMethodContext do
|
9
7
|
end
|
@@ -1,11 +1,9 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/reek/core/smell_configuration'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
describe SmellConfiguration do
|
4
|
+
describe Reek::Core::SmellConfiguration do
|
7
5
|
it 'returns the default value when key not found' do
|
8
|
-
cf = SmellConfiguration.new({})
|
6
|
+
cf = Reek::Core::SmellConfiguration.new({})
|
9
7
|
expect(cf.value('fred', nil, 27)).to eq(27)
|
10
8
|
end
|
11
9
|
|
@@ -14,7 +12,7 @@ describe SmellConfiguration do
|
|
14
12
|
@base_config = { 'enabled' => true, 'exclude' => [],
|
15
13
|
'reject' => [/^.$/, /[0-9]$/, /[A-Z]/],
|
16
14
|
'accept' => ['_'] }
|
17
|
-
@smell_config = SmellConfiguration.new(@base_config)
|
15
|
+
@smell_config = Reek::Core::SmellConfiguration.new(@base_config)
|
18
16
|
end
|
19
17
|
|
20
18
|
it { expect(@smell_config.merge!({})).to eq(@base_config) }
|
@@ -1,17 +1,17 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/reek/core/smell_repository'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
describe SmellRepository do
|
4
|
+
describe Reek::Core::SmellRepository do
|
7
5
|
describe '.smell_types' do
|
6
|
+
let(:smell_types) { Reek::Core::SmellRepository.smell_types }
|
7
|
+
|
8
8
|
it 'should include existing smell_types' do
|
9
|
-
expect(
|
10
|
-
expect(
|
9
|
+
expect(smell_types).to include(Reek::Smells::IrresponsibleModule)
|
10
|
+
expect(smell_types).to include(Reek::Smells::TooManyStatements)
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'should exclude certain smell_types' do
|
14
|
-
expect(
|
14
|
+
expect(smell_types).to_not include(Reek::Smells::SmellDetector)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -1,12 +1,9 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/reek/core/stop_context'
|
3
3
|
|
4
|
-
|
5
|
-
include Reek::Core
|
6
|
-
|
7
|
-
describe StopContext do
|
4
|
+
describe Reek::Core::StopContext do
|
8
5
|
before :each do
|
9
|
-
@stop = StopContext.new
|
6
|
+
@stop = Reek::Core::StopContext.new
|
10
7
|
end
|
11
8
|
|
12
9
|
context 'full_name' do
|
@@ -1,9 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/reek/core/tree_walker'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
describe TreeWalker, 'with no method definitions' do
|
4
|
+
describe Reek::Core::TreeWalker, 'with no method definitions' do
|
7
5
|
it 'reports no problems for empty source code' do
|
8
6
|
expect('').not_to reek
|
9
7
|
end
|
@@ -13,14 +11,14 @@ class Fred; end').not_to reek
|
|
13
11
|
end
|
14
12
|
end
|
15
13
|
|
16
|
-
describe TreeWalker, 'with a global method definition' do
|
14
|
+
describe Reek::Core::TreeWalker, 'with a global method definition' do
|
17
15
|
it 'reports no problems for simple method' do
|
18
16
|
src = 'def Outermost::fred() true; end'
|
19
17
|
expect(src).not_to reek
|
20
18
|
end
|
21
19
|
end
|
22
20
|
|
23
|
-
describe TreeWalker, 'when a yield is the receiver' do
|
21
|
+
describe Reek::Core::TreeWalker, 'when a yield is the receiver' do
|
24
22
|
it 'reports no problems' do
|
25
23
|
src = <<EOS
|
26
24
|
def values(*args)
|
@@ -1,12 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/reek/core/warning_collector'
|
3
|
+
require_relative '../../../lib/reek/smell_warning'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
describe WarningCollector do
|
5
|
+
describe Reek::Core::WarningCollector do
|
8
6
|
before(:each) do
|
9
|
-
@collector = WarningCollector.new
|
7
|
+
@collector = Reek::Core::WarningCollector.new
|
10
8
|
end
|
11
9
|
|
12
10
|
context 'when empty' do
|
data/spec/reek/examiner_spec.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
include Reek
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
require_relative '../../lib/reek/examiner'
|
5
3
|
|
6
4
|
shared_examples_for 'no smells found' do
|
7
5
|
it 'is not smelly' do
|
@@ -24,14 +22,14 @@ shared_examples_for 'one smell found' do
|
|
24
22
|
end
|
25
23
|
end
|
26
24
|
|
27
|
-
describe Examiner do
|
25
|
+
describe Reek::Examiner do
|
28
26
|
before :each do
|
29
27
|
@expected_first_smell = 'NestedIterators'
|
30
28
|
end
|
31
29
|
|
32
30
|
context 'with a fragrant String' do
|
33
31
|
before :each do
|
34
|
-
@examiner = Examiner.new('def good() true; end')
|
32
|
+
@examiner = Reek::Examiner.new('def good() true; end')
|
35
33
|
end
|
36
34
|
|
37
35
|
it_should_behave_like 'no smells found'
|
@@ -39,7 +37,7 @@ describe Examiner do
|
|
39
37
|
|
40
38
|
context 'with a smelly String' do
|
41
39
|
before :each do
|
42
|
-
@examiner = Examiner.new('def fine() y = 4; end')
|
40
|
+
@examiner = Reek::Examiner.new('def fine() y = 4; end')
|
43
41
|
@expected_first_smell = 'UncommunicativeName'
|
44
42
|
end
|
45
43
|
|
@@ -55,7 +53,7 @@ describe Examiner do
|
|
55
53
|
|
56
54
|
before :each do
|
57
55
|
smelly_dir = Dir['spec/samples/all_but_one_masked/*.rb']
|
58
|
-
@examiner = Examiner.new(smelly_dir)
|
56
|
+
@examiner = Reek::Examiner.new(smelly_dir)
|
59
57
|
end
|
60
58
|
|
61
59
|
it_should_behave_like 'one smell found'
|
@@ -64,7 +62,7 @@ describe Examiner do
|
|
64
62
|
context 'with a fragrant Dir' do
|
65
63
|
before :each do
|
66
64
|
clean_dir = Dir['spec/samples/three_clean_files/*.rb']
|
67
|
-
@examiner = Examiner.new(clean_dir)
|
65
|
+
@examiner = Reek::Examiner.new(clean_dir)
|
68
66
|
end
|
69
67
|
|
70
68
|
it_should_behave_like 'no smells found'
|
@@ -79,7 +77,7 @@ describe Examiner do
|
|
79
77
|
|
80
78
|
before :each do
|
81
79
|
smelly_dir = Dir['spec/samples/masked_by_dotfile/*.rb']
|
82
|
-
@examiner = Examiner.new(smelly_dir)
|
80
|
+
@examiner = Reek::Examiner.new(smelly_dir)
|
83
81
|
end
|
84
82
|
|
85
83
|
it_should_behave_like 'one smell found'
|
@@ -94,7 +92,7 @@ describe Examiner do
|
|
94
92
|
|
95
93
|
before :each do
|
96
94
|
smelly_file = File.new(Dir['spec/samples/all_but_one_masked/d*.rb'][0])
|
97
|
-
@examiner = Examiner.new(smelly_file)
|
95
|
+
@examiner = Reek::Examiner.new(smelly_file)
|
98
96
|
end
|
99
97
|
|
100
98
|
it_should_behave_like 'one smell found'
|
@@ -103,7 +101,7 @@ describe Examiner do
|
|
103
101
|
context 'with a fragrant File' do
|
104
102
|
before :each do
|
105
103
|
clean_file = File.new(Dir['spec/samples/three_clean_files/*.rb'][0])
|
106
|
-
@examiner = Examiner.new(clean_file)
|
104
|
+
@examiner = Reek::Examiner.new(clean_file)
|
107
105
|
end
|
108
106
|
|
109
107
|
it_should_behave_like 'no smells found'
|
@@ -1,9 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
require_relative '../../lib/reek/smell_warning'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
describe SmellWarning do
|
4
|
+
describe Reek::SmellWarning do
|
7
5
|
let(:duplication_detector) { build(:smell_detector, smell_type: 'DuplicateMethodCall') }
|
8
6
|
let(:feature_envy_detector) { build(:smell_detector, smell_type: 'FeatureEnvy') }
|
9
7
|
let(:utility_function_detector) { build(:smell_detector, smell_type: 'UtilityFunction') }
|
@@ -119,10 +117,10 @@ describe SmellWarning do
|
|
119
117
|
@smell_type = 'FeatureEnvy'
|
120
118
|
@parameters = { 'one' => 34, 'two' => 'second' }
|
121
119
|
@detector = Reek::Smells::FeatureEnvy.new @source
|
122
|
-
@warning = SmellWarning.new(@detector, context: @context_name,
|
123
|
-
|
124
|
-
|
125
|
-
|
120
|
+
@warning = Reek::SmellWarning.new(@detector, context: @context_name,
|
121
|
+
lines: @lines,
|
122
|
+
message: @message,
|
123
|
+
parameters: @parameters)
|
126
124
|
@yaml = @warning.yaml_hash
|
127
125
|
end
|
128
126
|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/reek/smells/attribute'
|
3
|
+
require_relative '../../../lib/reek/core/module_context'
|
4
|
+
require_relative 'smell_detector_shared'
|
5
5
|
|
6
6
|
describe Reek::Smells::Attribute do
|
7
7
|
before :each do
|
@@ -14,7 +14,7 @@ describe Reek::Smells::Attribute do
|
|
14
14
|
context 'with no attributes' do
|
15
15
|
it 'records nothing in the module' do
|
16
16
|
src = 'module Fred; end'
|
17
|
-
ctx = Reek::Core::CodeContext.new(nil, src.
|
17
|
+
ctx = Reek::Core::CodeContext.new(nil, Reek::Source::SourceCode.from(src).syntax_tree)
|
18
18
|
expect(@detector.examine_context(ctx)).to be_empty
|
19
19
|
end
|
20
20
|
end
|
@@ -26,7 +26,7 @@ describe Reek::Smells::Attribute do
|
|
26
26
|
|
27
27
|
shared_examples_for 'one attribute found' do
|
28
28
|
before :each do
|
29
|
-
ctx = Reek::Core::CodeContext.new(nil, @src.
|
29
|
+
ctx = Reek::Core::CodeContext.new(nil, Reek::Source::SourceCode.from(@src).syntax_tree)
|
30
30
|
@smells = @detector.examine_context(ctx)
|
31
31
|
end
|
32
32
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/reek/smells/boolean_parameter'
|
3
|
+
require_relative 'smell_detector_shared'
|
4
4
|
|
5
5
|
describe Reek::Smells::BooleanParameter do
|
6
6
|
context 'parameter defaulted with boolean' do
|
@@ -49,7 +49,7 @@ describe Reek::Smells::BooleanParameter do
|
|
49
49
|
|
50
50
|
it 'reports the fields correctly' do
|
51
51
|
src = 'def cc(arga = true) end'
|
52
|
-
ctx = Reek::Core::MethodContext.new(nil, src.
|
52
|
+
ctx = Reek::Core::MethodContext.new(nil, Reek::Source::SourceCode.from(src).syntax_tree)
|
53
53
|
@detector.examine(ctx)
|
54
54
|
smells = @detector.smells_found.to_a
|
55
55
|
expect(smells.length).to eq(1)
|
@@ -1,7 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/reek/smells/class_variable'
|
3
|
+
require_relative '../../../lib/reek/core/module_context'
|
4
|
+
require_relative 'smell_detector_shared'
|
5
5
|
|
6
6
|
describe Reek::Smells::ClassVariable do
|
7
7
|
before :each do
|
@@ -27,7 +27,7 @@ describe Reek::Smells::ClassVariable do
|
|
27
27
|
context 'with one class variable' do
|
28
28
|
shared_examples_for 'one variable found' do
|
29
29
|
before :each do
|
30
|
-
ast = @src.
|
30
|
+
ast = Reek::Source::SourceCode.from(@src).syntax_tree
|
31
31
|
@smells = @detector.examine_context(Reek::Core::CodeContext.new(nil, ast))
|
32
32
|
end
|
33
33
|
|
@@ -99,7 +99,7 @@ describe Reek::Smells::ClassVariable do
|
|
99
99
|
#{@class_variable} = {}
|
100
100
|
end
|
101
101
|
EOS
|
102
|
-
ctx = Reek::Core::CodeContext.new(nil, src.
|
102
|
+
ctx = Reek::Core::CodeContext.new(nil, Reek::Source::SourceCode.from(src).syntax_tree)
|
103
103
|
@warning = @detector.examine_context(ctx)[0]
|
104
104
|
expect(@warning.source).to eq(@source_name)
|
105
105
|
expect(@warning.smell_category).to eq(described_class.smell_category)
|
@@ -1,6 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/reek/smells/control_parameter'
|
3
|
+
require_relative 'smell_detector_shared'
|
4
4
|
|
5
5
|
describe Reek::Smells::ControlParameter do
|
6
6
|
before(:each) do
|
@@ -272,7 +272,7 @@ describe Reek::Smells::ControlParameter do
|
|
272
272
|
puts "hello" if arg
|
273
273
|
end
|
274
274
|
EOS
|
275
|
-
ctx = Reek::Core::MethodContext.new(nil, src.
|
275
|
+
ctx = Reek::Core::MethodContext.new(nil, Reek::Source::SourceCode.from(src).syntax_tree)
|
276
276
|
smells = @detector.examine(ctx)
|
277
277
|
expect(smells.length).to eq(1)
|
278
278
|
@warning = smells[0]
|
@@ -1,6 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/reek/smells/data_clump'
|
3
|
+
require_relative 'smell_detector_shared'
|
4
4
|
|
5
5
|
shared_examples_for 'a data clump detector' do
|
6
6
|
it 'does not report small parameter sets' do
|
@@ -25,7 +25,7 @@ shared_examples_for 'a data clump detector' do
|
|
25
25
|
def third(pa, pb) pa - pb + @fred; end
|
26
26
|
end
|
27
27
|
EOS
|
28
|
-
ctx = Reek::Core::ModuleContext.new(nil, @src.
|
28
|
+
ctx = Reek::Core::ModuleContext.new(nil, Reek::Source::SourceCode.from(@src).syntax_tree)
|
29
29
|
detector = build(:smell_detector, smell_type: :DataClump)
|
30
30
|
@smells = detector.examine_context(ctx)
|
31
31
|
end
|