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
@@ -4,69 +4,58 @@ Feature: Masking smells using config files
|
|
4
4
|
I want to mask some smells using config files
|
5
5
|
|
6
6
|
Scenario: empty config file is ignored
|
7
|
-
|
7
|
+
Given a smelly file called 'smelly.rb'
|
8
|
+
And an empty configuration file called 'empty.reek'
|
9
|
+
When I run reek -c empty.reek smelly.rb
|
8
10
|
Then it reports the error 'Warning: Invalid configuration file "empty.reek" -- Empty file'
|
9
11
|
And the exit status indicates smells
|
10
12
|
And it reports:
|
11
13
|
"""
|
12
|
-
|
13
|
-
[5]:
|
14
|
-
[4,
|
15
|
-
[
|
16
|
-
[5]:Dirty#a contains iterators nested 2 deep (NestedIterators)
|
17
|
-
[3]:Dirty#a has the name 'a' (UncommunicativeMethodName)
|
18
|
-
[5]:Dirty#a has the variable name 'x' (UncommunicativeVariableName)
|
14
|
+
smelly.rb -- 3 warnings:
|
15
|
+
[4, 5]:Smelly#m calls @foo.bar 2 times (DuplicateMethodCall)
|
16
|
+
[4, 5]:Smelly#m calls puts(@foo.bar) 2 times (DuplicateMethodCall)
|
17
|
+
[3]:Smelly#m has the name 'm' (UncommunicativeMethodName)
|
19
18
|
"""
|
20
19
|
|
21
20
|
Scenario: corrupt config file prevents normal output
|
22
|
-
|
21
|
+
Given a smelly file called 'smelly.rb'
|
22
|
+
And a corrupt configuration file called 'corrupt.reek'
|
23
|
+
When I run reek -c corrupt.reek smelly.rb
|
23
24
|
Then it reports the error 'Error: Invalid configuration file "corrupt.reek" -- Not a hash'
|
24
25
|
And the exit status indicates an error
|
25
26
|
And it reports nothing
|
26
27
|
|
27
28
|
Scenario: missing source file is an error
|
28
|
-
When I run reek
|
29
|
-
Then it reports the error "Error: No such file -
|
30
|
-
|
31
|
-
Scenario: switch off one smell
|
32
|
-
When I run reek -c spec/samples/masked/masked.reek spec/samples/masked/dirty.rb
|
33
|
-
Then the exit status indicates smells
|
34
|
-
And it reports:
|
35
|
-
"""
|
36
|
-
spec/samples/masked/dirty.rb -- 3 warnings:
|
37
|
-
[4, 6]:Dirty#a calls @s.title 2 times (DuplicateMethodCall)
|
38
|
-
[4, 6]:Dirty#a calls puts(@s.title) 2 times (DuplicateMethodCall)
|
39
|
-
[5]:Dirty#a contains iterators nested 2 deep (NestedIterators)
|
40
|
-
"""
|
29
|
+
When I run reek not_here.rb
|
30
|
+
Then it reports the error "Error: No such file - not_here.rb"
|
41
31
|
|
42
|
-
Scenario:
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
[5]:Dirty has the variable name '@s' (UncommunicativeVariableName)
|
49
|
-
[4, 6]:Dirty#a calls @s.title 2 times (DuplicateMethodCall)
|
50
|
-
[4, 6]:Dirty#a calls puts(@s.title) 2 times (DuplicateMethodCall)
|
51
|
-
[5]:Dirty#a contains iterators nested 2 deep (NestedIterators)
|
52
|
-
[3]:Dirty#a has the name 'a' (UncommunicativeMethodName)
|
53
|
-
"""
|
32
|
+
Scenario: masking smells in the configuration file
|
33
|
+
Given a smelly file called 'smelly.rb'
|
34
|
+
And a masking configuration file called 'config.reek'
|
35
|
+
When I run reek -c config.reek smelly.rb
|
36
|
+
Then it succeeds
|
37
|
+
And it reports nothing
|
54
38
|
|
55
39
|
Scenario: allow masking some calls for duplication smell
|
56
|
-
|
40
|
+
Given a smelly file called 'smelly.rb'
|
41
|
+
And a configuration file masking some duplication smells called 'config.reek'
|
42
|
+
When I run reek -c config.reek smelly.rb
|
57
43
|
Then the exit status indicates smells
|
58
44
|
And it reports:
|
59
45
|
"""
|
60
|
-
|
61
|
-
[4,
|
62
|
-
[
|
46
|
+
smelly.rb -- 2 warnings:
|
47
|
+
[4, 5]:Smelly#m calls @foo.bar 2 times (DuplicateMethodCall)
|
48
|
+
[3]:Smelly#m has the name 'm' (UncommunicativeMethodName)
|
63
49
|
"""
|
64
50
|
|
65
51
|
Scenario: provide extra masking inline in comments
|
66
|
-
|
52
|
+
Given a smelly file with inline masking called 'inline.rb'
|
53
|
+
And a masking configuration file called 'config.reek'
|
54
|
+
When I run reek -c config.reek inline.rb
|
67
55
|
Then the exit status indicates smells
|
68
56
|
And it reports:
|
69
57
|
"""
|
70
|
-
|
71
|
-
[5
|
58
|
+
inline.rb -- 2 warnings:
|
59
|
+
[5]:Dirty has the variable name '@s' (UncommunicativeVariableName)
|
60
|
+
[5]:Dirty#a has the variable name 'x' (UncommunicativeVariableName)
|
72
61
|
"""
|
@@ -3,11 +3,13 @@ Feature: Overriding current rules by specifying new configuration values
|
|
3
3
|
As a developer
|
4
4
|
I want to be able to override the default configuration values
|
5
5
|
|
6
|
-
Scenario: List of configuration values is overridden by a lower
|
7
|
-
|
6
|
+
Scenario: List of configuration values is overridden by a lower configuration file
|
7
|
+
Given a file with smelly variable names called 'camel_case.rb'
|
8
|
+
And a configuration file allowing camel case variables
|
9
|
+
When I run reek camel_case.rb
|
8
10
|
Then the exit status indicates smells
|
9
11
|
And it reports:
|
10
12
|
"""
|
11
|
-
|
13
|
+
camel_case.rb -- 1 warning:
|
12
14
|
[9]:CamelCase#initialize has the variable name 'x1' (UncommunicativeVariableName)
|
13
15
|
"""
|
@@ -11,52 +11,55 @@ Feature: Offer different ways how to load configuration
|
|
11
11
|
And finally, it should check your HOME directory.
|
12
12
|
|
13
13
|
Scenario: No configuration
|
14
|
-
|
14
|
+
Given a smelly file called 'smelly.rb'
|
15
|
+
When I run reek smelly.rb
|
15
16
|
Then the exit status indicates smells
|
16
17
|
And it reports:
|
17
18
|
"""
|
18
|
-
|
19
|
-
[
|
20
|
-
[
|
21
|
-
[
|
19
|
+
smelly.rb -- 3 warnings:
|
20
|
+
[4, 5]:Smelly#m calls @foo.bar 2 times (DuplicateMethodCall)
|
21
|
+
[4, 5]:Smelly#m calls puts(@foo.bar) 2 times (DuplicateMethodCall)
|
22
|
+
[3]:Smelly#m has the name 'm' (UncommunicativeMethodName)
|
22
23
|
"""
|
23
24
|
|
24
25
|
Scenario: Configuration via CLI
|
25
|
-
|
26
|
+
Given a smelly file called 'smelly.rb'
|
27
|
+
And a masking configuration file called 'config.reek'
|
28
|
+
When I run reek -c config.reek smelly.rb
|
26
29
|
Then it reports no errors
|
27
30
|
And it succeeds
|
28
31
|
|
29
|
-
@remove-disable-smell-config-from-current-dir
|
30
32
|
Scenario: Configuration file in working directory
|
31
|
-
Given
|
32
|
-
|
33
|
+
Given a smelly file called 'smelly.rb'
|
34
|
+
And a masking configuration file called 'config.reek'
|
35
|
+
When I run reek smelly.rb
|
33
36
|
Then it reports no errors
|
34
37
|
And it succeeds
|
35
38
|
|
36
|
-
@remove-disable-smell-config-from-parent-dir
|
37
39
|
Scenario: Configuration file in the parent directory of the working directory
|
38
|
-
Given
|
39
|
-
|
40
|
+
Given a smelly file called 'smelly.rb' in a subdirectory
|
41
|
+
And a masking configuration file called 'config.reek'
|
42
|
+
When I run "reek smelly.rb" in the subdirectory
|
40
43
|
Then it reports no errors
|
41
44
|
And it succeeds
|
42
45
|
|
43
|
-
@remove-disable-smell-config-from-home-dir
|
44
46
|
Scenario: Configuration file in the HOME directory
|
45
|
-
Given
|
46
|
-
|
47
|
+
Given a smelly file called 'smelly.rb'
|
48
|
+
And a masking configuration file in the HOME directory
|
49
|
+
When I run reek smelly.rb
|
47
50
|
Then it reports no errors
|
48
51
|
And it succeeds
|
49
52
|
|
50
|
-
@remove-enable-smell-config-from-current-dir @remove-disable-smell-config-from-parent-dir
|
51
53
|
Scenario: Two opposing configuration files and we stop after the first one
|
52
|
-
Given
|
53
|
-
And
|
54
|
-
|
54
|
+
Given a smelly file called 'smelly.rb' in a subdirectory
|
55
|
+
And an enabling configuration file in the subdirectory
|
56
|
+
And a masking configuration file called 'config.reek'
|
57
|
+
When I run "reek smelly.rb" in the subdirectory
|
55
58
|
Then the exit status indicates smells
|
56
59
|
And it reports:
|
57
60
|
"""
|
58
|
-
|
59
|
-
[
|
60
|
-
[
|
61
|
-
[
|
61
|
+
smelly.rb -- 3 warnings:
|
62
|
+
[4, 5]:Smelly#m calls @foo.bar 2 times (DuplicateMethodCall)
|
63
|
+
[4, 5]:Smelly#m calls puts(@foo.bar) 2 times (DuplicateMethodCall)
|
64
|
+
[3]:Smelly#m has the name 'm' (UncommunicativeMethodName)
|
62
65
|
"""
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Feature: Using reek programmatically
|
2
|
+
In order to use reek from inside my program
|
3
|
+
As a developer
|
4
|
+
I want to be able to use its classes
|
5
|
+
|
6
|
+
Scenario:
|
7
|
+
Given a smelly file called 'smelly.rb'
|
8
|
+
And a file named "examine.rb" with:
|
9
|
+
"""
|
10
|
+
require 'reek'
|
11
|
+
examiner = Reek::Examiner.new(['smelly.rb'])
|
12
|
+
examiner.smells.each do |smell|
|
13
|
+
puts smell.message
|
14
|
+
end
|
15
|
+
"""
|
16
|
+
When I run `ruby examine.rb`
|
17
|
+
Then it reports no errors
|
18
|
+
And it reports:
|
19
|
+
"""
|
20
|
+
calls @foo.bar 2 times
|
21
|
+
calls puts(@foo.bar) 2 times
|
22
|
+
has the name 'm'
|
23
|
+
"""
|
24
|
+
|
@@ -3,56 +3,60 @@ Feature: Reek can be driven through its Task
|
|
3
3
|
via the Task class. These scenarios test its various options.
|
4
4
|
|
5
5
|
Scenario: source_files points at the desired files
|
6
|
+
Given a smelly file called 'smelly.rb'
|
6
7
|
When I run rake reek with:
|
7
8
|
"""
|
8
9
|
Reek::Rake::Task.new do |t|
|
9
|
-
t.source_files = '
|
10
|
+
t.source_files = 'smelly.rb'
|
10
11
|
t.reek_opts = '--no-color'
|
11
12
|
end
|
12
13
|
"""
|
13
14
|
Then the exit status indicates an error
|
14
15
|
And it reports:
|
15
16
|
"""
|
16
|
-
|
17
|
-
[
|
18
|
-
[
|
19
|
-
[
|
17
|
+
smelly.rb -- 3 warnings:
|
18
|
+
[4, 5]:Smelly#m calls @foo.bar 2 times (DuplicateMethodCall)
|
19
|
+
[4, 5]:Smelly#m calls puts(@foo.bar) 2 times (DuplicateMethodCall)
|
20
|
+
[3]:Smelly#m has the name 'm' (UncommunicativeMethodName)
|
20
21
|
"""
|
21
22
|
|
22
23
|
Scenario: name changes the task name
|
24
|
+
Given a smelly file called 'smelly.rb'
|
23
25
|
When I run rake silky with:
|
24
26
|
"""
|
25
27
|
Reek::Rake::Task.new('silky') do |t|
|
26
|
-
t.source_files = '
|
28
|
+
t.source_files = 'smelly.rb'
|
27
29
|
t.reek_opts = '--no-color'
|
28
30
|
end
|
29
31
|
"""
|
30
32
|
Then the exit status indicates an error
|
31
33
|
And it reports:
|
32
34
|
"""
|
33
|
-
|
34
|
-
[
|
35
|
-
[
|
36
|
-
[
|
35
|
+
smelly.rb -- 3 warnings:
|
36
|
+
[4, 5]:Smelly#m calls @foo.bar 2 times (DuplicateMethodCall)
|
37
|
+
[4, 5]:Smelly#m calls puts(@foo.bar) 2 times (DuplicateMethodCall)
|
38
|
+
[3]:Smelly#m has the name 'm' (UncommunicativeMethodName)
|
37
39
|
"""
|
38
40
|
|
39
41
|
Scenario: verbose prints the reek command
|
42
|
+
Given a smelly file called 'smelly.rb'
|
40
43
|
When I run rake reek with:
|
41
44
|
"""
|
42
45
|
Reek::Rake::Task.new do |t|
|
43
|
-
t.source_files = '
|
46
|
+
t.source_files = 'smelly.rb'
|
44
47
|
t.verbose = true
|
45
48
|
end
|
46
49
|
"""
|
47
50
|
Then the exit status indicates an error
|
48
|
-
And stdout includes "
|
51
|
+
And stdout includes "Running 'reek' rake command"
|
49
52
|
|
50
53
|
Scenario: fail_on_error can hide the error status
|
54
|
+
Given a smelly file called 'smelly.rb'
|
51
55
|
When I run rake reek with:
|
52
56
|
"""
|
53
57
|
Reek::Rake::Task.new do |t|
|
54
58
|
t.fail_on_error = false
|
55
|
-
t.source_files = '
|
59
|
+
t.source_files = 'smelly.rb'
|
56
60
|
t.reek_opts = '--no-color'
|
57
61
|
end
|
58
62
|
"""
|
@@ -60,21 +64,20 @@ Feature: Reek can be driven through its Task
|
|
60
64
|
And it succeeds
|
61
65
|
And it reports:
|
62
66
|
"""
|
63
|
-
|
64
|
-
[5]:
|
65
|
-
[4,
|
66
|
-
[
|
67
|
-
[5]:Dirty#a contains iterators nested 2 deep (NestedIterators)
|
68
|
-
[3]:Dirty#a has the name 'a' (UncommunicativeMethodName)
|
69
|
-
[5]:Dirty#a has the variable name 'x' (UncommunicativeVariableName)
|
67
|
+
smelly.rb -- 3 warnings:
|
68
|
+
[4, 5]:Smelly#m calls @foo.bar 2 times (DuplicateMethodCall)
|
69
|
+
[4, 5]:Smelly#m calls puts(@foo.bar) 2 times (DuplicateMethodCall)
|
70
|
+
[3]:Smelly#m has the name 'm' (UncommunicativeMethodName)
|
70
71
|
"""
|
71
72
|
|
72
73
|
Scenario: can be configured with config_file
|
74
|
+
Given a smelly file called 'smelly.rb'
|
75
|
+
And a masking configuration file called 'config.reek'
|
73
76
|
When I run rake reek with:
|
74
77
|
"""
|
75
78
|
Reek::Rake::Task.new do |t|
|
76
|
-
t.config_file = '
|
77
|
-
t.source_files = '
|
79
|
+
t.config_file = 'config.reek'
|
80
|
+
t.source_files = 'smelly.rb'
|
78
81
|
end
|
79
82
|
"""
|
80
83
|
Then it succeeds
|
@@ -3,7 +3,8 @@ Feature: Report smells using simple JSON layout
|
|
3
3
|
output a list of smells in JSON.
|
4
4
|
|
5
5
|
Scenario: output is empty when there are no smells
|
6
|
-
|
6
|
+
Given a directory called 'clean_files' containing some clean files
|
7
|
+
When I run reek --format json clean_files
|
7
8
|
Then it succeeds
|
8
9
|
And it reports this JSON:
|
9
10
|
"""
|
@@ -11,41 +12,38 @@ Feature: Report smells using simple JSON layout
|
|
11
12
|
"""
|
12
13
|
|
13
14
|
Scenario: Indicate smells and print them as JSON when using files
|
14
|
-
|
15
|
+
Given a smelly file called 'smelly.rb'
|
16
|
+
When I run reek --format json smelly.rb
|
15
17
|
Then the exit status indicates smells
|
16
18
|
And it reports this JSON:
|
17
19
|
"""
|
18
20
|
[
|
19
21
|
{
|
20
|
-
"smell_category": "
|
21
|
-
"smell_type": "
|
22
|
-
"source": "
|
23
|
-
"context": "
|
24
|
-
"lines": [
|
25
|
-
|
26
|
-
|
27
|
-
"
|
28
|
-
"name": "C"
|
22
|
+
"smell_category": "Duplication",
|
23
|
+
"smell_type": "DuplicateMethodCall",
|
24
|
+
"source": "smelly.rb",
|
25
|
+
"context": "Smelly#m",
|
26
|
+
"lines": [ 4, 5 ],
|
27
|
+
"message": "calls @foo.bar 2 times",
|
28
|
+
"name": "@foo.bar",
|
29
|
+
"count": 2
|
29
30
|
},
|
30
31
|
{
|
31
|
-
"smell_category": "
|
32
|
-
"smell_type": "
|
33
|
-
"source": "
|
34
|
-
"context": "
|
35
|
-
"lines": [
|
36
|
-
|
37
|
-
|
38
|
-
"
|
39
|
-
"name": "C"
|
32
|
+
"smell_category": "Duplication",
|
33
|
+
"smell_type": "DuplicateMethodCall",
|
34
|
+
"source": "smelly.rb",
|
35
|
+
"context": "Smelly#m",
|
36
|
+
"lines": [ 4, 5 ],
|
37
|
+
"message": "calls puts(@foo.bar) 2 times",
|
38
|
+
"name": "puts(@foo.bar)",
|
39
|
+
"count": 2
|
40
40
|
},
|
41
41
|
{
|
42
42
|
"smell_category": "UncommunicativeName",
|
43
43
|
"smell_type": "UncommunicativeMethodName",
|
44
|
-
"source": "
|
45
|
-
"context": "
|
46
|
-
"lines": [
|
47
|
-
2
|
48
|
-
],
|
44
|
+
"source": "smelly.rb",
|
45
|
+
"context": "Smelly#m",
|
46
|
+
"lines": [ 3 ],
|
49
47
|
"message": "has the name 'm'",
|
50
48
|
"name": "m"
|
51
49
|
}
|
@@ -61,7 +59,7 @@ Feature: Report smells using simple JSON layout
|
|
61
59
|
{
|
62
60
|
"smell_category": "IrresponsibleModule",
|
63
61
|
"smell_type": "IrresponsibleModule",
|
64
|
-
"source": "
|
62
|
+
"source": "STDIN",
|
65
63
|
"context": "Turn",
|
66
64
|
"lines": [
|
67
65
|
1
|
@@ -4,50 +4,40 @@ Feature: Correctly formatted reports
|
|
4
4
|
I want to be able to parse reek's output simply and consistently
|
5
5
|
|
6
6
|
Scenario Outline: two reports run together with indented smells
|
7
|
+
Given a directory called 'smelly' containing two smelly files
|
7
8
|
When I run reek <args>
|
8
9
|
Then the exit status indicates smells
|
9
10
|
And it reports:
|
10
11
|
"""
|
11
|
-
|
12
|
-
[
|
13
|
-
[
|
14
|
-
|
15
|
-
[
|
16
|
-
[
|
17
|
-
[
|
18
|
-
|
19
|
-
[5]:Dirty has the variable name '@s' (UncommunicativeVariableName)
|
20
|
-
[4, 6]:Dirty#a calls @s.title 2 times (DuplicateMethodCall)
|
21
|
-
[4, 6]:Dirty#a calls puts(@s.title) 2 times (DuplicateMethodCall)
|
22
|
-
[5]:Dirty#a contains iterators nested 2 deep (NestedIterators)
|
23
|
-
[3]:Dirty#a has the name 'a' (UncommunicativeMethodName)
|
24
|
-
[5]:Dirty#a has the variable name 'x' (UncommunicativeVariableName)
|
25
|
-
12 total warnings
|
12
|
+
smelly/dirty_one.rb -- 2 warnings:
|
13
|
+
[1]:Dirty has no descriptive comment (IrresponsibleModule)
|
14
|
+
[2]:Dirty#a has the name 'a' (UncommunicativeMethodName)
|
15
|
+
smelly/dirty_two.rb -- 3 warnings:
|
16
|
+
[1]:Dirty has no descriptive comment (IrresponsibleModule)
|
17
|
+
[2]:Dirty#a has the name 'a' (UncommunicativeMethodName)
|
18
|
+
[3]:Dirty#b has the name 'b' (UncommunicativeMethodName)
|
19
|
+
5 total warnings
|
26
20
|
"""
|
27
21
|
|
28
22
|
Examples:
|
29
|
-
| args
|
30
|
-
|
|
31
|
-
|
|
23
|
+
| args |
|
24
|
+
| smelly/dirty_one.rb smelly/dirty_two.rb |
|
25
|
+
| smelly |
|
32
26
|
|
33
27
|
Scenario Outline: No sorting (which means report each file as it is read in)
|
34
|
-
|
28
|
+
Given a directory called 'smelly' containing two smelly files
|
29
|
+
When I run reek <option> smelly
|
35
30
|
Then the exit status indicates smells
|
36
31
|
And it reports:
|
37
32
|
"""
|
38
|
-
|
33
|
+
smelly/dirty_one.rb -- 2 warnings:
|
39
34
|
[1]:Dirty has no descriptive comment (IrresponsibleModule)
|
40
35
|
[2]:Dirty#a has the name 'a' (UncommunicativeMethodName)
|
41
|
-
|
36
|
+
smelly/dirty_two.rb -- 3 warnings:
|
42
37
|
[1]:Dirty has no descriptive comment (IrresponsibleModule)
|
43
38
|
[2]:Dirty#a has the name 'a' (UncommunicativeMethodName)
|
44
39
|
[3]:Dirty#b has the name 'b' (UncommunicativeMethodName)
|
45
|
-
|
46
|
-
spec/samples/three_smelly_files/dirty_two.rb -- 3 warnings:
|
47
|
-
[1]:Dirty has no descriptive comment (IrresponsibleModule)
|
48
|
-
[2]:Dirty#a has the name 'a' (UncommunicativeMethodName)
|
49
|
-
[3]:Dirty#b has the name 'b' (UncommunicativeMethodName)
|
50
|
-
9 total warnings
|
40
|
+
5 total warnings
|
51
41
|
"""
|
52
42
|
|
53
43
|
Examples:
|
@@ -57,23 +47,19 @@ Feature: Correctly formatted reports
|
|
57
47
|
| --sort-by n |
|
58
48
|
|
59
49
|
Scenario Outline: Sort by issue count
|
60
|
-
|
50
|
+
Given a directory called 'smelly' containing two smelly files
|
51
|
+
When I run reek <option> smelly
|
61
52
|
Then the exit status indicates smells
|
62
53
|
And it reports:
|
63
54
|
"""
|
64
|
-
|
65
|
-
[1]:Dirty has no descriptive comment (IrresponsibleModule)
|
66
|
-
[2]:Dirty#a has the name 'a' (UncommunicativeMethodName)
|
67
|
-
[3]:Dirty#b has the name 'b' (UncommunicativeMethodName)
|
68
|
-
[4]:Dirty#c has the name 'c' (UncommunicativeMethodName)
|
69
|
-
spec/samples/three_smelly_files/dirty_two.rb -- 3 warnings:
|
55
|
+
smelly/dirty_two.rb -- 3 warnings:
|
70
56
|
[1]:Dirty has no descriptive comment (IrresponsibleModule)
|
71
57
|
[2]:Dirty#a has the name 'a' (UncommunicativeMethodName)
|
72
58
|
[3]:Dirty#b has the name 'b' (UncommunicativeMethodName)
|
73
|
-
|
59
|
+
smelly/dirty_one.rb -- 2 warnings:
|
74
60
|
[1]:Dirty has no descriptive comment (IrresponsibleModule)
|
75
61
|
[2]:Dirty#a has the name 'a' (UncommunicativeMethodName)
|
76
|
-
|
62
|
+
5 total warnings
|
77
63
|
"""
|
78
64
|
|
79
65
|
Examples:
|
@@ -81,27 +67,24 @@ Feature: Correctly formatted reports
|
|
81
67
|
| --sort-by smelliness |
|
82
68
|
| --sort-by s |
|
83
69
|
|
84
|
-
Scenario
|
85
|
-
|
70
|
+
Scenario: good files show no headings by default
|
71
|
+
Given a directory called 'clean_files' containing some clean files
|
72
|
+
When I run reek clean_files
|
86
73
|
Then it succeeds
|
87
74
|
And it reports:
|
88
75
|
"""
|
89
76
|
0 total warnings
|
90
77
|
"""
|
91
78
|
|
92
|
-
Examples:
|
93
|
-
| args |
|
94
|
-
| spec/samples/three_clean_files/*.rb |
|
95
|
-
| spec/samples/three_clean_files |
|
96
|
-
|
97
79
|
Scenario Outline: --empty-headings turns on headings for fragrant files
|
98
|
-
|
80
|
+
Given a directory called 'clean_files' containing some clean files
|
81
|
+
When I run reek <option> clean_files
|
99
82
|
Then it succeeds
|
100
83
|
And it reports:
|
101
84
|
"""
|
102
|
-
|
103
|
-
|
104
|
-
|
85
|
+
clean_files/clean_one.rb -- 0 warnings
|
86
|
+
clean_files/clean_three.rb -- 0 warnings
|
87
|
+
clean_files/clean_two.rb -- 0 warnings
|
105
88
|
0 total warnings
|
106
89
|
"""
|
107
90
|
|
@@ -111,12 +94,13 @@ Feature: Correctly formatted reports
|
|
111
94
|
| -V |
|
112
95
|
|
113
96
|
Scenario Outline: --no-empty-headings turns off headings for fragrant files
|
114
|
-
|
97
|
+
Given a directory called 'clean_files' containing some clean files
|
98
|
+
When I run reek <option> clean_files
|
115
99
|
Then it succeeds
|
116
100
|
And it reports:
|
117
|
-
|
118
|
-
|
119
|
-
|
101
|
+
"""
|
102
|
+
0 total warnings
|
103
|
+
"""
|
120
104
|
|
121
105
|
Examples:
|
122
106
|
| option |
|
@@ -124,17 +108,15 @@ Feature: Correctly formatted reports
|
|
124
108
|
| -V --no-empty-headings |
|
125
109
|
|
126
110
|
Scenario Outline: --no-line-numbers turns off line numbers
|
127
|
-
|
111
|
+
Given a smelly file called 'smelly.rb'
|
112
|
+
When I run reek <option> smelly.rb
|
128
113
|
Then the exit status indicates smells
|
129
114
|
And it reports:
|
130
115
|
"""
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
Dirty#a contains iterators nested 2 deep (NestedIterators)
|
136
|
-
Dirty#a has the name 'a' (UncommunicativeMethodName)
|
137
|
-
Dirty#a has the variable name 'x' (UncommunicativeVariableName)
|
116
|
+
smelly.rb -- 3 warnings:
|
117
|
+
Smelly#m calls @foo.bar 2 times (DuplicateMethodCall)
|
118
|
+
Smelly#m calls puts(@foo.bar) 2 times (DuplicateMethodCall)
|
119
|
+
Smelly#m has the name 'm' (UncommunicativeMethodName)
|
138
120
|
"""
|
139
121
|
|
140
122
|
Examples:
|
@@ -144,17 +126,15 @@ Feature: Correctly formatted reports
|
|
144
126
|
| -V --no-line-numbers |
|
145
127
|
|
146
128
|
Scenario Outline: --line-numbers turns on line numbers
|
147
|
-
|
129
|
+
Given a smelly file called 'smelly.rb'
|
130
|
+
When I run reek <option> smelly.rb
|
148
131
|
Then the exit status indicates smells
|
149
132
|
And it reports:
|
150
133
|
"""
|
151
|
-
|
152
|
-
[5]:
|
153
|
-
[4,
|
154
|
-
[
|
155
|
-
[5]:Dirty#a contains iterators nested 2 deep (NestedIterators)
|
156
|
-
[3]:Dirty#a has the name 'a' (UncommunicativeMethodName)
|
157
|
-
[5]:Dirty#a has the variable name 'x' (UncommunicativeVariableName)
|
134
|
+
smelly.rb -- 3 warnings:
|
135
|
+
[4, 5]:Smelly#m calls @foo.bar 2 times (DuplicateMethodCall)
|
136
|
+
[4, 5]:Smelly#m calls puts(@foo.bar) 2 times (DuplicateMethodCall)
|
137
|
+
[3]:Smelly#m has the name 'm' (UncommunicativeMethodName)
|
158
138
|
"""
|
159
139
|
|
160
140
|
Examples:
|
@@ -164,17 +144,15 @@ Feature: Correctly formatted reports
|
|
164
144
|
| --no-line-numbers -n |
|
165
145
|
|
166
146
|
Scenario Outline: --single-line shows filename and one line number
|
167
|
-
|
147
|
+
Given a smelly file called 'smelly.rb'
|
148
|
+
When I run reek <option> smelly.rb
|
168
149
|
Then the exit status indicates smells
|
169
150
|
And it reports:
|
170
151
|
"""
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
spec/samples/standard_smelly/dirty.rb:5: Dirty#a contains iterators nested 2 deep (NestedIterators)
|
176
|
-
spec/samples/standard_smelly/dirty.rb:3: Dirty#a has the name 'a' (UncommunicativeMethodName)
|
177
|
-
spec/samples/standard_smelly/dirty.rb:5: Dirty#a has the variable name 'x' (UncommunicativeVariableName)
|
152
|
+
smelly.rb -- 3 warnings:
|
153
|
+
smelly.rb:4: Smelly#m calls @foo.bar 2 times (DuplicateMethodCall)
|
154
|
+
smelly.rb:4: Smelly#m calls puts(@foo.bar) 2 times (DuplicateMethodCall)
|
155
|
+
smelly.rb:3: Smelly#m has the name 'm' (UncommunicativeMethodName)
|
178
156
|
"""
|
179
157
|
|
180
158
|
Examples:
|
@@ -185,41 +163,36 @@ Feature: Correctly formatted reports
|
|
185
163
|
| -V -s |
|
186
164
|
|
187
165
|
Scenario Outline: Extra slashes aren't added to directory names
|
166
|
+
Given a directory called 'smelly' containing two smelly files
|
188
167
|
When I run reek <args>
|
189
168
|
Then the exit status indicates smells
|
190
169
|
And it reports:
|
191
170
|
"""
|
192
|
-
|
193
|
-
[
|
194
|
-
[
|
195
|
-
|
196
|
-
[
|
197
|
-
[
|
198
|
-
[
|
199
|
-
|
200
|
-
[5]:Dirty has the variable name '@s' (UncommunicativeVariableName)
|
201
|
-
[4, 6]:Dirty#a calls @s.title 2 times (DuplicateMethodCall)
|
202
|
-
[4, 6]:Dirty#a calls puts(@s.title) 2 times (DuplicateMethodCall)
|
203
|
-
[5]:Dirty#a contains iterators nested 2 deep (NestedIterators)
|
204
|
-
[3]:Dirty#a has the name 'a' (UncommunicativeMethodName)
|
205
|
-
[5]:Dirty#a has the variable name 'x' (UncommunicativeVariableName)
|
206
|
-
12 total warnings
|
171
|
+
smelly/dirty_one.rb -- 2 warnings:
|
172
|
+
[1]:Dirty has no descriptive comment (IrresponsibleModule)
|
173
|
+
[2]:Dirty#a has the name 'a' (UncommunicativeMethodName)
|
174
|
+
smelly/dirty_two.rb -- 3 warnings:
|
175
|
+
[1]:Dirty has no descriptive comment (IrresponsibleModule)
|
176
|
+
[2]:Dirty#a has the name 'a' (UncommunicativeMethodName)
|
177
|
+
[3]:Dirty#b has the name 'b' (UncommunicativeMethodName)
|
178
|
+
5 total warnings
|
207
179
|
"""
|
208
180
|
|
209
181
|
Examples:
|
210
|
-
| args
|
211
|
-
|
|
212
|
-
|
|
182
|
+
| args |
|
183
|
+
| smelly/ |
|
184
|
+
| smelly |
|
213
185
|
|
214
186
|
Scenario Outline: -U or --wiki-links adds helpful links to smell warnings
|
215
|
-
|
187
|
+
Given a smelly file called 'smelly.rb'
|
188
|
+
When I run reek <option> smelly.rb
|
216
189
|
Then the exit status indicates smells
|
217
190
|
And it reports:
|
218
191
|
"""
|
219
|
-
|
220
|
-
[
|
221
|
-
[
|
222
|
-
[
|
192
|
+
smelly.rb -- 3 warnings:
|
193
|
+
[4, 5]:Smelly#m calls @foo.bar 2 times (DuplicateMethodCall) [https://github.com/troessner/reek/wiki/Duplicate-Method-Call]
|
194
|
+
[4, 5]:Smelly#m calls puts(@foo.bar) 2 times (DuplicateMethodCall) [https://github.com/troessner/reek/wiki/Duplicate-Method-Call]
|
195
|
+
[3]:Smelly#m has the name 'm' (UncommunicativeMethodName) [https://github.com/troessner/reek/wiki/Uncommunicative-Method-Name]
|
223
196
|
"""
|
224
197
|
|
225
198
|
Examples:
|
@@ -228,14 +201,15 @@ Feature: Correctly formatted reports
|
|
228
201
|
| --wiki-links |
|
229
202
|
|
230
203
|
Scenario Outline: --wiki-links is independent of --line-numbers
|
231
|
-
|
204
|
+
Given a smelly file called 'smelly.rb'
|
205
|
+
When I run reek <option> smelly.rb
|
232
206
|
Then the exit status indicates smells
|
233
207
|
And it reports:
|
234
208
|
"""
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
209
|
+
smelly.rb -- 3 warnings:
|
210
|
+
Smelly#m calls @foo.bar 2 times (DuplicateMethodCall) [https://github.com/troessner/reek/wiki/Duplicate-Method-Call]
|
211
|
+
Smelly#m calls puts(@foo.bar) 2 times (DuplicateMethodCall) [https://github.com/troessner/reek/wiki/Duplicate-Method-Call]
|
212
|
+
Smelly#m has the name 'm' (UncommunicativeMethodName) [https://github.com/troessner/reek/wiki/Uncommunicative-Method-Name]
|
239
213
|
"""
|
240
214
|
|
241
215
|
Examples:
|