reek 2.0.4 → 3.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/.gitignore +13 -0
- data/.rubocop.yml +47 -0
- data/.travis.yml +31 -0
- data/.yardopts +3 -6
- data/CHANGELOG +24 -0
- data/CONTRIBUTING.md +111 -0
- data/Gemfile +16 -0
- data/README.md +112 -59
- data/bin/reek +2 -2
- data/config/cucumber.yml +3 -0
- data/config/defaults.reek +0 -1
- data/docs/API.md +79 -0
- data/docs/Attribute.md +43 -0
- data/docs/Basic-Smell-Options.md +44 -0
- data/docs/Boolean-Parameter.md +52 -0
- data/docs/Class-Variable.md +40 -0
- data/docs/Code-Smells.md +34 -0
- data/docs/Command-Line-Options.md +84 -0
- data/docs/Configuration-Files.md +49 -0
- data/docs/Control-Couple.md +22 -0
- data/docs/Control-Parameter.md +29 -0
- data/docs/Data-Clump.md +44 -0
- data/docs/Duplicate-Method-Call.md +49 -0
- data/docs/Feature-Envy.md +49 -0
- data/docs/How-reek-works-internally.md +114 -0
- data/docs/Irresponsible-Module.md +39 -0
- data/docs/Large-Class.md +20 -0
- data/docs/Long-Parameter-List.md +38 -0
- data/docs/Long-Yield-List.md +36 -0
- data/docs/Module-Initialize.md +62 -0
- data/docs/Nested-Iterators.md +38 -0
- data/docs/Nil-Check.md +39 -0
- data/docs/Prima-Donna-Method.md +53 -0
- data/docs/RSpec-matchers.md +137 -0
- data/docs/Rake-Task.md +58 -0
- data/docs/Reek-Driven-Development.md +37 -0
- data/docs/Repeated-Conditional.md +44 -0
- data/docs/Simulated-Polymorphism.md +16 -0
- data/docs/Smell-Suppression.md +32 -0
- data/docs/Too-Many-Instance-Variables.md +43 -0
- data/docs/Too-Many-Methods.md +55 -0
- data/docs/Too-Many-Statements.md +50 -0
- data/docs/Uncommunicative-Method-Name.md +24 -0
- data/docs/Uncommunicative-Module-Name.md +23 -0
- data/docs/Uncommunicative-Name.md +16 -0
- data/docs/Uncommunicative-Parameter-Name.md +24 -0
- data/docs/Uncommunicative-Variable-Name.md +24 -0
- data/docs/Unused-Parameters.md +27 -0
- data/docs/Utility-Function.md +44 -0
- data/docs/Versioning-Policy.md +7 -0
- data/docs/YAML-Reports.md +111 -0
- data/docs/yard_plugin.rb +14 -0
- data/features/{ruby_api/api.feature → command_line_interface/basic_usage.feature} +6 -5
- data/features/command_line_interface/options.feature +1 -0
- 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 +43 -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/samples.feature +26 -31
- 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/{source → ast}/ast_node_class_map.rb +11 -12
- data/lib/reek/ast/node.rb +132 -0
- data/lib/reek/{core → ast}/object_refs.rb +2 -1
- data/lib/reek/ast/reference_collector.rb +32 -0
- data/lib/reek/{source → ast}/sexp_extensions.rb +43 -7
- data/lib/reek/ast/sexp_formatter.rb +31 -0
- data/lib/reek/cli/application.rb +5 -4
- data/lib/reek/cli/command.rb +2 -1
- data/lib/reek/cli/input.rb +6 -5
- data/lib/reek/cli/option_interpreter.rb +13 -9
- data/lib/reek/cli/options.rb +16 -8
- data/lib/reek/cli/reek_command.rb +4 -3
- data/lib/reek/cli/silencer.rb +14 -0
- data/lib/reek/{core → cli}/warning_collector.rb +2 -1
- data/lib/reek/code_comment.rb +36 -0
- data/lib/reek/configuration/app_configuration.rb +18 -3
- data/lib/reek/configuration/configuration_file_finder.rb +18 -32
- data/lib/reek/{core → context}/code_context.rb +8 -6
- data/lib/reek/{core → context}/method_context.rb +11 -5
- data/lib/reek/{core → context}/module_context.rb +9 -4
- data/lib/reek/{core/stop_context.rb → context/root_context.rb} +4 -2
- data/lib/reek/{core → context}/singleton_method_context.rb +3 -6
- data/lib/reek/examiner.rb +32 -29
- data/lib/reek/report/formatter.rb +70 -0
- data/lib/reek/report/heading_formatter.rb +45 -0
- data/lib/reek/report/location_formatter.rb +35 -0
- data/lib/reek/report/report.rb +198 -0
- data/lib/reek/smells/attribute.rb +41 -11
- data/lib/reek/smells/boolean_parameter.rb +4 -2
- data/lib/reek/smells/class_variable.rb +4 -2
- data/lib/reek/smells/control_parameter.rb +4 -2
- data/lib/reek/smells/data_clump.rb +4 -3
- data/lib/reek/smells/duplicate_method_call.rb +15 -5
- data/lib/reek/smells/feature_envy.rb +8 -2
- data/lib/reek/smells/irresponsible_module.rb +13 -8
- data/lib/reek/smells/long_parameter_list.rb +6 -4
- data/lib/reek/smells/long_yield_list.rb +4 -2
- data/lib/reek/smells/module_initialize.rb +4 -2
- data/lib/reek/smells/nested_iterators.rb +4 -2
- data/lib/reek/smells/nil_check.rb +6 -3
- data/lib/reek/smells/prima_donna_method.rb +21 -12
- data/lib/reek/smells/repeated_conditional.rb +7 -4
- data/lib/reek/{core → smells}/smell_configuration.rb +3 -1
- data/lib/reek/smells/smell_detector.rb +11 -5
- data/lib/reek/{core → smells}/smell_repository.rb +9 -5
- data/lib/reek/smells/smell_warning.rb +101 -0
- data/lib/reek/smells/too_many_instance_variables.rb +4 -2
- data/lib/reek/smells/too_many_methods.rb +4 -2
- data/lib/reek/smells/too_many_statements.rb +4 -2
- data/lib/reek/smells/uncommunicative_method_name.rb +4 -2
- data/lib/reek/smells/uncommunicative_module_name.rb +4 -2
- data/lib/reek/smells/uncommunicative_parameter_name.rb +4 -2
- data/lib/reek/smells/uncommunicative_variable_name.rb +4 -2
- data/lib/reek/smells/unused_parameters.rb +4 -2
- data/lib/reek/smells/utility_function.rb +11 -22
- data/lib/reek/smells.rb +24 -11
- data/lib/reek/source/source_code.rb +69 -12
- data/lib/reek/source/source_locator.rb +34 -19
- data/lib/reek/spec/should_reek.rb +4 -3
- data/lib/reek/spec/should_reek_of.rb +2 -1
- data/lib/reek/spec/should_reek_only_of.rb +4 -3
- data/lib/reek/spec.rb +3 -3
- data/lib/reek/tree_dresser.rb +32 -0
- data/lib/reek/tree_walker.rb +182 -0
- data/lib/reek/version.rb +1 -1
- data/lib/reek.rb +3 -3
- data/reek.gemspec +18 -25
- data/spec/factories/factories.rb +4 -2
- data/spec/gem/updates_spec.rb +1 -1
- data/spec/gem/yard_spec.rb +2 -2
- data/spec/quality/reek_source_spec.rb +3 -3
- data/spec/reek/{source/sexp_node_spec.rb → ast/node_spec.rb} +4 -6
- data/spec/reek/{core → ast}/object_refs_spec.rb +4 -6
- data/spec/reek/{source → ast}/reference_collector_spec.rb +27 -19
- data/spec/reek/{source → ast}/sexp_extensions_spec.rb +7 -19
- data/spec/reek/{source → ast}/sexp_formatter_spec.rb +13 -8
- data/spec/reek/cli/option_interpreter_spec.rb +15 -0
- data/spec/reek/cli/options_spec.rb +19 -0
- data/spec/reek/cli/warning_collector_spec.rb +28 -0
- data/spec/reek/{source/code_comment_spec.rb → code_comment_spec.rb} +19 -17
- data/spec/reek/configuration/app_configuration_spec.rb +37 -26
- data/spec/reek/configuration/configuration_file_finder_spec.rb +67 -21
- data/spec/reek/{core → context}/code_context_spec.rb +18 -21
- data/spec/reek/{core → context}/method_context_spec.rb +33 -27
- data/spec/reek/{core → context}/module_context_spec.rb +5 -7
- data/spec/reek/context/root_context_spec.rb +14 -0
- data/spec/reek/context/singleton_method_context_spec.rb +17 -0
- data/spec/reek/examiner_spec.rb +9 -50
- data/spec/reek/{cli → report}/html_report_spec.rb +6 -9
- data/spec/reek/report/json_report_spec.rb +20 -0
- data/spec/reek/{cli → report}/text_report_spec.rb +16 -19
- data/spec/reek/report/xml_report_spec.rb +34 -0
- data/spec/reek/report/yaml_report_spec.rb +20 -0
- data/spec/reek/smells/attribute_spec.rb +93 -88
- data/spec/reek/smells/behaves_like_variable_detector.rb +1 -1
- data/spec/reek/smells/boolean_parameter_spec.rb +31 -5
- data/spec/reek/smells/class_variable_spec.rb +10 -10
- data/spec/reek/smells/control_parameter_spec.rb +5 -5
- data/spec/reek/smells/data_clump_spec.rb +6 -6
- data/spec/reek/smells/duplicate_method_call_spec.rb +7 -7
- data/spec/reek/smells/feature_envy_spec.rb +12 -13
- data/spec/reek/smells/irresponsible_module_spec.rb +28 -32
- data/spec/reek/smells/long_parameter_list_spec.rb +7 -7
- data/spec/reek/smells/long_yield_list_spec.rb +6 -6
- data/spec/reek/smells/module_initialize_spec.rb +4 -4
- data/spec/reek/smells/nested_iterators_spec.rb +6 -6
- data/spec/reek/smells/nil_check_spec.rb +6 -6
- data/spec/reek/smells/prima_donna_method_spec.rb +8 -5
- data/spec/reek/smells/repeated_conditional_spec.rb +18 -17
- data/spec/reek/{core → smells}/smell_configuration_spec.rb +5 -7
- data/spec/reek/smells/smell_detector_shared.rb +6 -7
- data/spec/reek/smells/smell_repository_spec.rb +29 -0
- data/spec/reek/{smell_warning_spec.rb → smells/smell_warning_spec.rb} +7 -9
- data/spec/reek/smells/too_many_instance_variables_spec.rb +5 -5
- data/spec/reek/smells/too_many_methods_spec.rb +12 -8
- data/spec/reek/smells/too_many_statements_spec.rb +10 -9
- data/spec/reek/smells/uncommunicative_method_name_spec.rb +5 -5
- data/spec/reek/smells/uncommunicative_module_name_spec.rb +8 -8
- data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +18 -6
- data/spec/reek/smells/uncommunicative_variable_name_spec.rb +10 -7
- data/spec/reek/smells/unused_parameters_spec.rb +4 -4
- data/spec/reek/smells/utility_function_spec.rb +65 -39
- data/spec/reek/source/source_code_spec.rb +10 -10
- data/spec/reek/source/source_locator_spec.rb +30 -0
- data/spec/reek/spec/should_reek_of_spec.rb +9 -25
- data/spec/reek/spec/should_reek_only_of_spec.rb +4 -7
- data/spec/reek/spec/should_reek_spec.rb +4 -32
- data/spec/reek/tree_dresser_spec.rb +16 -0
- data/spec/reek/{core/tree_walker_spec.rb → tree_walker_spec.rb} +5 -7
- data/spec/samples/checkstyle.xml +2 -0
- data/spec/samples/configuration/with_excluded_paths.reek +4 -0
- data/spec/samples/{overrides/masked/lower.reek → masked_by_dotfile/.reek} +3 -1
- data/spec/samples/source_with_exclude_paths/ignore_me/uncommunicative_method_name.rb +5 -0
- data/spec/samples/source_with_exclude_paths/nested/ignore_me_as_well/irresponsible_module.rb +2 -0
- data/spec/samples/source_with_exclude_paths/nested/uncommunicative_parameter_name.rb +6 -0
- data/spec/samples/{ruby20_syntax.rb → unusual_syntax.rb} +8 -0
- data/spec/spec_helper.rb +21 -10
- data/tasks/develop.rake +2 -2
- data/tasks/reek.rake +1 -1
- metadata +158 -141
- data/features/support/hooks.rb +0 -15
- data/lib/reek/cli/report/formatter.rb +0 -69
- data/lib/reek/cli/report/heading_formatter.rb +0 -45
- data/lib/reek/cli/report/location_formatter.rb +0 -34
- data/lib/reek/cli/report/report.rb +0 -131
- data/lib/reek/core/tree_walker.rb +0 -180
- data/lib/reek/smell_warning.rb +0 -87
- data/lib/reek/source/ast_node.rb +0 -38
- data/lib/reek/source/code_comment.rb +0 -37
- data/lib/reek/source/core_extras.rb +0 -46
- data/lib/reek/source/reference_collector.rb +0 -27
- data/lib/reek/source/sexp_formatter.rb +0 -22
- data/lib/reek/source/sexp_node.rb +0 -79
- data/lib/reek/source/source_file.rb +0 -16
- data/lib/reek/source/source_repository.rb +0 -45
- data/lib/reek/source/tree_dresser.rb +0 -24
- data/lib/reek/source.rb +0 -16
- data/spec/reek/cli/json_report_spec.rb +0 -20
- data/spec/reek/cli/option_interperter_spec.rb +0 -14
- data/spec/reek/cli/yaml_report_spec.rb +0 -23
- data/spec/reek/core/singleton_method_context_spec.rb +0 -9
- data/spec/reek/core/smell_repository_spec.rb +0 -17
- data/spec/reek/core/stop_context_spec.rb +0 -17
- data/spec/reek/core/warning_collector_spec.rb +0 -30
- data/spec/reek/source/object_source_spec.rb +0 -20
- data/spec/reek/source/tree_dresser_spec.rb +0 -18
- 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/ruby21_syntax.rb +0 -5
- 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
- /data/spec/samples/{simple_configuration.reek → configuration/simple_configuration.reek} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
require_relative '../../spec_helper'
|
|
2
|
+
require_relative '../../../lib/reek/smells/duplicate_method_call'
|
|
3
|
+
require_relative '../../../lib/reek/context/code_context'
|
|
4
|
+
require_relative '../../../lib/reek/tree_walker'
|
|
5
|
+
require_relative 'smell_detector_shared'
|
|
6
6
|
|
|
7
|
-
describe Reek::Smells::DuplicateMethodCall do
|
|
7
|
+
RSpec.describe Reek::Smells::DuplicateMethodCall do
|
|
8
8
|
context 'when a smell is reported' do
|
|
9
9
|
before :each do
|
|
10
10
|
@source_name = 'dummy_source'
|
|
@@ -16,7 +16,7 @@ describe Reek::Smells::DuplicateMethodCall do
|
|
|
16
16
|
other[@thing]
|
|
17
17
|
end
|
|
18
18
|
EOS
|
|
19
|
-
ctx = Reek::
|
|
19
|
+
ctx = Reek::Context::CodeContext.new(nil, Reek::Source::SourceCode.from(src).syntax_tree)
|
|
20
20
|
smells = @detector.examine_context(ctx)
|
|
21
21
|
expect(smells.length).to eq(1)
|
|
22
22
|
@warning = smells[0]
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
require_relative '../../spec_helper'
|
|
2
|
+
require_relative '../../../lib/reek/smells/feature_envy'
|
|
3
|
+
require_relative 'smell_detector_shared'
|
|
4
4
|
|
|
5
|
-
describe Reek::Smells::FeatureEnvy do
|
|
5
|
+
RSpec.describe Reek::Smells::FeatureEnvy do
|
|
6
6
|
context 'with no smell' do
|
|
7
7
|
it 'should not report use of self' do
|
|
8
8
|
expect('def simple() self.to_s + self.to_i end').not_to reek_of(:FeatureEnvy)
|
|
@@ -74,7 +74,7 @@ describe Reek::Smells::FeatureEnvy do
|
|
|
74
74
|
def envy(arga)
|
|
75
75
|
arga.b(arga) + arga.c(@fred)
|
|
76
76
|
end
|
|
77
|
-
').to
|
|
77
|
+
').to reek_of(:FeatureEnvy, name: 'arga')
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
80
|
|
|
@@ -88,7 +88,8 @@ describe Reek::Smells::FeatureEnvy do
|
|
|
88
88
|
total *= 1.15
|
|
89
89
|
end
|
|
90
90
|
EOS
|
|
91
|
-
expect(src).to
|
|
91
|
+
expect(src).to reek_of(:FeatureEnvy, name: 'total')
|
|
92
|
+
expect(src).not_to reek_of(:FeatureEnvy, name: 'fred')
|
|
92
93
|
end
|
|
93
94
|
|
|
94
95
|
it 'should report multiple affinities' do
|
|
@@ -100,8 +101,8 @@ describe Reek::Smells::FeatureEnvy do
|
|
|
100
101
|
total += fred.tax
|
|
101
102
|
end
|
|
102
103
|
EOS
|
|
103
|
-
expect(src).to reek_of(:FeatureEnvy,
|
|
104
|
-
expect(src).to reek_of(:FeatureEnvy,
|
|
104
|
+
expect(src).to reek_of(:FeatureEnvy, name: 'total')
|
|
105
|
+
expect(src).to reek_of(:FeatureEnvy, name: 'fred')
|
|
105
106
|
end
|
|
106
107
|
|
|
107
108
|
it 'should not be fooled by duplication' do
|
|
@@ -179,9 +180,7 @@ describe Reek::Smells::FeatureEnvy do
|
|
|
179
180
|
EOS
|
|
180
181
|
expect(src).not_to reek_of(:FeatureEnvy)
|
|
181
182
|
end
|
|
182
|
-
end
|
|
183
183
|
|
|
184
|
-
describe Reek::Smells::FeatureEnvy do
|
|
185
184
|
it 'counts references to self correctly' do
|
|
186
185
|
ruby = <<-EOS
|
|
187
186
|
def report
|
|
@@ -212,7 +211,7 @@ describe Reek::Smells::FeatureEnvy do
|
|
|
212
211
|
end
|
|
213
212
|
end
|
|
214
213
|
|
|
215
|
-
describe Reek::Smells::FeatureEnvy do
|
|
214
|
+
RSpec.describe Reek::Smells::FeatureEnvy do
|
|
216
215
|
before(:each) do
|
|
217
216
|
@source_name = 'dummy_source'
|
|
218
217
|
@detector = build(:smell_detector, smell_type: :FeatureEnvy, source: @source_name)
|
|
@@ -231,8 +230,8 @@ describe Reek::Smells::FeatureEnvy do
|
|
|
231
230
|
#{@receiver}.fred
|
|
232
231
|
end
|
|
233
232
|
EOS
|
|
234
|
-
source = src
|
|
235
|
-
@mctx = Reek::
|
|
233
|
+
source = Reek::Source::SourceCode.from(src)
|
|
234
|
+
@mctx = Reek::TreeWalker.new.process_def(source.syntax_tree)
|
|
236
235
|
@smells = @detector.examine_context(@mctx)
|
|
237
236
|
end
|
|
238
237
|
|
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
describe Reek::Smells::IrresponsibleModule do
|
|
7
|
-
before(:each) do
|
|
8
|
-
@bad_module_name = 'WrongUn'
|
|
9
|
-
@source_name = 'dummy_source'
|
|
10
|
-
@detector = build(:smell_detector, smell_type: :IrresponsibleModule, source: @source_name)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it_should_behave_like 'SmellDetector'
|
|
1
|
+
require_relative '../../spec_helper'
|
|
2
|
+
require_relative '../../../lib/reek/context/code_context'
|
|
3
|
+
require_relative '../../../lib/reek/smells/irresponsible_module'
|
|
4
|
+
require_relative 'smell_detector_shared'
|
|
14
5
|
|
|
6
|
+
RSpec.describe Reek::Smells::IrresponsibleModule do
|
|
15
7
|
it 'does not report re-opened modules' do
|
|
16
8
|
src = <<-EOS
|
|
17
9
|
# Abstract base class
|
|
@@ -27,19 +19,12 @@ describe Reek::Smells::IrresponsibleModule do
|
|
|
27
19
|
# test class
|
|
28
20
|
class Responsible; end
|
|
29
21
|
EOS
|
|
30
|
-
|
|
31
|
-
expect(@detector.examine_context(ctx)).to be_empty
|
|
22
|
+
expect(src).not_to reek_of(:IrresponsibleModule)
|
|
32
23
|
end
|
|
33
24
|
|
|
34
25
|
it 'reports a class without a comment' do
|
|
35
|
-
src =
|
|
36
|
-
|
|
37
|
-
smells = @detector.examine_context(ctx)
|
|
38
|
-
expect(smells.length).to eq(1)
|
|
39
|
-
expect(smells[0].smell_category).to eq(Reek::Smells::IrresponsibleModule.smell_category)
|
|
40
|
-
expect(smells[0].smell_type).to eq(Reek::Smells::IrresponsibleModule.smell_type)
|
|
41
|
-
expect(smells[0].lines).to eq([1])
|
|
42
|
-
expect(smells[0].parameters[:name]).to eq(@bad_module_name)
|
|
26
|
+
src = 'class BadClass; end'
|
|
27
|
+
expect(src).to reek_of :IrresponsibleModule, name: 'BadClass'
|
|
43
28
|
end
|
|
44
29
|
|
|
45
30
|
it 'reports a class with an empty comment' do
|
|
@@ -47,7 +32,7 @@ describe Reek::Smells::IrresponsibleModule do
|
|
|
47
32
|
#
|
|
48
33
|
#
|
|
49
34
|
#
|
|
50
|
-
class
|
|
35
|
+
class BadClass; end
|
|
51
36
|
EOS
|
|
52
37
|
expect(src).to reek_of :IrresponsibleModule
|
|
53
38
|
end
|
|
@@ -63,14 +48,25 @@ describe Reek::Smells::IrresponsibleModule do
|
|
|
63
48
|
expect(src).to reek_of(:IrresponsibleModule)
|
|
64
49
|
end
|
|
65
50
|
|
|
66
|
-
it 'reports a
|
|
51
|
+
it 'reports a class with a trailing comment' do
|
|
52
|
+
src = <<-EOS
|
|
53
|
+
class BadClass
|
|
54
|
+
end # end BadClass
|
|
55
|
+
EOS
|
|
56
|
+
expect(src).to reek_of(:IrresponsibleModule)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it 'reports a fully qualified class name correctly' do
|
|
67
60
|
src = 'class Foo::Bar; end'
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
61
|
+
expect(src).to reek_of :IrresponsibleModule, name: 'Foo::Bar'
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
context 'when a smell is reported' do
|
|
65
|
+
before do
|
|
66
|
+
@source_name = 'dummy_source'
|
|
67
|
+
@detector = build(:smell_detector, smell_type: :IrresponsibleModule, source: @source_name)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it_should_behave_like 'SmellDetector'
|
|
75
71
|
end
|
|
76
72
|
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
require_relative '../../spec_helper'
|
|
2
|
+
require_relative '../../../lib/reek/context/code_context'
|
|
3
|
+
require_relative '../../../lib/reek/smells/long_parameter_list'
|
|
4
|
+
require_relative 'smell_detector_shared'
|
|
5
5
|
|
|
6
|
-
describe Reek::Smells::LongParameterList do
|
|
6
|
+
RSpec.describe Reek::Smells::LongParameterList do
|
|
7
7
|
context 'for methods with few parameters' do
|
|
8
8
|
it 'should report nothing for no parameters' do
|
|
9
9
|
expect('def simple; f(3);true; end').not_to reek_of(:LongParameterList)
|
|
@@ -73,7 +73,7 @@ describe Reek::Smells::LongParameterList do
|
|
|
73
73
|
end
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
-
describe Reek::Smells::LongParameterList do
|
|
76
|
+
RSpec.describe Reek::Smells::LongParameterList do
|
|
77
77
|
before(:each) do
|
|
78
78
|
@source_name = 'dummy_source'
|
|
79
79
|
@detector = build(:smell_detector, smell_type: :LongParameterList, source: @source_name)
|
|
@@ -89,7 +89,7 @@ describe Reek::Smells::LongParameterList do
|
|
|
89
89
|
true
|
|
90
90
|
end
|
|
91
91
|
EOS
|
|
92
|
-
ctx = Reek::
|
|
92
|
+
ctx = Reek::Context::CodeContext.new(nil, Reek::Source::SourceCode.from(src).syntax_tree)
|
|
93
93
|
@smells = @detector.examine_context(ctx)
|
|
94
94
|
@warning = @smells[0]
|
|
95
95
|
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
require_relative '../../spec_helper'
|
|
2
|
+
require_relative '../../../lib/reek/context/code_context'
|
|
3
|
+
require_relative '../../../lib/reek/smells/long_yield_list'
|
|
4
|
+
require_relative 'smell_detector_shared'
|
|
5
5
|
|
|
6
|
-
describe Reek::Smells::LongYieldList do
|
|
6
|
+
RSpec.describe Reek::Smells::LongYieldList do
|
|
7
7
|
before(:each) do
|
|
8
8
|
@source_name = 'dummy_source'
|
|
9
9
|
@detector = build(:smell_detector, smell_type: :LongYieldList, source: @source_name)
|
|
@@ -38,7 +38,7 @@ describe Reek::Smells::LongYieldList do
|
|
|
38
38
|
yield(arga,argb,arga,argb)
|
|
39
39
|
end
|
|
40
40
|
EOS
|
|
41
|
-
ctx = Reek::
|
|
41
|
+
ctx = Reek::Context::CodeContext.new(nil, Reek::Source::SourceCode.from(src).syntax_tree)
|
|
42
42
|
@smells = @detector.examine_context(ctx)
|
|
43
43
|
@warning = @smells[0]
|
|
44
44
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
require_relative '../../spec_helper'
|
|
2
|
+
require_relative '../../../lib/reek/smells/module_initialize'
|
|
3
|
+
require_relative 'smell_detector_shared'
|
|
4
4
|
|
|
5
|
-
describe Reek::Smells::ModuleInitialize do
|
|
5
|
+
RSpec.describe Reek::Smells::ModuleInitialize do
|
|
6
6
|
context 'module' do
|
|
7
7
|
context 'with method named initialize' do
|
|
8
8
|
it 'smells' do
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
require_relative '../../spec_helper'
|
|
2
|
+
require_relative '../../../lib/reek/smells/nested_iterators'
|
|
3
|
+
require_relative 'smell_detector_shared'
|
|
4
4
|
|
|
5
|
-
describe Reek::Smells::NestedIterators do
|
|
5
|
+
RSpec.describe Reek::Smells::NestedIterators do
|
|
6
6
|
context 'with no iterators' do
|
|
7
7
|
it 'reports no smells' do
|
|
8
8
|
src = 'def fred() nothing = true; end'
|
|
@@ -220,7 +220,7 @@ describe Reek::Smells::NestedIterators do
|
|
|
220
220
|
end
|
|
221
221
|
end
|
|
222
222
|
|
|
223
|
-
describe Reek::Smells::NestedIterators do
|
|
223
|
+
RSpec.describe Reek::Smells::NestedIterators do
|
|
224
224
|
before(:each) do
|
|
225
225
|
@source_name = 'dummy_source'
|
|
226
226
|
@detector = build(:smell_detector, smell_type: :NestedIterators, source: @source_name)
|
|
@@ -237,7 +237,7 @@ describe Reek::Smells::NestedIterators do
|
|
|
237
237
|
end
|
|
238
238
|
end
|
|
239
239
|
EOS
|
|
240
|
-
ctx = Reek::
|
|
240
|
+
ctx = Reek::Context::CodeContext.new(nil, Reek::Source::SourceCode.from(src).syntax_tree)
|
|
241
241
|
@warning = @detector.examine_context(ctx)[0]
|
|
242
242
|
end
|
|
243
243
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
require_relative '../../spec_helper'
|
|
2
|
+
require_relative '../../../lib/reek/context/code_context'
|
|
3
|
+
require_relative '../../../lib/reek/smells/nil_check'
|
|
4
|
+
require_relative 'smell_detector_shared'
|
|
5
5
|
|
|
6
|
-
describe Reek::Smells::NilCheck do
|
|
6
|
+
RSpec.describe Reek::Smells::NilCheck do
|
|
7
7
|
context 'for methods' do
|
|
8
8
|
it 'reports the correct line number' do
|
|
9
9
|
src = <<-EOS
|
|
@@ -11,7 +11,7 @@ describe Reek::Smells::NilCheck do
|
|
|
11
11
|
foo.nil?
|
|
12
12
|
end
|
|
13
13
|
EOS
|
|
14
|
-
ctx = Reek::
|
|
14
|
+
ctx = Reek::Context::CodeContext.new(nil, Reek::Source::SourceCode.from(src).syntax_tree)
|
|
15
15
|
detector = build(:smell_detector, smell_type: :NilCheck, source: 'source_name')
|
|
16
16
|
smells = detector.examine_context(ctx)
|
|
17
17
|
expect(smells[0].lines).to eq [2]
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
require_relative '../../spec_helper'
|
|
2
|
+
require_relative '../../../lib/reek/context/module_context'
|
|
3
|
+
require_relative 'smell_detector_shared'
|
|
4
4
|
|
|
5
|
-
describe Reek::Smells::PrimaDonnaMethod do
|
|
5
|
+
RSpec.describe Reek::Smells::PrimaDonnaMethod do
|
|
6
6
|
it 'should report nothing when method and bang counterpart exist' do
|
|
7
7
|
expect('class C; def m; end; def m!; end; end').not_to reek_of(:PrimaDonnaMethod)
|
|
8
8
|
end
|
|
@@ -14,7 +14,10 @@ describe Reek::Smells::PrimaDonnaMethod do
|
|
|
14
14
|
describe 'the right smell' do
|
|
15
15
|
let(:detector) { build(:smell_detector, smell_type: :PrimaDonnaMethod, source: 'source_name') }
|
|
16
16
|
let(:src) { 'class C; def m!; end; end' }
|
|
17
|
-
let(:ctx)
|
|
17
|
+
let(:ctx) do
|
|
18
|
+
Reek::Context::ModuleContext.new(nil,
|
|
19
|
+
Reek::Source::SourceCode.from(src).syntax_tree)
|
|
20
|
+
end
|
|
18
21
|
|
|
19
22
|
it 'should be reported' do
|
|
20
23
|
smells = detector.examine_context(ctx)
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
require_relative '../../spec_helper'
|
|
2
|
+
require_relative '../../../lib/reek/smells/repeated_conditional'
|
|
3
|
+
require_relative '../../../lib/reek/context/code_context'
|
|
4
|
+
require_relative 'smell_detector_shared'
|
|
5
|
+
require_relative '../../../lib/reek/source/source_code'
|
|
5
6
|
|
|
6
|
-
describe Reek::Smells::RepeatedConditional do
|
|
7
|
+
RSpec.describe Reek::Smells::RepeatedConditional do
|
|
7
8
|
before(:each) do
|
|
8
9
|
@source_name = 'dummy_source'
|
|
9
10
|
@detector = build(:smell_detector, smell_type: :RepeatedConditional, source: @source_name)
|
|
@@ -13,24 +14,24 @@ describe Reek::Smells::RepeatedConditional do
|
|
|
13
14
|
|
|
14
15
|
context 'with no conditionals' do
|
|
15
16
|
it 'gathers an empty hash' do
|
|
16
|
-
ast = 'module Stable; end'.
|
|
17
|
-
ctx = Reek::
|
|
17
|
+
ast = Reek::Source::SourceCode.from('module Stable; end').syntax_tree
|
|
18
|
+
ctx = Reek::Context::CodeContext.new(nil, ast)
|
|
18
19
|
expect(@detector.conditional_counts(ctx).length).to eq(0)
|
|
19
20
|
end
|
|
20
21
|
end
|
|
21
22
|
|
|
22
23
|
context 'with a test of block_given?' do
|
|
23
24
|
it 'does not record the condition' do
|
|
24
|
-
ast = 'def fred() yield(3) if block_given?; end'.
|
|
25
|
-
ctx = Reek::
|
|
25
|
+
ast = Reek::Source::SourceCode.from('def fred() yield(3) if block_given?; end').syntax_tree
|
|
26
|
+
ctx = Reek::Context::CodeContext.new(nil, ast)
|
|
26
27
|
expect(@detector.conditional_counts(ctx).length).to eq(0)
|
|
27
28
|
end
|
|
28
29
|
end
|
|
29
30
|
|
|
30
31
|
context 'with an empty condition' do
|
|
31
32
|
it 'does not record the condition' do
|
|
32
|
-
ast = 'def fred() case; when 3; end; end'.
|
|
33
|
-
ctx = Reek::
|
|
33
|
+
ast = Reek::Source::SourceCode.from('def fred() case; when 3; end; end').syntax_tree
|
|
34
|
+
ctx = Reek::Context::CodeContext.new(nil, ast)
|
|
34
35
|
expect(@detector.conditional_counts(ctx).length).to eq(0)
|
|
35
36
|
end
|
|
36
37
|
end
|
|
@@ -38,7 +39,7 @@ describe Reek::Smells::RepeatedConditional do
|
|
|
38
39
|
context 'with three identical conditionals' do
|
|
39
40
|
before :each do
|
|
40
41
|
@cond = '@field == :sym'
|
|
41
|
-
@cond_expr = @cond.
|
|
42
|
+
@cond_expr = Reek::Source::SourceCode.from(@cond).syntax_tree
|
|
42
43
|
src = <<-EOS
|
|
43
44
|
class Scrunch
|
|
44
45
|
def first
|
|
@@ -56,8 +57,8 @@ describe Reek::Smells::RepeatedConditional do
|
|
|
56
57
|
end
|
|
57
58
|
EOS
|
|
58
59
|
|
|
59
|
-
ast = src.
|
|
60
|
-
@ctx = Reek::
|
|
60
|
+
ast = Reek::Source::SourceCode.from(src).syntax_tree
|
|
61
|
+
@ctx = Reek::Context::CodeContext.new(nil, ast)
|
|
61
62
|
@conds = @detector.conditional_counts(@ctx)
|
|
62
63
|
end
|
|
63
64
|
|
|
@@ -77,7 +78,7 @@ describe Reek::Smells::RepeatedConditional do
|
|
|
77
78
|
context 'with a matching if and case' do
|
|
78
79
|
before :each do
|
|
79
80
|
cond = '@field == :sym'
|
|
80
|
-
@cond_expr = cond.
|
|
81
|
+
@cond_expr = Reek::Source::SourceCode.from(cond).syntax_tree
|
|
81
82
|
src = <<-EOS
|
|
82
83
|
class Scrunch
|
|
83
84
|
def alpha
|
|
@@ -92,8 +93,8 @@ describe Reek::Smells::RepeatedConditional do
|
|
|
92
93
|
end
|
|
93
94
|
EOS
|
|
94
95
|
|
|
95
|
-
ast = src.
|
|
96
|
-
ctx = Reek::
|
|
96
|
+
ast = Reek::Source::SourceCode.from(src).syntax_tree
|
|
97
|
+
ctx = Reek::Context::CodeContext.new(nil, ast)
|
|
97
98
|
@conds = @detector.conditional_counts(ctx)
|
|
98
99
|
end
|
|
99
100
|
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
require_relative '../../spec_helper'
|
|
2
|
+
require_relative '../../../lib/reek/smells/smell_configuration'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
describe SmellConfiguration do
|
|
4
|
+
RSpec.describe Reek::Smells::SmellConfiguration do
|
|
7
5
|
it 'returns the default value when key not found' do
|
|
8
|
-
cf =
|
|
6
|
+
cf = described_class.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 =
|
|
15
|
+
@smell_config = described_class.new(@base_config)
|
|
18
16
|
end
|
|
19
17
|
|
|
20
18
|
it { expect(@smell_config.merge!({})).to eq(@base_config) }
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
require_relative '../../spec_helper'
|
|
2
|
+
require_relative '../../../lib/reek/smells/smell_configuration'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
shared_examples_for 'SmellDetector' do
|
|
4
|
+
RSpec.shared_examples_for 'SmellDetector' do
|
|
7
5
|
context 'exception matching follows the context' do
|
|
8
6
|
before :each do
|
|
9
7
|
@ctx = double('context')
|
|
@@ -23,13 +21,14 @@ shared_examples_for 'SmellDetector' do
|
|
|
23
21
|
|
|
24
22
|
context 'configuration' do
|
|
25
23
|
it 'becomes disabled when disabled' do
|
|
26
|
-
|
|
24
|
+
enabled_key = Reek::Smells::SmellConfiguration::ENABLED_KEY
|
|
25
|
+
@detector.configure_with(enabled_key => false)
|
|
27
26
|
expect(@detector).not_to be_enabled
|
|
28
27
|
end
|
|
29
28
|
end
|
|
30
29
|
end
|
|
31
30
|
|
|
32
|
-
shared_examples_for 'common fields set correctly' do
|
|
31
|
+
RSpec.shared_examples_for 'common fields set correctly' do
|
|
33
32
|
it 'reports the source' do
|
|
34
33
|
expect(@warning.source).to eq(@source_name)
|
|
35
34
|
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require_relative '../../spec_helper'
|
|
2
|
+
require_relative '../../../lib/reek/smells/smell_detector'
|
|
3
|
+
require_relative '../../../lib/reek/smells/smell_repository'
|
|
4
|
+
|
|
5
|
+
RSpec.describe Reek::Smells::SmellRepository do
|
|
6
|
+
describe '.smell_types' do
|
|
7
|
+
let(:smell_types) { described_class.smell_types }
|
|
8
|
+
|
|
9
|
+
it 'should include existing smell_types' do
|
|
10
|
+
expect(smell_types).to include(Reek::Smells::IrresponsibleModule)
|
|
11
|
+
expect(smell_types).to include(Reek::Smells::TooManyStatements)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'should exclude certain smell_types' do
|
|
15
|
+
expect(smell_types).to_not include(Reek::Smells::SmellDetector)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'should return the smell types in alphabetic order' do
|
|
19
|
+
expect(smell_types).to eq(smell_types.sort_by(&:name))
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "should raise an ArgumentError if smell to configure doesn't exist" do
|
|
23
|
+
repository = described_class.new
|
|
24
|
+
expect { repository.configure('SomethingNonExistant', {}) }.
|
|
25
|
+
to raise_error ArgumentError,
|
|
26
|
+
'Unknown smell type SomethingNonExistant found in configuration'
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
require_relative '../../spec_helper'
|
|
2
|
+
require_relative '../../../lib/reek/smells/smell_warning'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
describe SmellWarning do
|
|
4
|
+
RSpec.describe Reek::Smells::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::Smells::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,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
require_relative '../../spec_helper'
|
|
2
|
+
require_relative '../../../lib/reek/smells/too_many_instance_variables'
|
|
3
|
+
require_relative 'smell_detector_shared'
|
|
4
4
|
|
|
5
|
-
describe Reek::Smells::TooManyInstanceVariables do
|
|
5
|
+
RSpec.describe Reek::Smells::TooManyInstanceVariables do
|
|
6
6
|
before(:each) do
|
|
7
7
|
@source_name = 'dummy_source'
|
|
8
8
|
@detector = build(:smell_detector, smell_type: :TooManyInstanceVariables, source: @source_name)
|
|
@@ -72,7 +72,7 @@ describe Reek::Smells::TooManyInstanceVariables do
|
|
|
72
72
|
end
|
|
73
73
|
end
|
|
74
74
|
EOS
|
|
75
|
-
ctx = Reek::
|
|
75
|
+
ctx = Reek::Context::CodeContext.new(nil, Reek::Source::SourceCode.from(src).syntax_tree)
|
|
76
76
|
@warning = @detector.examine_context(ctx)[0]
|
|
77
77
|
expect(@warning.source).to eq(@source_name)
|
|
78
78
|
expect(@warning.smell_category).to eq(Reek::Smells::TooManyInstanceVariables.smell_category)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
require_relative '../../spec_helper'
|
|
2
|
+
require_relative '../../../lib/reek/smells/too_many_methods'
|
|
3
|
+
require_relative 'smell_detector_shared'
|
|
4
4
|
|
|
5
|
-
describe Reek::Smells::TooManyMethods do
|
|
5
|
+
RSpec.describe Reek::Smells::TooManyMethods do
|
|
6
6
|
before(:each) do
|
|
7
7
|
@source_name = 'dummy_source'
|
|
8
8
|
@detector = described_class.new(@source_name)
|
|
@@ -19,7 +19,8 @@ describe Reek::Smells::TooManyMethods do
|
|
|
19
19
|
def m2; end
|
|
20
20
|
end
|
|
21
21
|
EOS
|
|
22
|
-
|
|
22
|
+
syntax_tree = Reek::Source::SourceCode.from(src).syntax_tree
|
|
23
|
+
ctx = Reek::Context::ModuleContext.new(nil, syntax_tree)
|
|
23
24
|
expect(@detector.examine_context(ctx)).to be_empty
|
|
24
25
|
end
|
|
25
26
|
|
|
@@ -31,7 +32,8 @@ describe Reek::Smells::TooManyMethods do
|
|
|
31
32
|
def m3; end
|
|
32
33
|
end
|
|
33
34
|
EOS
|
|
34
|
-
|
|
35
|
+
syntax_tree = Reek::Source::SourceCode.from(src).syntax_tree
|
|
36
|
+
ctx = Reek::Context::ModuleContext.new(nil, syntax_tree)
|
|
35
37
|
smells = @detector.examine_context(ctx)
|
|
36
38
|
expect(smells.length).to eq(1)
|
|
37
39
|
expect(smells[0].smell_type).to eq(described_class.smell_type)
|
|
@@ -53,7 +55,8 @@ describe Reek::Smells::TooManyMethods do
|
|
|
53
55
|
end
|
|
54
56
|
end
|
|
55
57
|
EOS
|
|
56
|
-
|
|
58
|
+
syntax_tree = Reek::Source::SourceCode.from(src).syntax_tree
|
|
59
|
+
ctx = Reek::Context::ModuleContext.new(nil, syntax_tree)
|
|
57
60
|
expect(@detector.examine_context(ctx)).to be_empty
|
|
58
61
|
end
|
|
59
62
|
end
|
|
@@ -67,7 +70,8 @@ describe Reek::Smells::TooManyMethods do
|
|
|
67
70
|
end
|
|
68
71
|
EOS
|
|
69
72
|
|
|
70
|
-
|
|
73
|
+
syntax_tree = Reek::Source::SourceCode.from(src).syntax_tree
|
|
74
|
+
ctx = Reek::Context::ModuleContext.new(nil, syntax_tree)
|
|
71
75
|
@warning = @detector.examine_context(ctx)[0]
|
|
72
76
|
expect(@warning.source).to eq(@source_name)
|
|
73
77
|
expect(@warning.smell_category).to eq(described_class.smell_category)
|