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
|
@@ -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:
|
|
@@ -3,7 +3,8 @@ Feature: Report smells using simple YAML layout
|
|
|
3
3
|
output a list of smells in Yaml.
|
|
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 yaml clean_files
|
|
7
8
|
Then it succeeds
|
|
8
9
|
And it reports this yaml:
|
|
9
10
|
"""
|
|
@@ -11,33 +12,38 @@ Feature: Report smells using simple YAML layout
|
|
|
11
12
|
"""
|
|
12
13
|
|
|
13
14
|
Scenario: Indicate smells and print them as yaml when using files
|
|
14
|
-
|
|
15
|
+
Given a smelly file called 'smelly.rb'
|
|
16
|
+
When I run reek --format yaml smelly.rb
|
|
15
17
|
Then the exit status indicates smells
|
|
16
18
|
And it reports this yaml:
|
|
17
19
|
"""
|
|
18
20
|
---
|
|
19
|
-
- smell_category:
|
|
20
|
-
smell_type:
|
|
21
|
-
source:
|
|
22
|
-
context:
|
|
21
|
+
- smell_category: Duplication
|
|
22
|
+
smell_type: DuplicateMethodCall
|
|
23
|
+
source: smelly.rb
|
|
24
|
+
context: Smelly#m
|
|
23
25
|
lines:
|
|
24
|
-
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
- 4
|
|
27
|
+
- 5
|
|
28
|
+
message: calls @foo.bar 2 times
|
|
29
|
+
name: "@foo.bar"
|
|
30
|
+
count: 2
|
|
31
|
+
- smell_category: Duplication
|
|
32
|
+
smell_type: DuplicateMethodCall
|
|
33
|
+
source: smelly.rb
|
|
34
|
+
context: Smelly#m
|
|
31
35
|
lines:
|
|
32
|
-
-
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
- 4
|
|
37
|
+
- 5
|
|
38
|
+
message: calls puts(@foo.bar) 2 times
|
|
39
|
+
name: puts(@foo.bar)
|
|
40
|
+
count: 2
|
|
35
41
|
- smell_category: UncommunicativeName
|
|
36
42
|
smell_type: UncommunicativeMethodName
|
|
37
|
-
source:
|
|
38
|
-
context:
|
|
43
|
+
source: smelly.rb
|
|
44
|
+
context: Smelly#m
|
|
39
45
|
lines:
|
|
40
|
-
-
|
|
46
|
+
- 3
|
|
41
47
|
message: has the name 'm'
|
|
42
48
|
name: m
|
|
43
49
|
"""
|
|
@@ -50,7 +56,7 @@ Feature: Report smells using simple YAML layout
|
|
|
50
56
|
---
|
|
51
57
|
- smell_category: IrresponsibleModule
|
|
52
58
|
smell_type: IrresponsibleModule
|
|
53
|
-
source: "
|
|
59
|
+
source: "STDIN"
|
|
54
60
|
context: Turn
|
|
55
61
|
lines:
|
|
56
62
|
- 1
|
data/features/samples.feature
CHANGED
|
@@ -4,19 +4,21 @@ Feature: Basic smell detection
|
|
|
4
4
|
I want to detect the smells in my Ruby code
|
|
5
5
|
|
|
6
6
|
Scenario: Correct smells from inline.rb
|
|
7
|
-
|
|
7
|
+
Given the "inline.rb" sample file exists
|
|
8
|
+
When I run reek --no-line-numbers inline.rb
|
|
8
9
|
Then the exit status indicates smells
|
|
9
10
|
And it reports:
|
|
10
11
|
"""
|
|
11
|
-
|
|
12
|
+
inline.rb -- 45 warnings:
|
|
12
13
|
CompilationError has no descriptive comment (IrresponsibleModule)
|
|
14
|
+
Dir has no descriptive comment (IrresponsibleModule)
|
|
13
15
|
File has no descriptive comment (IrresponsibleModule)
|
|
14
16
|
File#self.write_with_backup has approx 6 statements (TooManyStatements)
|
|
15
17
|
Inline declares the class variable @@directory (ClassVariable)
|
|
16
18
|
Inline declares the class variable @@rootdir (ClassVariable)
|
|
17
19
|
Inline#self.rootdir calls env.nil? 2 times (DuplicateMethodCall)
|
|
18
20
|
Inline#self.rootdir has approx 8 statements (TooManyStatements)
|
|
19
|
-
Inline#self.rootdir performs a nil-check
|
|
21
|
+
Inline#self.rootdir performs a nil-check (NilCheck)
|
|
20
22
|
Inline::C declares the class variable @@type_map (ClassVariable)
|
|
21
23
|
Inline::C has at least 13 instance variables (TooManyInstanceVariables)
|
|
22
24
|
Inline::C takes parameters [options, src] to 5 methods (DataClump)
|
|
@@ -49,18 +51,19 @@ Feature: Basic smell detection
|
|
|
49
51
|
Inline::C#parse_signature has the variable name 'x' (UncommunicativeVariableName)
|
|
50
52
|
Inline::C#parse_signature is controlled by argument raw (ControlParameter)
|
|
51
53
|
Inline::C#strip_comments doesn't depend on instance state (UtilityFunction)
|
|
52
|
-
|
|
54
|
+
Module has no descriptive comment (IrresponsibleModule)
|
|
53
55
|
Module#inline calls Inline.const_get(lang) 2 times (DuplicateMethodCall)
|
|
54
56
|
Module#inline calls options[:testing] 2 times (DuplicateMethodCall)
|
|
55
57
|
Module#inline has approx 12 statements (TooManyStatements)
|
|
56
58
|
"""
|
|
57
59
|
|
|
58
60
|
Scenario: Correct smells from optparse.rb
|
|
59
|
-
|
|
61
|
+
Given the "optparse.rb" sample file exists
|
|
62
|
+
When I run reek --no-line-numbers optparse.rb
|
|
60
63
|
Then the exit status indicates smells
|
|
61
64
|
And it reports:
|
|
62
65
|
"""
|
|
63
|
-
|
|
66
|
+
optparse.rb -- 111 warnings:
|
|
64
67
|
OptionParser has at least 42 methods (TooManyMethods)
|
|
65
68
|
OptionParser has the variable name 'f' (UncommunicativeVariableName)
|
|
66
69
|
OptionParser has the variable name 'k' (UncommunicativeVariableName)
|
|
@@ -100,7 +103,7 @@ Feature: Basic smell detection
|
|
|
100
103
|
OptionParser#make_switch has the variable name 'q' (UncommunicativeVariableName)
|
|
101
104
|
OptionParser#make_switch has the variable name 's' (UncommunicativeVariableName)
|
|
102
105
|
OptionParser#make_switch has the variable name 'v' (UncommunicativeVariableName)
|
|
103
|
-
OptionParser#make_switch performs a nil-check
|
|
106
|
+
OptionParser#make_switch performs a nil-check (NilCheck)
|
|
104
107
|
OptionParser#order calls argv[0] 2 times (DuplicateMethodCall)
|
|
105
108
|
OptionParser#order refers to argv more than self (FeatureEnvy)
|
|
106
109
|
OptionParser#parse calls argv[0] 2 times (DuplicateMethodCall)
|
|
@@ -118,7 +121,7 @@ Feature: Basic smell detection
|
|
|
118
121
|
OptionParser#permute refers to argv more than self (FeatureEnvy)
|
|
119
122
|
OptionParser#permute! has approx 6 statements (TooManyStatements)
|
|
120
123
|
OptionParser#search has the variable name 'k' (UncommunicativeVariableName)
|
|
121
|
-
OptionParser#self.inc performs a nil-check
|
|
124
|
+
OptionParser#self.inc performs a nil-check (NilCheck)
|
|
122
125
|
OptionParser#summarize has 4 parameters (LongParameterList)
|
|
123
126
|
OptionParser#summarize has the variable name 'l' (UncommunicativeVariableName)
|
|
124
127
|
OptionParser#summarize is controlled by argument blk (ControlParameter)
|
|
@@ -175,11 +178,12 @@ Feature: Basic smell detection
|
|
|
175
178
|
"""
|
|
176
179
|
|
|
177
180
|
Scenario: Correct smells from redcloth.rb
|
|
178
|
-
|
|
181
|
+
Given the "redcloth.rb" sample file exists
|
|
182
|
+
When I run reek --no-line-numbers redcloth.rb
|
|
179
183
|
Then the exit status indicates smells
|
|
180
184
|
And it reports:
|
|
181
185
|
"""
|
|
182
|
-
|
|
186
|
+
redcloth.rb -- 95 warnings:
|
|
183
187
|
RedCloth has at least 44 methods (TooManyMethods)
|
|
184
188
|
RedCloth has the variable name 'a' (UncommunicativeVariableName)
|
|
185
189
|
RedCloth has the variable name 'b' (UncommunicativeVariableName)
|
|
@@ -191,7 +195,7 @@ Feature: Basic smell detection
|
|
|
191
195
|
RedCloth#block_markdown_atx refers to text more than self (FeatureEnvy)
|
|
192
196
|
RedCloth#block_markdown_bq has approx 6 statements (TooManyStatements)
|
|
193
197
|
RedCloth#block_markdown_lists has unused parameter 'text' (UnusedParameters)
|
|
194
|
-
RedCloth#block_markdown_rule
|
|
198
|
+
RedCloth#block_markdown_rule doesn't depend on instance state (UtilityFunction)
|
|
195
199
|
RedCloth#block_markdown_setext refers to text more than self (FeatureEnvy)
|
|
196
200
|
RedCloth#block_textile_lists calls depth.last 5 times (DuplicateMethodCall)
|
|
197
201
|
RedCloth#block_textile_lists calls depth.last.length 2 times (DuplicateMethodCall)
|
|
@@ -218,18 +222,15 @@ Feature: Basic smell detection
|
|
|
218
222
|
RedCloth#clean_html has approx 15 statements (TooManyStatements)
|
|
219
223
|
RedCloth#clean_html has the variable name 'q' (UncommunicativeVariableName)
|
|
220
224
|
RedCloth#clean_html has the variable name 'q2' (UncommunicativeVariableName)
|
|
221
|
-
RedCloth#clean_html refers to raw more than self (FeatureEnvy)
|
|
222
|
-
RedCloth#clean_html refers to tags more than self (FeatureEnvy)
|
|
223
225
|
RedCloth#clean_white_space has approx 7 statements (TooManyStatements)
|
|
224
226
|
RedCloth#clean_white_space refers to text more than self (FeatureEnvy)
|
|
225
227
|
RedCloth#flush_left doesn't depend on instance state (UtilityFunction)
|
|
226
|
-
RedCloth#
|
|
227
|
-
RedCloth#footnote_ref refers to text more than self (FeatureEnvy)
|
|
228
|
+
RedCloth#footnote_ref doesn't depend on instance state (UtilityFunction)
|
|
228
229
|
RedCloth#glyphs_textile has approx 10 statements (TooManyStatements)
|
|
230
|
+
RedCloth#h_align doesn't depend on instance state (UtilityFunction)
|
|
229
231
|
RedCloth#htmlesc doesn't depend on instance state (UtilityFunction)
|
|
230
232
|
RedCloth#htmlesc is controlled by argument mode (ControlParameter)
|
|
231
|
-
RedCloth#
|
|
232
|
-
RedCloth#incoming_entities refers to text more than self (FeatureEnvy)
|
|
233
|
+
RedCloth#incoming_entities doesn't depend on instance state (UtilityFunction)
|
|
233
234
|
RedCloth#initialize has the variable name 'r' (UncommunicativeVariableName)
|
|
234
235
|
RedCloth#inline contains iterators nested 2 deep (NestedIterators)
|
|
235
236
|
RedCloth#inline_markdown_link has approx 6 statements (TooManyStatements)
|
|
@@ -246,11 +247,10 @@ Feature: Basic smell detection
|
|
|
246
247
|
RedCloth#inline_textile_span contains iterators nested 2 deep (NestedIterators)
|
|
247
248
|
RedCloth#inline_textile_span has approx 9 statements (TooManyStatements)
|
|
248
249
|
RedCloth#inline_textile_span has the variable name 'm' (UncommunicativeVariableName)
|
|
250
|
+
RedCloth#lT doesn't depend on instance state (UtilityFunction)
|
|
249
251
|
RedCloth#lT has the name 'lT' (UncommunicativeMethodName)
|
|
250
252
|
RedCloth#lT is controlled by argument text (ControlParameter)
|
|
251
|
-
RedCloth#lT refers to text more than self (FeatureEnvy)
|
|
252
253
|
RedCloth#no_textile doesn't depend on instance state (UtilityFunction)
|
|
253
|
-
RedCloth#no_textile refers to text more than self (FeatureEnvy)
|
|
254
254
|
RedCloth#pba calls $1.length 2 times (DuplicateMethodCall)
|
|
255
255
|
RedCloth#pba has approx 21 statements (TooManyStatements)
|
|
256
256
|
RedCloth#pba is controlled by argument element (ControlParameter)
|
|
@@ -278,22 +278,17 @@ Feature: Basic smell detection
|
|
|
278
278
|
RedCloth#textile_popup_help has the parameter name 'windowH' (UncommunicativeParameterName)
|
|
279
279
|
RedCloth#textile_popup_help has the parameter name 'windowW' (UncommunicativeParameterName)
|
|
280
280
|
RedCloth#to_html has approx 26 statements (TooManyStatements)
|
|
281
|
+
RedCloth#v_align doesn't depend on instance state (UtilityFunction)
|
|
281
282
|
"""
|
|
282
283
|
|
|
283
|
-
Scenario: Correct smells from a source file with
|
|
284
|
-
|
|
284
|
+
Scenario: Correct smells from a source file with unusual syntax samples
|
|
285
|
+
Given the "unusual_syntax.rb" sample file exists
|
|
286
|
+
When I run reek unusual_syntax.rb
|
|
285
287
|
Then the exit status indicates smells
|
|
286
288
|
And it reports:
|
|
287
289
|
"""
|
|
288
|
-
|
|
289
|
-
[1]:SomeClass has no descriptive comment (IrresponsibleModule)
|
|
290
|
-
"""
|
|
291
|
-
|
|
292
|
-
Scenario: Correct smells from a source file with Ruby 2.1 specific syntax
|
|
293
|
-
When I run reek spec/samples/ruby21_syntax.rb
|
|
294
|
-
Then the exit status indicates smells
|
|
295
|
-
And it reports:
|
|
296
|
-
"""
|
|
297
|
-
spec/samples/ruby21_syntax.rb -- 1 warning:
|
|
290
|
+
unusual_syntax.rb -- 3 warnings:
|
|
298
291
|
[1]:SomeClass has no descriptive comment (IrresponsibleModule)
|
|
292
|
+
[18]:SomeClass#method_with_array_decomposition has the parameter name 'a' (UncommunicativeParameterName)
|
|
293
|
+
[18]:SomeClass#method_with_array_decomposition has the parameter name 'b' (UncommunicativeParameterName)
|
|
299
294
|
"""
|
|
@@ -11,81 +11,69 @@ When /^I run rake (\w*) with:$/ do |name, task_def|
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
Then /^it reports nothing$/ do
|
|
14
|
-
|
|
14
|
+
assert_exact_output '', all_stdout
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
Then /^there is no output on stdout$/ do
|
|
18
|
-
|
|
18
|
+
assert_exact_output '', all_stdout
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
Then /^stdout includes "(.*)"$/ do |text|
|
|
22
|
-
|
|
22
|
+
assert_partial_output(text, all_stdout)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
Then /^it succeeds$/ do
|
|
26
|
-
|
|
26
|
+
assert_exit_status Reek::CLI::Application::STATUS_SUCCESS
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
Then /^the exit status indicates an error$/ do
|
|
30
|
-
|
|
30
|
+
assert_exit_status Reek::CLI::Application::STATUS_ERROR
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
Then /^the exit status indicates smells$/ do
|
|
34
|
-
|
|
34
|
+
assert_exit_status Reek::CLI::Application::STATUS_SMELLS
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
Then /^it reports:$/ do |report|
|
|
38
|
-
|
|
38
|
+
assert_exact_output "#{report}\n", all_stdout
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
Then /^it reports this yaml:$/ do |expected_yaml|
|
|
42
42
|
expected_warnings = YAML.load(expected_yaml.chomp)
|
|
43
|
-
actual_warnings = YAML.load(
|
|
43
|
+
actual_warnings = YAML.load(all_stdout)
|
|
44
44
|
expect(actual_warnings).to eq expected_warnings
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
Then /^it reports this JSON:$/ do |expected_json|
|
|
48
48
|
expected_warnings = JSON.parse(expected_json.chomp)
|
|
49
|
-
actual_warnings = JSON.parse(
|
|
49
|
+
actual_warnings = JSON.parse(all_stdout)
|
|
50
50
|
expect(actual_warnings).to eq expected_warnings
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
Then /^stderr reports:$/ do |report|
|
|
54
|
-
|
|
54
|
+
assert_exact_output report, all_stderr
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
Then /^it reports no errors$/ do
|
|
58
|
-
|
|
58
|
+
assert_exact_output '', all_stderr
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
Then /^it reports an error$/ do
|
|
62
|
-
expect(
|
|
62
|
+
expect(all_stderr).to_not be_empty
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
Then /^it reports the error ['"](.*)['"]$/ do |string|
|
|
66
|
-
|
|
66
|
+
assert_partial_output string, all_stderr
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
Then /^it reports a parsing error$/ do
|
|
70
|
-
|
|
70
|
+
assert_partial_output 'Parser::SyntaxError', all_stderr
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
Then /^it should indicate the line numbers of those smells$/ do
|
|
74
|
-
|
|
74
|
+
assert_matching_output /\[.*\]:/, all_stdout
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
Then /^it reports the current version$/ do
|
|
78
|
-
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
Given(/^"(.*?)" exists in the working directory$/) do |path|
|
|
82
|
-
FileUtils.cp path, Pathname.pwd
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
Given(/^"(.*?)" exists in the parent directory of the working directory$/) do |path|
|
|
86
|
-
FileUtils.cp path, Pathname.pwd.parent
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
Given(/^"(.*?)" exists in the HOME directory$/) do |path|
|
|
90
|
-
FileUtils.cp path, Pathname.new(Dir.home)
|
|
78
|
+
assert_exact_output "reek #{Reek::Version::STRING}\n", all_stdout
|
|
91
79
|
end
|