reek 4.4.2 → 4.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +10 -1
- data/CHANGELOG.md +16 -0
- data/CONTRIBUTING.md +52 -23
- data/README.md +16 -3
- data/ataru_setup.rb +1 -1
- data/docs/API.md +1 -4
- data/docs/How-reek-works-internally.md +5 -5
- data/docs/Style-Guide.md +7 -0
- data/features/command_line_interface/options.feature +1 -0
- data/features/command_line_interface/show_progress.feature +33 -0
- data/features/configuration_files/masking_smells.feature +0 -1
- data/features/configuration_via_source_comments/erroneous_source_comments.feature +18 -4
- data/features/configuration_via_source_comments/well_formed_source_comments.feature +116 -0
- data/features/step_definitions/sample_file_steps.rb +5 -0
- data/features/todo_list.feature +42 -14
- data/lib/reek.rb +1 -1
- data/lib/reek/cli/application.rb +5 -0
- data/lib/reek/cli/command/report_command.rb +6 -1
- data/lib/reek/cli/command/todo_list_command.rb +1 -2
- data/lib/reek/cli/options.rb +19 -3
- data/lib/reek/code_comment.rb +83 -11
- data/lib/reek/configuration/configuration_validator.rb +2 -2
- data/lib/reek/errors/bad_detector_in_comment_error.rb +35 -0
- data/lib/reek/errors/garbage_detector_configuration_in_comment_error.rb +34 -0
- data/lib/reek/examiner.rb +36 -14
- data/lib/reek/report.rb +28 -9
- data/lib/reek/report/base_report.rb +77 -0
- data/lib/reek/report/code_climate.rb +4 -0
- data/lib/reek/report/code_climate/code_climate_fingerprint.rb +48 -0
- data/lib/reek/report/code_climate/code_climate_formatter.rb +5 -0
- data/lib/reek/report/code_climate/code_climate_report.rb +19 -0
- data/lib/reek/report/formatter.rb +5 -56
- data/lib/reek/report/{heading_formatter.rb → formatter/heading_formatter.rb} +4 -4
- data/lib/reek/report/formatter/location_formatter.rb +41 -0
- data/lib/reek/report/formatter/progress_formatter.rb +80 -0
- data/lib/reek/report/formatter/simple_warning_formatter.rb +35 -0
- data/lib/reek/report/formatter/wiki_link_warning_formatter.rb +35 -0
- data/lib/reek/report/html_report.rb +21 -0
- data/lib/reek/report/{html_report.html.erb → html_report/html_report.html.erb} +0 -0
- data/lib/reek/report/json_report.rb +18 -0
- data/lib/reek/report/text_report.rb +68 -0
- data/lib/reek/report/xml_report.rb +61 -0
- data/lib/reek/report/yaml_report.rb +18 -0
- data/lib/reek/smell_detectors.rb +30 -0
- data/lib/reek/{smells → smell_detectors}/attribute.rb +3 -3
- data/lib/reek/{smells/smell_detector.rb → smell_detectors/base_detector.rb} +3 -3
- data/lib/reek/{smells → smell_detectors}/boolean_parameter.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/class_variable.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/control_parameter.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/data_clump.rb +3 -3
- data/lib/reek/{smells/smell_repository.rb → smell_detectors/detector_repository.rb} +9 -9
- data/lib/reek/{smells → smell_detectors}/duplicate_method_call.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/feature_envy.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/instance_variable_assumption.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/irresponsible_module.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/long_parameter_list.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/long_yield_list.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/manual_dispatch.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/module_initialize.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/nested_iterators.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/nil_check.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/prima_donna_method.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/repeated_conditional.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/smell_configuration.rb +1 -1
- data/lib/reek/{smells → smell_detectors}/smell_warning.rb +1 -1
- data/lib/reek/{smells → smell_detectors}/subclassed_from_core_class.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/too_many_constants.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/too_many_instance_variables.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/too_many_methods.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/too_many_statements.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/uncommunicative_method_name.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/uncommunicative_module_name.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/uncommunicative_parameter_name.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/uncommunicative_variable_name.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/unused_parameters.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/unused_private_method.rb +3 -3
- data/lib/reek/{smells → smell_detectors}/utility_function.rb +3 -3
- data/lib/reek/spec/should_reek_of.rb +1 -1
- data/lib/reek/version.rb +1 -1
- data/reek.gemspec +1 -1
- data/spec/factories/factories.rb +6 -6
- data/spec/reek/cli/command/report_command_spec.rb +3 -1
- data/spec/reek/cli/options_spec.rb +12 -2
- data/spec/reek/code_comment_spec.rb +18 -6
- data/spec/reek/configuration/app_configuration_spec.rb +12 -12
- data/spec/reek/configuration/default_directive_spec.rb +1 -1
- data/spec/reek/configuration/directory_directives_spec.rb +2 -2
- data/spec/reek/examiner_spec.rb +56 -28
- data/spec/reek/report/code_climate/code_climate_fingerprint_spec.rb +122 -0
- data/spec/reek/report/{code_climate_formatter_spec.rb → code_climate/code_climate_formatter_spec.rb} +6 -2
- data/spec/reek/report/{code_climate_report_spec.rb → code_climate/code_climate_report_spec.rb} +7 -5
- data/spec/reek/report/{location_formatter_spec.rb → formatter/location_formatter_spec.rb} +4 -4
- data/spec/reek/report/formatter/progress_formatter_spec.rb +68 -0
- data/spec/reek/report/html_report_spec.rb +1 -1
- data/spec/reek/report/json_report_spec.rb +2 -2
- data/spec/reek/report/text_report_spec.rb +3 -4
- data/spec/reek/report/xml_report_spec.rb +1 -1
- data/spec/reek/report/yaml_report_spec.rb +2 -2
- data/spec/reek/report_spec.rb +3 -3
- data/spec/reek/{smells → smell_detectors}/attribute_spec.rb +2 -2
- data/spec/reek/{smells/smell_detector_spec.rb → smell_detectors/base_detector_spec.rb} +5 -5
- data/spec/reek/{smells → smell_detectors}/boolean_parameter_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/class_variable_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/control_parameter_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/data_clump_spec.rb +2 -2
- data/spec/reek/smell_detectors/detector_repository_spec.rb +22 -0
- data/spec/reek/{smells → smell_detectors}/duplicate_method_call_spec.rb +6 -6
- data/spec/reek/{smells → smell_detectors}/feature_envy_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/instance_variable_assumption_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/irresponsible_module_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/long_parameter_list_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/long_yield_list_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/manual_dispatch_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/module_initialize_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/nested_iterators_spec.rb +4 -4
- data/spec/reek/{smells → smell_detectors}/nil_check_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/prima_donna_method_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/repeated_conditional_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/smell_configuration_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/smell_warning_spec.rb +3 -3
- data/spec/reek/{smells → smell_detectors}/subclassed_from_core_class_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/too_many_constants_spec.rb +3 -3
- data/spec/reek/{smells → smell_detectors}/too_many_instance_variables_spec.rb +3 -3
- data/spec/reek/{smells → smell_detectors}/too_many_methods_spec.rb +3 -3
- data/spec/reek/{smells → smell_detectors}/too_many_statements_spec.rb +3 -3
- data/spec/reek/{smells → smell_detectors}/uncommunicative_method_name_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/uncommunicative_module_name_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/uncommunicative_parameter_name_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/uncommunicative_variable_name_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/unused_parameters_spec.rb +2 -2
- data/spec/reek/{smells → smell_detectors}/unused_private_method_spec.rb +4 -4
- data/spec/reek/{smells → smell_detectors}/utility_function_spec.rb +3 -3
- data/spec/reek/spec/should_reek_of_spec.rb +3 -3
- data/tasks/configuration.rake +2 -2
- metadata +95 -81
- data/features/smells/subclassed_from_core_class.feature +0 -14
- data/features/smells/too_many_constants.feature +0 -19
- data/lib/reek/errors.rb +0 -32
- data/lib/reek/report/location_formatter.rb +0 -39
- data/lib/reek/report/report.rb +0 -229
- data/lib/reek/smells.rb +0 -30
- data/spec/reek/smells/smell_repository_spec.rb +0 -22
data/spec/reek/report/{code_climate_formatter_spec.rb → code_climate/code_climate_formatter_spec.rb}
RENAMED
@@ -1,11 +1,11 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative '../../../spec_helper'
|
2
2
|
require_lib 'reek/report/code_climate/code_climate_formatter'
|
3
3
|
|
4
4
|
RSpec.describe Reek::Report::CodeClimateFormatter do
|
5
5
|
describe '#render' do
|
6
6
|
let(:warning) do
|
7
7
|
FactoryGirl.build(:smell_warning,
|
8
|
-
smell_detector: Reek::
|
8
|
+
smell_detector: Reek::SmellDetectors::UtilityFunction.new,
|
9
9
|
context: 'context foo',
|
10
10
|
message: 'message bar',
|
11
11
|
lines: [1, 2],
|
@@ -43,5 +43,9 @@ RSpec.describe Reek::Report::CodeClimateFormatter do
|
|
43
43
|
it 'sets remediation points based on the smell detector' do
|
44
44
|
expect(json['remediation_points']).to eq 250_000
|
45
45
|
end
|
46
|
+
|
47
|
+
it 'sets fingerprint based on warning context' do
|
48
|
+
expect(json['fingerprint']).to eq '70c530e45999af129d520f1f579f967f'
|
49
|
+
end
|
46
50
|
end
|
47
51
|
end
|
data/spec/reek/report/{code_climate_report_spec.rb → code_climate/code_climate_report_spec.rb}
RENAMED
@@ -1,7 +1,6 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative '../../../spec_helper'
|
2
2
|
require_lib 'reek/examiner'
|
3
|
-
require_lib 'reek/report/
|
4
|
-
require_lib 'reek/report/formatter'
|
3
|
+
require_lib 'reek/report/code_climate'
|
5
4
|
|
6
5
|
require 'json'
|
7
6
|
require 'stringio'
|
@@ -38,7 +37,8 @@ RSpec.describe Reek::Report::CodeClimateReport do
|
|
38
37
|
doesn't communicate its intent well enough.\\n\\nPoor names make it hard for the reader
|
39
38
|
to build a mental picture of what's going on in the code. They can also be
|
40
39
|
mis-interpreted; and they hurt the flow of reading, because the reader must slow down
|
41
|
-
to interpret the names.\\n\"}
|
40
|
+
to interpret the names.\\n\"},
|
41
|
+
\"fingerprint\":\"09970037d92b5a628bf682a3e2bb126d\"}\u0000
|
42
42
|
{\"type\":\"issue\",
|
43
43
|
\"check_name\":\"UtilityFunction\",
|
44
44
|
\"description\":\"simple doesn't depend on instance state (maybe move it to another class?)\",
|
@@ -46,8 +46,10 @@ RSpec.describe Reek::Report::CodeClimateReport do
|
|
46
46
|
\"location\":{\"path\":\"string\",\"lines\":{\"begin\":1,\"end\":1}},
|
47
47
|
\"remediation_points\":250000,
|
48
48
|
\"content\":{\"body\":\"A _Utility Function_ is any instance method that has no
|
49
|
-
dependency on the state of the instance.\\n\"}
|
49
|
+
dependency on the state of the instance.\\n\"},
|
50
|
+
\"fingerprint\":\"db456db7cb344bb5a98b8fc54a2f382e\"}\u0000
|
50
51
|
EOS
|
52
|
+
|
51
53
|
expect { instance.show }.to output(expected).to_stdout
|
52
54
|
end
|
53
55
|
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative '../../../spec_helper'
|
2
2
|
require_lib 'reek/report/formatter'
|
3
3
|
|
4
|
-
RSpec.describe Reek::Report::BlankLocationFormatter do
|
4
|
+
RSpec.describe Reek::Report::Formatter::BlankLocationFormatter do
|
5
5
|
let(:warning) { build(:smell_warning, lines: [11, 9, 250, 100]) }
|
6
6
|
|
7
7
|
describe '.format' do
|
@@ -11,7 +11,7 @@ RSpec.describe Reek::Report::BlankLocationFormatter do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
RSpec.describe Reek::Report::DefaultLocationFormatter do
|
14
|
+
RSpec.describe Reek::Report::Formatter::DefaultLocationFormatter do
|
15
15
|
let(:warning) { build(:smell_warning, lines: [11, 9, 250, 100]) }
|
16
16
|
|
17
17
|
describe '.format' do
|
@@ -21,7 +21,7 @@ RSpec.describe Reek::Report::DefaultLocationFormatter do
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
RSpec.describe Reek::Report::SingleLineLocationFormatter do
|
24
|
+
RSpec.describe Reek::Report::Formatter::SingleLineLocationFormatter do
|
25
25
|
let(:warning) { build(:smell_warning, lines: [11, 9, 250, 100]) }
|
26
26
|
|
27
27
|
describe '.format' do
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require_relative '../../../spec_helper'
|
2
|
+
require_lib 'reek/report/formatter/progress_formatter'
|
3
|
+
|
4
|
+
RSpec.describe Reek::Report::Formatter::ProgressFormatter::Dots do
|
5
|
+
let(:sources_count) { 23 }
|
6
|
+
let(:formatter) { described_class.new(sources_count) }
|
7
|
+
|
8
|
+
describe '#header' do
|
9
|
+
it 'announces the number of files to be inspected' do
|
10
|
+
expect(formatter.header).to eq "Inspecting 23 file(s):\n"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#progress' do
|
15
|
+
let(:clean_examiner) { instance_double(Reek::Examiner, smelly?: false) }
|
16
|
+
let(:smelly_examiner) { instance_double(Reek::Examiner, smelly?: true) }
|
17
|
+
|
18
|
+
context 'with colors disabled' do
|
19
|
+
before do
|
20
|
+
Rainbow.enabled = false
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'returns a dot for clean files' do
|
24
|
+
expect(formatter.progress(clean_examiner)).to eq '.'
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns an S for smelly files' do
|
28
|
+
expect(formatter.progress(smelly_examiner)).to eq 'S'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#footer' do
|
34
|
+
it 'returns some blank lines to offset the output' do
|
35
|
+
expect(formatter.footer).to eq "\n\n"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
RSpec.describe Reek::Report::Formatter::ProgressFormatter::Quiet do
|
41
|
+
let(:sources_count) { 23 }
|
42
|
+
let(:formatter) { described_class.new(sources_count) }
|
43
|
+
|
44
|
+
describe '#header' do
|
45
|
+
it 'is quiet' do
|
46
|
+
expect(formatter.header).to eq ''
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#progress' do
|
51
|
+
let(:clean_examiner) { instance_double(Reek::Examiner, smelly?: false) }
|
52
|
+
let(:smelly_examiner) { instance_double(Reek::Examiner, smelly?: true) }
|
53
|
+
|
54
|
+
it 'is quiet for clean files' do
|
55
|
+
expect(formatter.progress(clean_examiner)).to eq ''
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'is quiet for smelly files' do
|
59
|
+
expect(formatter.progress(smelly_examiner)).to eq ''
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe '#footer' do
|
64
|
+
it 'is quiet' do
|
65
|
+
expect(formatter.footer).to eq ''
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative '../../spec_helper'
|
2
2
|
require_lib 'reek/examiner'
|
3
|
-
require_lib 'reek/report/
|
3
|
+
require_lib 'reek/report/json_report'
|
4
4
|
require_lib 'reek/report/formatter'
|
5
5
|
|
6
6
|
require 'json'
|
@@ -55,7 +55,7 @@ RSpec.describe Reek::Report::JSONReport do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
context 'with link formatter' do
|
58
|
-
let(:options) { { warning_formatter: Reek::Report::WikiLinkWarningFormatter.new } }
|
58
|
+
let(:options) { { warning_formatter: Reek::Report::Formatter::WikiLinkWarningFormatter.new } }
|
59
59
|
|
60
60
|
it 'prints documentation links' do
|
61
61
|
out = StringIO.new
|
@@ -1,16 +1,15 @@
|
|
1
1
|
require_relative '../../spec_helper'
|
2
2
|
require_lib 'reek/examiner'
|
3
|
-
require_lib 'reek/report/
|
3
|
+
require_lib 'reek/report/text_report'
|
4
4
|
require_lib 'reek/report/formatter'
|
5
|
-
require_lib 'reek/report/heading_formatter'
|
6
5
|
require 'rainbow'
|
7
6
|
|
8
7
|
RSpec.describe Reek::Report::TextReport do
|
9
8
|
let(:report_options) do
|
10
9
|
{
|
11
|
-
warning_formatter: Reek::Report::SimpleWarningFormatter.new,
|
10
|
+
warning_formatter: Reek::Report::Formatter::SimpleWarningFormatter.new,
|
12
11
|
report_formatter: Reek::Report::Formatter,
|
13
|
-
heading_formatter: Reek::Report::
|
12
|
+
heading_formatter: Reek::Report::Formatter::QuietHeadingFormatter
|
14
13
|
}
|
15
14
|
end
|
16
15
|
let(:instance) { described_class.new report_options }
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative '../../spec_helper'
|
2
2
|
require_lib 'reek/examiner'
|
3
|
-
require_lib 'reek/report/
|
3
|
+
require_lib 'reek/report/yaml_report'
|
4
4
|
require_lib 'reek/report/formatter'
|
5
5
|
|
6
6
|
require 'yaml'
|
@@ -51,7 +51,7 @@ RSpec.describe Reek::Report::YAMLReport do
|
|
51
51
|
expect(result).to eq expected
|
52
52
|
end
|
53
53
|
context 'with link formatter' do
|
54
|
-
let(:options) { { warning_formatter: Reek::Report::WikiLinkWarningFormatter.new } }
|
54
|
+
let(:options) { { warning_formatter: Reek::Report::Formatter::WikiLinkWarningFormatter.new } }
|
55
55
|
|
56
56
|
it 'prints documentation links' do
|
57
57
|
out = StringIO.new
|
data/spec/reek/report_spec.rb
CHANGED
@@ -10,19 +10,19 @@ RSpec.describe Reek::Report do
|
|
10
10
|
|
11
11
|
describe '.location_formatter' do
|
12
12
|
it 'returns the correct class' do
|
13
|
-
expect(described_class.location_formatter(:plain)).to eq Reek::Report::BlankLocationFormatter
|
13
|
+
expect(described_class.location_formatter(:plain)).to eq Reek::Report::Formatter::BlankLocationFormatter
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
describe '.heading_formatter' do
|
18
18
|
it 'returns the correct class' do
|
19
|
-
expect(described_class.heading_formatter(:quiet)).to eq Reek::Report::
|
19
|
+
expect(described_class.heading_formatter(:quiet)).to eq Reek::Report::Formatter::QuietHeadingFormatter
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
describe '.warning_formatter_class' do
|
24
24
|
it 'returns the correct class' do
|
25
|
-
expect(described_class.warning_formatter_class(:simple)).to eq Reek::Report::SimpleWarningFormatter
|
25
|
+
expect(described_class.warning_formatter_class(:simple)).to eq Reek::Report::Formatter::SimpleWarningFormatter
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative '../../spec_helper'
|
2
|
-
require_lib 'reek/
|
2
|
+
require_lib 'reek/smell_detectors/attribute'
|
3
3
|
|
4
|
-
RSpec.describe Reek::
|
4
|
+
RSpec.describe Reek::SmellDetectors::Attribute do
|
5
5
|
it 'reports the right values' do
|
6
6
|
src = <<-EOS
|
7
7
|
class Alfa
|
@@ -1,24 +1,24 @@
|
|
1
1
|
require_relative '../../spec_helper'
|
2
|
-
require_lib 'reek/
|
2
|
+
require_lib 'reek/smell_detectors/base_detector'
|
3
3
|
|
4
|
-
RSpec.describe Reek::
|
4
|
+
RSpec.describe Reek::SmellDetectors::BaseDetector do
|
5
5
|
describe '.todo_configuration_for' do
|
6
6
|
it 'returns exclusion configuration for the given smells' do
|
7
7
|
detector = described_class.new
|
8
8
|
smell = create(:smell_warning, smell_detector: detector, context: 'Foo#bar')
|
9
9
|
result = described_class.todo_configuration_for([smell])
|
10
|
-
expect(result).to eq('
|
10
|
+
expect(result).to eq('BaseDetector' => { 'exclude' => ['Foo#bar'] })
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'merges identical contexts' do
|
14
14
|
detector = described_class.new
|
15
15
|
smell = create(:smell_warning, smell_detector: detector, context: 'Foo#bar')
|
16
16
|
result = described_class.todo_configuration_for([smell, smell])
|
17
|
-
expect(result).to eq('
|
17
|
+
expect(result).to eq('BaseDetector' => { 'exclude' => ['Foo#bar'] })
|
18
18
|
end
|
19
19
|
|
20
20
|
context 'with default exclusions present' do
|
21
|
-
let(:subclass) { Reek::
|
21
|
+
let(:subclass) { Reek::SmellDetectors::TooManyStatements }
|
22
22
|
|
23
23
|
before do
|
24
24
|
expect(subclass.default_config['exclude']).to eq ['initialize']
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative '../../spec_helper'
|
2
|
-
require_lib 'reek/
|
2
|
+
require_lib 'reek/smell_detectors/boolean_parameter'
|
3
3
|
|
4
|
-
RSpec.describe Reek::
|
4
|
+
RSpec.describe Reek::SmellDetectors::BooleanParameter do
|
5
5
|
it 'reports the right values' do
|
6
6
|
src = <<-EOS
|
7
7
|
def alfa(bravo = true)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative '../../spec_helper'
|
2
|
-
require_lib 'reek/
|
2
|
+
require_lib 'reek/smell_detectors/class_variable'
|
3
3
|
|
4
|
-
RSpec.describe Reek::
|
4
|
+
RSpec.describe Reek::SmellDetectors::ClassVariable do
|
5
5
|
it 'reports the right values' do
|
6
6
|
src = <<-EOS
|
7
7
|
class Alfa
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative '../../spec_helper'
|
2
|
-
require_lib 'reek/
|
2
|
+
require_lib 'reek/smell_detectors/control_parameter'
|
3
3
|
|
4
|
-
RSpec.describe Reek::
|
4
|
+
RSpec.describe Reek::SmellDetectors::ControlParameter do
|
5
5
|
it 'reports the right values' do
|
6
6
|
src = <<-EOS
|
7
7
|
def alfa(bravo)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative '../../spec_helper'
|
2
|
-
require_lib 'reek/
|
2
|
+
require_lib 'reek/smell_detectors/data_clump'
|
3
3
|
|
4
|
-
RSpec.describe Reek::
|
4
|
+
RSpec.describe Reek::SmellDetectors::DataClump do
|
5
5
|
it 'reports the right values' do
|
6
6
|
src = <<-EOS
|
7
7
|
class Alfa
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require_lib 'reek/smell_detectors/base_detector'
|
3
|
+
require_lib 'reek/smell_detectors/detector_repository'
|
4
|
+
|
5
|
+
RSpec.describe Reek::SmellDetectors::DetectorRepository do
|
6
|
+
describe '.smell_types' do
|
7
|
+
let(:smell_types) { described_class.smell_types }
|
8
|
+
|
9
|
+
it 'includes existing smell_types' do
|
10
|
+
expect(smell_types).to include(Reek::SmellDetectors::IrresponsibleModule).
|
11
|
+
and include(Reek::SmellDetectors::TooManyStatements)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'excludes the smell detector base class' do
|
15
|
+
expect(smell_types).not_to include(Reek::SmellDetectors::BaseDetector)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'returns the smell types in alphabetic order' do
|
19
|
+
expect(smell_types).to eq(smell_types.sort_by(&:name))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative '../../spec_helper'
|
2
|
-
require_lib 'reek/
|
2
|
+
require_lib 'reek/smell_detectors/duplicate_method_call'
|
3
3
|
|
4
|
-
RSpec.describe Reek::
|
4
|
+
RSpec.describe Reek::SmellDetectors::DuplicateMethodCall do
|
5
5
|
it 'reports the right values' do
|
6
6
|
src = <<-EOS
|
7
7
|
class Alfa
|
@@ -164,7 +164,7 @@ RSpec.describe Reek::Smells::DuplicateMethodCall do
|
|
164
164
|
|
165
165
|
context 'allowing up to 3 calls' do
|
166
166
|
let(:config) do
|
167
|
-
{ Reek::
|
167
|
+
{ Reek::SmellDetectors::DuplicateMethodCall::MAX_ALLOWED_CALLS_KEY => 3 }
|
168
168
|
end
|
169
169
|
|
170
170
|
it 'does not report double calls' do
|
@@ -191,19 +191,19 @@ RSpec.describe Reek::Smells::DuplicateMethodCall do
|
|
191
191
|
|
192
192
|
context 'allowing calls to some methods' do
|
193
193
|
it 'does not report calls to some methods' do
|
194
|
-
config = { Reek::
|
194
|
+
config = { Reek::SmellDetectors::DuplicateMethodCall::ALLOW_CALLS_KEY => ['@bravo.charlie'] }
|
195
195
|
src = 'def alfa; @bravo.charlie + @bravo.charlie; end'
|
196
196
|
expect(src).not_to reek_of(:DuplicateMethodCall).with_config(config)
|
197
197
|
end
|
198
198
|
|
199
199
|
it 'reports calls to other methods' do
|
200
|
-
config = { Reek::
|
200
|
+
config = { Reek::SmellDetectors::DuplicateMethodCall::ALLOW_CALLS_KEY => ['@delta.charlie'] }
|
201
201
|
src = 'def alfa; @bravo.charlie + @bravo.charlie; end'
|
202
202
|
expect(src).to reek_of(:DuplicateMethodCall, name: '@bravo.charlie').with_config(config)
|
203
203
|
end
|
204
204
|
|
205
205
|
it 'does not report calls to methods specifed with a regular expression' do
|
206
|
-
config = { Reek::
|
206
|
+
config = { Reek::SmellDetectors::DuplicateMethodCall::ALLOW_CALLS_KEY => [/charlie/] }
|
207
207
|
src = 'def alfa; puts @bravo.charlie; puts @bravo.charlie; end'
|
208
208
|
expect(src).not_to reek_of(:DuplicateMethodCall, name: '@bravo.charlie').with_config(config)
|
209
209
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative '../../spec_helper'
|
2
|
-
require_lib 'reek/
|
2
|
+
require_lib 'reek/smell_detectors/feature_envy'
|
3
3
|
|
4
|
-
RSpec.describe Reek::
|
4
|
+
RSpec.describe Reek::SmellDetectors::FeatureEnvy do
|
5
5
|
it 'reports the right values' do
|
6
6
|
src = <<-EOS
|
7
7
|
class Alfa
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require_relative '../../spec_helper'
|
2
2
|
|
3
|
-
require_lib 'reek/
|
3
|
+
require_lib 'reek/smell_detectors/instance_variable_assumption'
|
4
4
|
|
5
|
-
RSpec.describe Reek::
|
5
|
+
RSpec.describe Reek::SmellDetectors::InstanceVariableAssumption do
|
6
6
|
it 'reports the right values' do
|
7
7
|
src = <<-EOS
|
8
8
|
class Alfa
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative '../../spec_helper'
|
2
|
-
require_lib 'reek/
|
2
|
+
require_lib 'reek/smell_detectors/irresponsible_module'
|
3
3
|
|
4
|
-
RSpec.describe Reek::
|
4
|
+
RSpec.describe Reek::SmellDetectors::IrresponsibleModule do
|
5
5
|
it 'reports the right values' do
|
6
6
|
src = <<-EOS
|
7
7
|
class Alfa
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative '../../spec_helper'
|
2
|
-
require_lib 'reek/
|
2
|
+
require_lib 'reek/smell_detectors/long_parameter_list'
|
3
3
|
|
4
|
-
RSpec.describe Reek::
|
4
|
+
RSpec.describe Reek::SmellDetectors::LongParameterList do
|
5
5
|
it 'reports the right values' do
|
6
6
|
src = <<-EOS
|
7
7
|
class Alfa
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative '../../spec_helper'
|
2
|
-
require_lib 'reek/
|
2
|
+
require_lib 'reek/smell_detectors/long_yield_list'
|
3
3
|
|
4
|
-
RSpec.describe Reek::
|
4
|
+
RSpec.describe Reek::SmellDetectors::LongYieldList do
|
5
5
|
it 'reports the right values' do
|
6
6
|
src = <<-EOS
|
7
7
|
class Alfa
|