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
data/reek.gemspec
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require 'reek/version'
|
2
|
+
require File.join(File.dirname(__FILE__), 'lib/reek/version')
|
4
3
|
|
5
4
|
Gem::Specification.new do |s|
|
6
5
|
s.name = 'reek'
|
@@ -15,31 +14,26 @@ Gem::Specification.new do |s|
|
|
15
14
|
|
16
15
|
s.license = 'MIT'
|
17
16
|
s.email = ['timo.roessner@googlemail.com']
|
18
|
-
s.executables = ['reek']
|
19
17
|
s.extra_rdoc_files = ['CHANGELOG', 'License.txt']
|
20
|
-
s.files =
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
s.homepage = 'https://wiki.github.com/troessner/reek'
|
25
|
-
s.rdoc_options = ['--main', 'README.md',
|
26
|
-
'-x', 'assets/|bin/|config/|features/|spec/|tasks/']
|
27
|
-
s.require_paths = ['lib']
|
28
|
-
s.rubyforge_project = 'reek'
|
29
|
-
s.rubygems_version = '1.3.6'
|
18
|
+
s.files = `git ls-files -z`.split("\0")
|
19
|
+
s.executables = s.files.grep(%r{^bin/}).map { |path| File.basename(path) }
|
20
|
+
s.homepage = 'https://github.com/troessner/reek/wiki'
|
21
|
+
s.rdoc_options = %w(--main README.md -x assets/|bin/|config/|features/|spec/|tasks/)
|
30
22
|
s.required_ruby_version = '>= 1.9.3'
|
31
23
|
s.summary = 'Code smell detector for Ruby'
|
32
24
|
|
33
|
-
s.add_runtime_dependency
|
34
|
-
s.add_runtime_dependency
|
35
|
-
s.add_runtime_dependency
|
36
|
-
s.add_runtime_dependency
|
25
|
+
s.add_runtime_dependency 'parser', '~> 2.2'
|
26
|
+
s.add_runtime_dependency 'rainbow', '~> 2.0'
|
27
|
+
s.add_runtime_dependency 'require_all', '~> 1.3'
|
28
|
+
s.add_runtime_dependency 'unparser', '~> 0.2.2'
|
37
29
|
|
38
|
-
s.add_development_dependency
|
39
|
-
s.add_development_dependency
|
40
|
-
s.add_development_dependency
|
41
|
-
s.add_development_dependency
|
42
|
-
s.add_development_dependency
|
43
|
-
s.add_development_dependency
|
44
|
-
s.add_development_dependency
|
30
|
+
s.add_development_dependency 'activesupport', '~> 4.2'
|
31
|
+
s.add_development_dependency 'aruba', '~> 0.6.2'
|
32
|
+
s.add_development_dependency 'bundler', '~> 1.1'
|
33
|
+
s.add_development_dependency 'cucumber', '~> 2.0'
|
34
|
+
s.add_development_dependency 'factory_girl', '~> 4.0'
|
35
|
+
s.add_development_dependency 'rake', '~> 10.0'
|
36
|
+
s.add_development_dependency 'rspec', '~> 3.0'
|
37
|
+
s.add_development_dependency 'rubocop', '~> 0.30.0'
|
38
|
+
s.add_development_dependency 'yard', '~> 0.8.7'
|
45
39
|
end
|
data/spec/factories/factories.rb
CHANGED
data/spec/gem/updates_spec.rb
CHANGED
data/spec/gem/yard_spec.rb
CHANGED
@@ -1,15 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/reek/examiner'
|
3
|
+
require_relative '../../../lib/reek/cli/report/report'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
describe Report::HtmlReport do
|
9
|
-
let(:instance) { Report::HtmlReport.new }
|
5
|
+
describe Reek::CLI::Report::HTMLReport do
|
6
|
+
let(:instance) { Reek::CLI::Report::HTMLReport.new }
|
10
7
|
|
11
8
|
context 'with an empty source' do
|
12
|
-
let(:examiner) { Examiner.new('') }
|
9
|
+
let(:examiner) { Reek::Examiner.new('') }
|
13
10
|
|
14
11
|
before do
|
15
12
|
instance.add_examiner examiner
|
@@ -1,10 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/reek/examiner'
|
3
|
+
require_relative '../../../lib/reek/cli/report/report'
|
4
|
+
require_relative '../../../lib/reek/cli/report/formatter'
|
5
5
|
|
6
|
-
describe Reek::
|
7
|
-
let(:instance) { Reek::
|
6
|
+
describe Reek::CLI::Report::JSONReport do
|
7
|
+
let(:instance) { Reek::CLI::Report::JSONReport.new }
|
8
8
|
|
9
9
|
context 'empty source' do
|
10
10
|
let(:examiner) { Reek::Examiner.new('') }
|
@@ -1,14 +1,14 @@
|
|
1
|
-
|
1
|
+
require_relative '../../spec_helper'
|
2
2
|
|
3
|
-
|
3
|
+
require_relative '../../../lib/reek/cli/options'
|
4
4
|
|
5
|
-
describe Reek::
|
5
|
+
describe Reek::CLI::OptionInterpreter do
|
6
6
|
let(:options) { OpenStruct.new }
|
7
|
-
let(:instance) { Reek::
|
7
|
+
let(:instance) { Reek::CLI::OptionInterpreter.new(options) }
|
8
8
|
|
9
9
|
describe '#reporter' do
|
10
10
|
it 'returns a Report::TextReport instance by default' do
|
11
|
-
expect(instance.reporter).to be_instance_of Reek::
|
11
|
+
expect(instance.reporter).to be_instance_of Reek::CLI::Report::TextReport
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -1,26 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/reek/examiner'
|
3
|
+
require_relative '../../../lib/reek/cli/report/report'
|
4
|
+
require_relative '../../../lib/reek/cli/report/formatter'
|
5
|
+
require_relative '../../../lib/reek/cli/report/heading_formatter'
|
6
6
|
require 'rainbow'
|
7
7
|
|
8
|
-
|
9
|
-
include Reek::Cli
|
10
|
-
|
11
|
-
describe Report::TextReport do
|
8
|
+
describe Reek::CLI::Report::TextReport do
|
12
9
|
let(:report_options) do
|
13
10
|
{
|
14
|
-
warning_formatter: Report::SimpleWarningFormatter.new,
|
15
|
-
report_formatter: Report::Formatter,
|
16
|
-
heading_formatter: Report::HeadingFormatter::Quiet
|
11
|
+
warning_formatter: Reek::CLI::Report::SimpleWarningFormatter.new,
|
12
|
+
report_formatter: Reek::CLI::Report::Formatter,
|
13
|
+
heading_formatter: Reek::CLI::Report::HeadingFormatter::Quiet
|
17
14
|
}
|
18
15
|
end
|
19
|
-
let(:instance) { Report::TextReport.new report_options }
|
16
|
+
let(:instance) { Reek::CLI::Report::TextReport.new report_options }
|
20
17
|
|
21
18
|
context 'with a single empty source' do
|
22
19
|
before do
|
23
|
-
instance.add_examiner Examiner.new('')
|
20
|
+
instance.add_examiner Reek::Examiner.new('')
|
24
21
|
end
|
25
22
|
|
26
23
|
it 'has an empty quiet_report' do
|
@@ -30,8 +27,8 @@ describe Report::TextReport do
|
|
30
27
|
|
31
28
|
context 'with non smelly files' do
|
32
29
|
before do
|
33
|
-
instance.add_examiner(Examiner.new('def simple() puts "a" end'))
|
34
|
-
instance.add_examiner(Examiner.new('def simple() puts "a" end'))
|
30
|
+
instance.add_examiner(Reek::Examiner.new('def simple() puts "a" end'))
|
31
|
+
instance.add_examiner(Reek::Examiner.new('def simple() puts "a" end'))
|
35
32
|
end
|
36
33
|
|
37
34
|
context 'with colors disabled' do
|
@@ -57,8 +54,8 @@ describe Report::TextReport do
|
|
57
54
|
|
58
55
|
context 'with a couple of smells' do
|
59
56
|
before do
|
60
|
-
instance.add_examiner(Examiner.new('def simple(a) a[3] end'))
|
61
|
-
instance.add_examiner(Examiner.new('def simple(a) a[3] end'))
|
57
|
+
instance.add_examiner(Reek::Examiner.new('def simple(a) a[3] end'))
|
58
|
+
instance.add_examiner(Reek::Examiner.new('def simple(a) a[3] end'))
|
62
59
|
end
|
63
60
|
|
64
61
|
context 'with colors disabled' do
|
@@ -72,7 +69,7 @@ describe Report::TextReport do
|
|
72
69
|
|
73
70
|
it 'should mention every smell name' do
|
74
71
|
expect { instance.show }.to output(/UncommunicativeParameterName/).to_stdout
|
75
|
-
expect { instance.show }.to output(/
|
72
|
+
expect { instance.show }.to output(/UtilityFunction/).to_stdout
|
76
73
|
end
|
77
74
|
end
|
78
75
|
|
@@ -1,16 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/reek/examiner'
|
3
|
+
require_relative '../../../lib/reek/cli/report/report'
|
4
|
+
require_relative '../../../lib/reek/cli/report/formatter'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
describe Report::YamlReport do
|
10
|
-
let(:instance) { Report::YamlReport.new }
|
6
|
+
describe Reek::CLI::Report::YAMLReport do
|
7
|
+
let(:instance) { Reek::CLI::Report::YAMLReport.new }
|
11
8
|
|
12
9
|
context 'empty source' do
|
13
|
-
let(:examiner) { Examiner.new('') }
|
10
|
+
let(:examiner) { Reek::Examiner.new('') }
|
14
11
|
|
15
12
|
before do
|
16
13
|
instance.add_examiner examiner
|
@@ -1,11 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/reek/configuration/app_configuration'
|
3
|
+
require_relative '../../../lib/reek/core/smell_repository'
|
4
4
|
|
5
|
-
|
6
|
-
include Reek::Core
|
7
|
-
|
8
|
-
describe AppConfiguration do
|
5
|
+
describe Reek::Configuration::AppConfiguration do
|
9
6
|
let(:sample_configuration_path) { 'spec/samples/simple_configuration.reek' }
|
10
7
|
let(:sample_configuration_loaded) do
|
11
8
|
{
|
@@ -15,31 +12,32 @@ describe AppConfiguration do
|
|
15
12
|
end
|
16
13
|
let(:default_configuration) { Hash.new }
|
17
14
|
|
18
|
-
after(:each) { AppConfiguration.reset }
|
15
|
+
after(:each) { Reek::Configuration::AppConfiguration.reset }
|
19
16
|
|
20
17
|
describe '.initialize_with' do
|
21
18
|
it 'loads a configuration file if it can find one' do
|
22
|
-
|
23
|
-
|
19
|
+
finder = Reek::Configuration::ConfigurationFileFinder
|
20
|
+
allow(finder).to receive(:find).and_return sample_configuration_path
|
21
|
+
expect(Reek::Configuration::AppConfiguration.configuration).to eq(default_configuration)
|
24
22
|
|
25
|
-
AppConfiguration.initialize_with(nil)
|
26
|
-
expect(AppConfiguration.configuration).to eq(sample_configuration_loaded)
|
23
|
+
Reek::Configuration::AppConfiguration.initialize_with(nil)
|
24
|
+
expect(Reek::Configuration::AppConfiguration.configuration).to eq(sample_configuration_loaded)
|
27
25
|
end
|
28
26
|
|
29
27
|
it 'leaves the default configuration untouched if it can\'t find one' do
|
30
|
-
allow(ConfigurationFileFinder).to receive(:find).and_return nil
|
31
|
-
expect(AppConfiguration.configuration).to eq(default_configuration)
|
28
|
+
allow(Reek::Configuration::ConfigurationFileFinder).to receive(:find).and_return nil
|
29
|
+
expect(Reek::Configuration::AppConfiguration.configuration).to eq(default_configuration)
|
32
30
|
|
33
|
-
AppConfiguration.initialize_with(nil)
|
34
|
-
expect(AppConfiguration.configuration).to eq(default_configuration)
|
31
|
+
Reek::Configuration::AppConfiguration.initialize_with(nil)
|
32
|
+
expect(Reek::Configuration::AppConfiguration.configuration).to eq(default_configuration)
|
35
33
|
end
|
36
34
|
end
|
37
35
|
|
38
36
|
describe '.configure_smell_repository' do
|
39
37
|
it 'should configure a given smell_repository' do
|
40
|
-
AppConfiguration.load_from_file(sample_configuration_path)
|
41
|
-
smell_repository = SmellRepository.new('def m; end')
|
42
|
-
AppConfiguration.configure_smell_repository smell_repository
|
38
|
+
Reek::Configuration::AppConfiguration.load_from_file(sample_configuration_path)
|
39
|
+
smell_repository = Reek::Core::SmellRepository.new('def m; end')
|
40
|
+
Reek::Configuration::AppConfiguration.configure_smell_repository smell_repository
|
43
41
|
|
44
42
|
expect(smell_repository.detectors[Reek::Smells::DataClump]).to be_enabled
|
45
43
|
expect(smell_repository.detectors[Reek::Smells::UncommunicativeVariableName]).
|
@@ -50,18 +48,18 @@ describe AppConfiguration do
|
|
50
48
|
|
51
49
|
describe '.load_from_file' do
|
52
50
|
it 'loads the configuration from given file' do
|
53
|
-
AppConfiguration.load_from_file(sample_configuration_path)
|
54
|
-
expect(AppConfiguration.configuration).to eq(sample_configuration_loaded)
|
51
|
+
Reek::Configuration::AppConfiguration.load_from_file(sample_configuration_path)
|
52
|
+
expect(Reek::Configuration::AppConfiguration.configuration).to eq(sample_configuration_loaded)
|
55
53
|
end
|
56
54
|
end
|
57
55
|
|
58
56
|
describe '.reset' do
|
59
57
|
it 'resets the configuration' do
|
60
|
-
AppConfiguration.load_from_file(sample_configuration_path)
|
58
|
+
Reek::Configuration::AppConfiguration.load_from_file(sample_configuration_path)
|
61
59
|
|
62
|
-
expect(AppConfiguration.configuration).to eq(sample_configuration_loaded)
|
63
|
-
AppConfiguration.reset
|
64
|
-
expect(AppConfiguration.configuration).to eq(default_configuration)
|
60
|
+
expect(Reek::Configuration::AppConfiguration.configuration).to eq(sample_configuration_loaded)
|
61
|
+
Reek::Configuration::AppConfiguration.reset
|
62
|
+
expect(Reek::Configuration::AppConfiguration.configuration).to eq(default_configuration)
|
65
63
|
end
|
66
64
|
end
|
67
65
|
end
|
@@ -1,34 +1,59 @@
|
|
1
|
-
|
2
|
-
require 'reek/cli/application'
|
1
|
+
# encoding: UTF-8
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
require 'pathname'
|
4
|
+
require 'tmpdir'
|
5
|
+
require_relative '../../spec_helper'
|
6
6
|
|
7
|
-
describe ConfigurationFileFinder do
|
7
|
+
describe Reek::Configuration::ConfigurationFileFinder do
|
8
8
|
describe '.find' do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
it 'returns the config_file if it’s set' do
|
10
|
+
config_file = double
|
11
|
+
options = double(config_file: config_file)
|
12
|
+
found = described_class.find(options: options)
|
13
|
+
expect(found).to eq(config_file)
|
14
|
+
end
|
13
15
|
|
14
|
-
it '
|
15
|
-
|
16
|
+
it 'returns the file in current dir if config_file is nil' do
|
17
|
+
options = double(config_file: nil)
|
18
|
+
current = Pathname.new('spec/samples')
|
19
|
+
found = described_class.find(options: options, current: current)
|
20
|
+
expect(found).to eq(Pathname.new('spec/samples/exceptions.reek'))
|
16
21
|
end
|
17
22
|
|
18
|
-
it '
|
19
|
-
|
20
|
-
|
23
|
+
it 'returns the file in current dir if options is nil' do
|
24
|
+
current = Pathname.new('spec/samples')
|
25
|
+
found = described_class.find(current: current)
|
26
|
+
expect(found).to eq(Pathname.new('spec/samples/exceptions.reek'))
|
27
|
+
end
|
21
28
|
|
22
|
-
|
23
|
-
|
29
|
+
it 'returns the file in a parent dir if none in current dir' do
|
30
|
+
current = Pathname.new('spec/samples/no_config_file')
|
31
|
+
found = described_class.find(current: current)
|
32
|
+
expect(found).to eq(Pathname.new('spec/samples/exceptions.reek'))
|
24
33
|
end
|
25
34
|
|
26
|
-
it '
|
27
|
-
|
28
|
-
|
29
|
-
expect(
|
35
|
+
it 'returns the file even if it’s just ‘.reek’' do
|
36
|
+
current = Pathname.new('spec/samples/masked_by_dotfile')
|
37
|
+
found = described_class.find(current: current)
|
38
|
+
expect(found).to eq(Pathname.new('spec/samples/masked_by_dotfile/.reek'))
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'returns the file in home if traversing from the current dir fails' do
|
42
|
+
Dir.mktmpdir do |tempdir|
|
43
|
+
current = Pathname.new(tempdir)
|
44
|
+
home = Pathname.new('spec/samples')
|
45
|
+
found = described_class.find(current: current, home: home)
|
46
|
+
expect(found).to eq(Pathname.new('spec/samples/exceptions.reek'))
|
47
|
+
end
|
48
|
+
end
|
30
49
|
|
31
|
-
|
50
|
+
it 'returns nil when there are no files to find' do
|
51
|
+
Dir.mktmpdir do |tempdir|
|
52
|
+
current = Pathname.new(tempdir)
|
53
|
+
home = Pathname.new(tempdir)
|
54
|
+
found = described_class.find(current: current, home: home)
|
55
|
+
expect(found).to be_nil
|
56
|
+
end
|
32
57
|
end
|
33
58
|
end
|
34
59
|
end
|
@@ -1,11 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_relative '../../../lib/reek/core/method_context'
|
3
|
+
require_relative '../../../lib/reek/core/module_context'
|
4
|
+
require_relative '../../../lib/reek/core/stop_context'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
describe CodeContext do
|
6
|
+
describe Reek::Core::CodeContext do
|
9
7
|
context 'name recognition' do
|
10
8
|
before :each do
|
11
9
|
@exp_name = 'random_name' # SMELL: could use a String.random here
|
@@ -14,7 +12,7 @@ describe CodeContext do
|
|
14
12
|
allow(@exp).to receive(:name).and_return(@exp_name)
|
15
13
|
allow(@exp).to receive(:full_name).and_return(@full_name)
|
16
14
|
allow(@exp).to receive(:comments).and_return('')
|
17
|
-
@ctx = CodeContext.new(nil, @exp)
|
15
|
+
@ctx = Reek::Core::CodeContext.new(nil, @exp)
|
18
16
|
end
|
19
17
|
it 'gets its short name from the exp' do
|
20
18
|
expect(@ctx.name).to eq(@exp_name)
|
@@ -44,7 +42,7 @@ describe CodeContext do
|
|
44
42
|
@outer_name = 'another_random sting'
|
45
43
|
allow(outer).to receive(:full_name).at_least(:once).and_return(@outer_name)
|
46
44
|
allow(outer).to receive(:config).and_return({})
|
47
|
-
@ctx = CodeContext.new(outer, @exp)
|
45
|
+
@ctx = Reek::Core::CodeContext.new(outer, @exp)
|
48
46
|
end
|
49
47
|
it 'creates the correct full name' do
|
50
48
|
expect(@ctx.full_name).to eq("#{@full_name}")
|
@@ -60,10 +58,10 @@ describe CodeContext do
|
|
60
58
|
|
61
59
|
context 'generics' do
|
62
60
|
it 'should pass unknown method calls down the stack' do
|
63
|
-
stop = StopContext.new
|
61
|
+
stop = Reek::Core::StopContext.new
|
64
62
|
def stop.bananas(arg1, arg2) arg1 + arg2 + 43 end
|
65
|
-
element = ModuleContext.new(stop, s(:module, :mod, nil))
|
66
|
-
element = MethodContext.new(element, s(:def, :bad, s(:args), nil))
|
63
|
+
element = Reek::Core::ModuleContext.new(stop, s(:module, :mod, nil))
|
64
|
+
element = Reek::Core::MethodContext.new(element, s(:def, :bad, s(:args), nil))
|
67
65
|
expect(element.bananas(17, -5)).to eq(55)
|
68
66
|
end
|
69
67
|
end
|
@@ -73,8 +71,8 @@ describe CodeContext do
|
|
73
71
|
before :each do
|
74
72
|
@module_name = 'Emptiness'
|
75
73
|
src = "module #{@module_name}; end"
|
76
|
-
ast = src.
|
77
|
-
@ctx = CodeContext.new(nil, ast)
|
74
|
+
ast = Reek::Source::SourceCode.from(src).syntax_tree
|
75
|
+
@ctx = Reek::Core::CodeContext.new(nil, ast)
|
78
76
|
end
|
79
77
|
|
80
78
|
it 'yields no calls' do
|
@@ -105,8 +103,8 @@ describe CodeContext do
|
|
105
103
|
@module_name = 'Loneliness'
|
106
104
|
@method_name = 'calloo'
|
107
105
|
src = "module #{@module_name}; def #{@method_name}; puts('hello') end; end"
|
108
|
-
ast = src.
|
109
|
-
@ctx = CodeContext.new(nil, ast)
|
106
|
+
ast = Reek::Source::SourceCode.from(src).syntax_tree
|
107
|
+
@ctx = Reek::Core::CodeContext.new(nil, ast)
|
110
108
|
end
|
111
109
|
it 'yields no ifs' do
|
112
110
|
@ctx.each_node(:if, []) { |exp| raise "#{exp} yielded by empty module!" }
|
@@ -157,8 +155,8 @@ class Scrunch
|
|
157
155
|
end
|
158
156
|
EOS
|
159
157
|
|
160
|
-
ast = src.
|
161
|
-
ctx = CodeContext.new(nil, ast)
|
158
|
+
ast = Reek::Source::SourceCode.from(src).syntax_tree
|
159
|
+
ctx = Reek::Core::CodeContext.new(nil, ast)
|
162
160
|
expect(ctx.each_node(:if, []).length).to eq(3)
|
163
161
|
end
|
164
162
|
end
|
@@ -166,7 +164,7 @@ EOS
|
|
166
164
|
describe '#config_for' do
|
167
165
|
let(:expression) { double('exp') }
|
168
166
|
let(:outer) { nil }
|
169
|
-
let(:context) { CodeContext.new(outer, expression) }
|
167
|
+
let(:context) { Reek::Core::CodeContext.new(outer, expression) }
|
170
168
|
let(:sniffer) { double('sniffer') }
|
171
169
|
|
172
170
|
before :each do
|