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
|
@@ -3,45 +3,38 @@ Feature: Reports total number of code smells
|
|
|
3
3
|
Reek outputs the total number of smells among all files inspected.
|
|
4
4
|
|
|
5
5
|
Scenario: Does not output total number of smells when inspecting single file
|
|
6
|
-
|
|
6
|
+
Given a smelly file called 'smelly.rb'
|
|
7
|
+
When I run reek smelly.rb
|
|
7
8
|
Then the exit status indicates smells
|
|
8
9
|
And it reports:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
[3]:Dirty#a has the name 'a' (UncommunicativeMethodName)
|
|
16
|
-
[5]:Dirty#a has the variable name 'x' (UncommunicativeVariableName)
|
|
17
|
-
"""
|
|
10
|
+
"""
|
|
11
|
+
smelly.rb -- 3 warnings:
|
|
12
|
+
[4, 5]:Smelly#m calls @foo.bar 2 times (DuplicateMethodCall)
|
|
13
|
+
[4, 5]:Smelly#m calls puts(@foo.bar) 2 times (DuplicateMethodCall)
|
|
14
|
+
[3]:Smelly#m has the name 'm' (UncommunicativeMethodName)
|
|
15
|
+
"""
|
|
18
16
|
|
|
19
17
|
Scenario: Output total number of smells when inspecting multiple files
|
|
20
|
-
|
|
18
|
+
Given a directory called 'smelly' containing two smelly files
|
|
19
|
+
When I run reek smelly
|
|
21
20
|
Then the exit status indicates smells
|
|
22
21
|
And it reports:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
[4, 6]:Dirty#a calls @s.title 2 times (DuplicateMethodCall)
|
|
34
|
-
[4, 6]:Dirty#a calls puts(@s.title) 2 times (DuplicateMethodCall)
|
|
35
|
-
[5]:Dirty#a contains iterators nested 2 deep (NestedIterators)
|
|
36
|
-
[3]:Dirty#a has the name 'a' (UncommunicativeMethodName)
|
|
37
|
-
[5]:Dirty#a has the variable name 'x' (UncommunicativeVariableName)
|
|
38
|
-
12 total warnings
|
|
39
|
-
"""
|
|
22
|
+
"""
|
|
23
|
+
smelly/dirty_one.rb -- 2 warnings:
|
|
24
|
+
[1]:Dirty has no descriptive comment (IrresponsibleModule)
|
|
25
|
+
[2]:Dirty#a has the name 'a' (UncommunicativeMethodName)
|
|
26
|
+
smelly/dirty_two.rb -- 3 warnings:
|
|
27
|
+
[1]:Dirty has no descriptive comment (IrresponsibleModule)
|
|
28
|
+
[2]:Dirty#a has the name 'a' (UncommunicativeMethodName)
|
|
29
|
+
[3]:Dirty#b has the name 'b' (UncommunicativeMethodName)
|
|
30
|
+
5 total warnings
|
|
31
|
+
"""
|
|
40
32
|
|
|
41
33
|
Scenario: Output total number of smells even if total equals 0
|
|
42
|
-
|
|
34
|
+
Given a directory called 'clean_files' containing some clean files
|
|
35
|
+
When I run reek clean_files
|
|
43
36
|
Then it succeeds
|
|
44
37
|
And it reports:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
"""
|
|
39
|
+
0 total warnings
|
|
40
|
+
"""
|
|
@@ -18,7 +18,7 @@ Feature: Reek reads from $stdin when no files are given
|
|
|
18
18
|
Then it succeeds
|
|
19
19
|
And it reports:
|
|
20
20
|
"""
|
|
21
|
-
|
|
21
|
+
STDIN -- 0 warnings
|
|
22
22
|
"""
|
|
23
23
|
|
|
24
24
|
Scenario: return non-zero status when there are smells
|
|
@@ -26,7 +26,7 @@ Feature: Reek reads from $stdin when no files are given
|
|
|
26
26
|
Then the exit status indicates smells
|
|
27
27
|
And it reports:
|
|
28
28
|
"""
|
|
29
|
-
|
|
29
|
+
STDIN -- 3 warnings:
|
|
30
30
|
[1]:Turn has no descriptive comment (IrresponsibleModule)
|
|
31
31
|
[1]:Turn has the variable name '@x' (UncommunicativeVariableName)
|
|
32
32
|
[1]:Turn#y has the name 'y' (UncommunicativeMethodName)
|
|
@@ -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,43 @@
|
|
|
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: Accessing smells found by an examiner
|
|
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(File.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
|
+
|
|
25
|
+
Scenario: Using reek's built-in report classes
|
|
26
|
+
Given a smelly file called 'smelly.rb'
|
|
27
|
+
And a file named "examine.rb" with:
|
|
28
|
+
"""
|
|
29
|
+
require 'reek'
|
|
30
|
+
examiner = Reek::Examiner.new(File.new('smelly.rb'))
|
|
31
|
+
report = Reek::Report::TextReport.new
|
|
32
|
+
report.add_examiner examiner
|
|
33
|
+
report.show
|
|
34
|
+
"""
|
|
35
|
+
When I run `ruby examine.rb`
|
|
36
|
+
Then it reports no errors
|
|
37
|
+
And it reports:
|
|
38
|
+
"""
|
|
39
|
+
smelly.rb -- 3 warnings:
|
|
40
|
+
Smelly#m calls @foo.bar 2 times (DuplicateMethodCall)
|
|
41
|
+
Smelly#m calls puts(@foo.bar) 2 times (DuplicateMethodCall)
|
|
42
|
+
Smelly#m has the name 'm' (UncommunicativeMethodName)
|
|
43
|
+
"""
|
|
@@ -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
|