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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: da371c20978d5a436025bc2ecddc2df4582a9c7e
|
|
4
|
+
data.tar.gz: 8aa3729d6814cba34e69ff9e1696ce93450221c6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d15340c5aa637820c280d28008579ecc97f9de7a56bf74e47f6f217a9f593d3a1416dfa6757b4beb3900032c505eed91aa8fa21de94374ac1e2d1537706cbabb
|
|
7
|
+
data.tar.gz: c49a1ae86f1265e493f6e5eff700e2d02c2849358a49db20d87d9c52498138da0ca38fd7bd83cb90d0c16cb7b19789aa43422b052910b145ac611d9421bc6bf8
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
Exclude:
|
|
3
|
+
- 'spec/samples/**/*'
|
|
4
|
+
- 'tmp/**/*'
|
|
5
|
+
- 'vendor/**/*'
|
|
6
|
+
|
|
7
|
+
# FIXME: Make the class shorter
|
|
8
|
+
Metrics/ClassLength:
|
|
9
|
+
Exclude:
|
|
10
|
+
- lib/reek/tree_walker.rb
|
|
11
|
+
- lib/reek/cli/options.rb
|
|
12
|
+
|
|
13
|
+
# FIXME: Lower the method length by fixing the biggest offenders
|
|
14
|
+
Metrics/MethodLength:
|
|
15
|
+
Max: 15
|
|
16
|
+
|
|
17
|
+
# Be a little more lenient with line length
|
|
18
|
+
Metrics/LineLength:
|
|
19
|
+
Max: 100
|
|
20
|
+
|
|
21
|
+
# Allow small arrays of words with quotes
|
|
22
|
+
Style/WordArray:
|
|
23
|
+
MinSize: 3
|
|
24
|
+
|
|
25
|
+
# Allow single-line method definitions
|
|
26
|
+
Style/SingleLineMethods:
|
|
27
|
+
Enabled: false
|
|
28
|
+
|
|
29
|
+
# Always use raise to signal exceptions
|
|
30
|
+
Style/SignalException:
|
|
31
|
+
EnforcedStyle: only_raise
|
|
32
|
+
|
|
33
|
+
# Place . on the previous line
|
|
34
|
+
Style/DotPosition:
|
|
35
|
+
EnforcedStyle: trailing
|
|
36
|
+
|
|
37
|
+
# Require empty lines between defs, except for one-line defs
|
|
38
|
+
Style/EmptyLineBetweenDefs:
|
|
39
|
+
AllowAdjacentOneLineDefs: true
|
|
40
|
+
|
|
41
|
+
# Allow multiline block chains
|
|
42
|
+
Style/MultilineBlockChain:
|
|
43
|
+
Enabled: false
|
|
44
|
+
|
|
45
|
+
# Allow Perl-style references to regex matches
|
|
46
|
+
Style/PerlBackrefs:
|
|
47
|
+
Enabled: false
|
data/.travis.yml
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
sudo: false
|
|
2
|
+
cache: bundler
|
|
3
|
+
language: ruby
|
|
4
|
+
bundler_args: --without local_development
|
|
5
|
+
script:
|
|
6
|
+
- bundle exec rake
|
|
7
|
+
- bundle exec ataru check
|
|
8
|
+
rvm:
|
|
9
|
+
- 2.0.0
|
|
10
|
+
- 2.1
|
|
11
|
+
- 2.2
|
|
12
|
+
- rbx-2
|
|
13
|
+
- ruby-head
|
|
14
|
+
matrix:
|
|
15
|
+
include:
|
|
16
|
+
- rvm: jruby-19mode
|
|
17
|
+
env: JRUBY_OPTS='--server -Xcompile.invokedynamic=false'
|
|
18
|
+
- rvm: jruby-head
|
|
19
|
+
env: JRUBY_OPTS='--server -Xcompile.invokedynamic=false'
|
|
20
|
+
allow_failures:
|
|
21
|
+
- rvm: jruby-head
|
|
22
|
+
env: JRUBY_OPTS='--server -Xcompile.invokedynamic=false'
|
|
23
|
+
- rvm: ruby-head
|
|
24
|
+
fast_finish: true
|
|
25
|
+
notifications:
|
|
26
|
+
recipients:
|
|
27
|
+
- timo.roessner@googlemail.com
|
|
28
|
+
- matijs@matijs.net
|
|
29
|
+
- emil.rehnberg@gmail.com
|
|
30
|
+
- chastell@chastell.net
|
|
31
|
+
irc: "irc.freenode.org#reek"
|
data/.yardopts
CHANGED
data/CHANGELOG
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
== 3.0.0
|
|
2
|
+
|
|
3
|
+
* (troessner) Make directories excludable via configuration.
|
|
4
|
+
* (mvz) Define and document public API
|
|
5
|
+
* (troessner) Recognize methods defined with class << self syntax as singleton methods.
|
|
6
|
+
* (troessner) Use ruby22 instead of ruby21 for parsing.
|
|
7
|
+
* (nTraum) Drop support for Ruby 1.9
|
|
8
|
+
|
|
9
|
+
== 2.2.1
|
|
10
|
+
|
|
11
|
+
* (mvz) Support methods using array decomposition arguments
|
|
12
|
+
|
|
13
|
+
== 2.2.0
|
|
14
|
+
|
|
15
|
+
* (sauliusgrigaitis) Add support for XML reports
|
|
16
|
+
* (beanieboi) Don’t track private methods in the Attributes smell
|
|
17
|
+
* (Sebastian Boehm) Do not enable colorization if stdout is not a TTY
|
|
18
|
+
|
|
19
|
+
== 2.1.0
|
|
20
|
+
|
|
21
|
+
* (mvz) Ensure require 'reek' is enough to use reek's classes
|
|
22
|
+
* (mvz) Pick config file that comes first alphabetically
|
|
23
|
+
* (mvz) Separate FeatureEnvy and UtilityFunction
|
|
24
|
+
|
|
1
25
|
== 2.0.4
|
|
2
26
|
|
|
3
27
|
* (chastell) Recognise .reek as a valid configuration file
|
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Contributing to reek
|
|
2
|
+
|
|
3
|
+
We welcome any and all contributions to reek!
|
|
4
|
+
|
|
5
|
+
If what you’re proposing requires significant work discuss it beforehand
|
|
6
|
+
as an issue – it’s much easier for us to guide you towards a good
|
|
7
|
+
solution and less frustrating for you than doing a lot of work
|
|
8
|
+
only to find us suggesting large parts should be rewritten.
|
|
9
|
+
|
|
10
|
+
Don’t hesitate to offer trivial fixes (spelling, better naming
|
|
11
|
+
ideas, etc.) – we’ll let you know if you’re overdoing it. :)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## Reporting Issues
|
|
16
|
+
|
|
17
|
+
Search [all existing (open _and_ closed)
|
|
18
|
+
issues](https://github.com/troessner/reek/issues?q=is%3Aissue)
|
|
19
|
+
for a possible previous report; comment there if the issue is not
|
|
20
|
+
actually resolved properly or you have any additional information.
|
|
21
|
+
|
|
22
|
+
Include the steps to reproduce the issue,
|
|
23
|
+
the expected outcome and the actual outcome.
|
|
24
|
+
|
|
25
|
+
Include as much information as possible: the exact reek
|
|
26
|
+
invocation that you use, reek’s config and version, Ruby
|
|
27
|
+
version, Ruby platform (MRI, JRuby, etc.), operating system.
|
|
28
|
+
|
|
29
|
+
Try to provide a minimal example that reproduces the issue.
|
|
30
|
+
Extra kudos if you can write it as a failing test. :)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## Setup and Pull Request Basics
|
|
35
|
+
|
|
36
|
+
Fork reek, then clone it, make sure you have
|
|
37
|
+
[Bundler](http://bundler.io) installed, install dependencies
|
|
38
|
+
and make sure all of the existing tests pass:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
git clone git@github.com:…username…/reek.git
|
|
42
|
+
cd reek
|
|
43
|
+
gem install bundler
|
|
44
|
+
bundle
|
|
45
|
+
bundle exec rake
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Once you’re sure your copy of reek works (and that there are no
|
|
49
|
+
failing tests on the "develop" branch) create your own branch from our "develop" branch.
|
|
50
|
+
|
|
51
|
+
We are using the popular [gitflow branch model](http://nvie.com/posts/a-successful-git-branching-model/) and
|
|
52
|
+
require contributions to follow to this model as well.
|
|
53
|
+
This probably sounds more complicated than it is, for you this just means that you should branch off
|
|
54
|
+
of our "develop" branch for your pull request, not master (which is the default already):
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
git checkout -b your_feature_or_fix_name
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Then start hacking and add new tests which make sure that your new feature works or
|
|
61
|
+
demonstrate that your fix was needed; please also [write good commit
|
|
62
|
+
messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
|
|
63
|
+
|
|
64
|
+
Once you’re happy with your feature / fix – or want to
|
|
65
|
+
share it as a work-in-progress and request comments – once
|
|
66
|
+
again make sure all of the tests pass. This will also run
|
|
67
|
+
[RuboCop](https://github.com/bbatsov/rubocop) – fix any
|
|
68
|
+
offences RuboCop finds (or discuss them in the pull request):
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
bundle exec rake
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Once your code is ready for review push it to your repository:
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
git push -u origin
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Then go to your GitHub fork and [make a pull
|
|
81
|
+
request](https://help.github.com/articles/creating-a-pull-request/)
|
|
82
|
+
to the original repository.
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
## Review and Fixes
|
|
87
|
+
|
|
88
|
+
Try to gauge and let us know in the pull request whether what
|
|
89
|
+
you propose is a backward-compatible bugfix and should go into the
|
|
90
|
+
next patch release, is a backward-compatible feature and should go
|
|
91
|
+
into the next minor release, or has to break backward-compatibility
|
|
92
|
+
and so needs to wait for the next major release of reek.
|
|
93
|
+
|
|
94
|
+
Once your PR is open someone will review it, discuss the details (if
|
|
95
|
+
needed) and either merge right away or ask for some further fixes.
|
|
96
|
+
|
|
97
|
+
GitHub doesn’t have a good way to amend pull requests from external
|
|
98
|
+
repositories. In cases where it’s easier to make a direct fix
|
|
99
|
+
to your pull request (rather than describing it in the comments)
|
|
100
|
+
we’ll either open a separate pull request to the branch in your
|
|
101
|
+
repository or ask you to give us commit access to your repository.
|
|
102
|
+
|
|
103
|
+
If there were any fixes to your pull request we’ll ask you to
|
|
104
|
+
[squash](http://git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Squashing-Commits)
|
|
105
|
+
all of the commits into one:
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
git rebase -i develop
|
|
109
|
+
# squash squash squash
|
|
110
|
+
git push -f origin
|
|
111
|
+
```
|
data/Gemfile
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
# The gem's dependencies are specified in the gemspec
|
|
4
|
+
gemspec
|
|
5
|
+
|
|
6
|
+
group :local_development do
|
|
7
|
+
gem 'pry'
|
|
8
|
+
gem 'yard', '~> 0.8.7'
|
|
9
|
+
|
|
10
|
+
platforms :mri do
|
|
11
|
+
gem 'pry-byebug'
|
|
12
|
+
gem 'pry-stack_explorer'
|
|
13
|
+
|
|
14
|
+
gem 'redcarpet', '~> 3.3.1'
|
|
15
|
+
end
|
|
16
|
+
end
|
data/README.md
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `reek`: code smell detection for Ruby
|
|
2
2
|
|
|
3
3
|
## Overview
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
[](https://travis-ci.org/troessner/reek?branch=master)
|
|
7
|
-
[](https://badge.fury.io/rb/reek)
|
|
8
8
|
[](https://gemnasium.com/troessner/reek)
|
|
9
9
|
[](https://inch-ci.org/github/troessner/reek)
|
|
10
10
|
|
|
11
11
|
## Quickstart
|
|
12
12
|
|
|
13
|
-
`reek` is a tool that examines Ruby classes, modules and methods and reports any
|
|
13
|
+
`reek` is a tool that examines Ruby classes, modules and methods and reports any
|
|
14
|
+
[Code Smells](docs/Code-Smells.md) it finds.
|
|
15
|
+
Install it like this:
|
|
14
16
|
|
|
15
17
|
```Bash
|
|
16
18
|
gem install reek
|
|
@@ -24,34 +26,32 @@ reek [options] [dir_or_source_file]*
|
|
|
24
26
|
|
|
25
27
|
## Example
|
|
26
28
|
|
|
27
|
-
Imagine a source file
|
|
29
|
+
Imagine a source file `demo.rb` containing:
|
|
28
30
|
|
|
29
31
|
```Ruby
|
|
30
32
|
class Dirty
|
|
31
33
|
# This method smells of :reek:NestedIterators but ignores them
|
|
32
34
|
def awful(x, y, offset = 0, log = false)
|
|
33
35
|
puts @screen.title
|
|
34
|
-
@screen = widgets.map {|w| w.each {|key| key += 3}}
|
|
36
|
+
@screen = widgets.map { |w| w.each { |key| key += 3 * x } }
|
|
35
37
|
puts @screen.contents
|
|
36
38
|
end
|
|
37
39
|
end
|
|
38
40
|
```
|
|
39
41
|
|
|
40
|
-
|
|
42
|
+
`reek` will report the following code smells in this file:
|
|
41
43
|
|
|
42
44
|
```
|
|
43
45
|
$ reek demo.rb
|
|
44
|
-
|
|
45
|
-
Dirty has no descriptive comment (IrresponsibleModule)
|
|
46
|
-
Dirty#awful has 4 parameters (LongParameterList)
|
|
47
|
-
Dirty#awful has boolean parameter 'log' (
|
|
48
|
-
Dirty#awful has the parameter name 'x' (
|
|
49
|
-
Dirty#awful has the
|
|
50
|
-
Dirty#awful has
|
|
51
|
-
Dirty#awful has unused parameter '
|
|
52
|
-
Dirty#awful has unused parameter '
|
|
53
|
-
Dirty#awful has unused parameter 'x' (UnusedParameters)
|
|
54
|
-
Dirty#awful has unused parameter 'y' (UnusedParameters)
|
|
46
|
+
demo.rb -- 8 warnings:
|
|
47
|
+
[1]:Dirty has no descriptive comment (IrresponsibleModule)
|
|
48
|
+
[3]:Dirty#awful has 4 parameters (LongParameterList)
|
|
49
|
+
[3]:Dirty#awful has boolean parameter 'log' (BooleanParameter)
|
|
50
|
+
[3]:Dirty#awful has the parameter name 'x' (UncommunicativeParameterName)
|
|
51
|
+
[5]:Dirty#awful has the variable name 'w' (UncommunicativeVariableName)
|
|
52
|
+
[3]:Dirty#awful has unused parameter 'log' (UnusedParameters)
|
|
53
|
+
[3]:Dirty#awful has unused parameter 'offset' (UnusedParameters)
|
|
54
|
+
[3]:Dirty#awful has unused parameter 'y' (UnusedParameters)
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
## Sources
|
|
@@ -70,13 +70,13 @@ So
|
|
|
70
70
|
reek
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
is the exact same thing
|
|
73
|
+
is the exact same thing as being explicit:
|
|
74
74
|
|
|
75
75
|
```Bash
|
|
76
76
|
reek .
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
-
Additionally can
|
|
79
|
+
Additionally you can pipe code to `reek` like this:
|
|
80
80
|
|
|
81
81
|
```Bash
|
|
82
82
|
echo "class C; def m; end; end" | reek
|
|
@@ -93,11 +93,22 @@ $stdin -- 3 warnings:
|
|
|
93
93
|
|
|
94
94
|
## Code smells
|
|
95
95
|
|
|
96
|
-
`reek` currently includes checks for some aspects of
|
|
96
|
+
`reek` currently includes checks for some aspects of
|
|
97
|
+
[Control Couple](docs/Control-Couple.md),
|
|
98
|
+
[Data Clump](docs/Data-Clump.md),
|
|
99
|
+
[Feature Envy](docs/Feature-Envy.md),
|
|
100
|
+
[Large Class](docs/Large-Class.md),
|
|
101
|
+
[Long Parameter List](docs/Long-Parameter-List.md),
|
|
102
|
+
[Simulated Polymorphism](docs/Simulated-Polymorphism.md),
|
|
103
|
+
[Too Many Statements](docs/Too-Many-Statements.md),
|
|
104
|
+
[Uncommunicative Name](docs/Uncommunicative-Name.md),
|
|
105
|
+
[Unused Parameters](docs/Unused-Parameters.md)
|
|
106
|
+
and more. See the [Code Smells](docs/Code-Smells.md)
|
|
107
|
+
for up to date details of exactly what `reek` will check in your code.
|
|
97
108
|
|
|
98
109
|
## Configuration
|
|
99
110
|
|
|
100
|
-
### Command
|
|
111
|
+
### Command-line interface
|
|
101
112
|
|
|
102
113
|
For a basic overview, run
|
|
103
114
|
|
|
@@ -105,29 +116,45 @@ For a basic overview, run
|
|
|
105
116
|
reek --help
|
|
106
117
|
```
|
|
107
118
|
|
|
108
|
-
For a summary of those CLI options see [Command-Line Options](
|
|
119
|
+
For a summary of those CLI options see [Command-Line Options](docs/Command-Line-Options.md).
|
|
109
120
|
|
|
110
|
-
### Configuration
|
|
121
|
+
### Configuration file
|
|
111
122
|
|
|
112
123
|
#### Configuration loading
|
|
113
124
|
|
|
114
|
-
Configuring `reek` via configuration file is by far the most powerful way.
|
|
125
|
+
Configuring `reek` via a configuration file is by far the most powerful way.
|
|
115
126
|
|
|
116
|
-
There are
|
|
127
|
+
There are three ways of passing `reek` a configuration file:
|
|
117
128
|
|
|
118
|
-
1. Using the
|
|
119
|
-
2. Having a file ending with
|
|
120
|
-
3. Having a file ending with
|
|
129
|
+
1. Using the CLI `-c` switch (see [_Command-line interface_](#command-line-interface) above)
|
|
130
|
+
2. Having a file ending with `.reek` either in your current working directory or in a parent directory (more on that later)
|
|
131
|
+
3. Having a file ending with `.reek` in your home directory
|
|
121
132
|
|
|
122
|
-
The order in which `reek` tries to find such a configuration
|
|
133
|
+
The order in which `reek` tries to find such a configuration
|
|
134
|
+
file is exactly the above: first it checks if we have given
|
|
135
|
+
it a configuration file explicitly via CLI; then it checks
|
|
136
|
+
the current working directory for a file and if it can't
|
|
137
|
+
find one, it traverses up the directories until it hits the
|
|
138
|
+
root directory; lastly, it checks your home directory.
|
|
123
139
|
|
|
124
|
-
As soon as `reek` detects a configuration file it stops searching
|
|
140
|
+
As soon as `reek` detects a configuration file it stops searching
|
|
141
|
+
immediately, meaning that from `reek`'s point of view there exists
|
|
142
|
+
exactly one configuration file and one configuration, regardless
|
|
143
|
+
of how many `*.reek` files you might have on your filesystem.
|
|
125
144
|
|
|
126
145
|
#### Configuration options
|
|
127
146
|
|
|
128
|
-
The first thing you probably want to check out are the
|
|
129
|
-
|
|
130
|
-
|
|
147
|
+
The first thing you probably want to check out are the
|
|
148
|
+
[Basic Smell Options](docs/Basic-Smell-Options.md)
|
|
149
|
+
which are supported by every smell type. Certain smell
|
|
150
|
+
types offer a configuration that goes beyond that
|
|
151
|
+
of the basic smell options, for instance
|
|
152
|
+
[Data Clump](docs/Data-Clump.md).
|
|
153
|
+
All options that go beyond the [Basic Smell Options](docs/Basic-Smell-Options.md)
|
|
154
|
+
should be documented in the corresponding smell type wiki page,
|
|
155
|
+
but if you want to get a quick and full overview over all possible
|
|
156
|
+
configurations you can always check out [the `config/default.reek`
|
|
157
|
+
file in this repository](config/defaults.reek).
|
|
131
158
|
|
|
132
159
|
Here's an excerpt of a `reek` configuration file from a commercial project:
|
|
133
160
|
|
|
@@ -135,20 +162,30 @@ Here's an excerpt of a `reek` configuration file from a commercial project:
|
|
|
135
162
|
---
|
|
136
163
|
IrresponsibleModule:
|
|
137
164
|
enabled: false
|
|
165
|
+
|
|
138
166
|
NestedIterators:
|
|
139
167
|
exclude:
|
|
140
168
|
- "ActiveModelErrorAdder#self.run" # should be refactored
|
|
141
169
|
- "BookingRequests::Transfer#remote_validation"
|
|
142
170
|
- "BookingRequestsController#vehicle_options" # respond_to block
|
|
143
171
|
- "Content::Base#self.expose_fields" # unavoidable due to metaprogramming
|
|
172
|
+
|
|
144
173
|
DataClump:
|
|
145
174
|
max_copies: 3
|
|
146
175
|
min_clump_size: 3
|
|
176
|
+
|
|
177
|
+
exclude_paths:
|
|
178
|
+
- app/views
|
|
179
|
+
- app/controllers
|
|
147
180
|
```
|
|
148
181
|
|
|
182
|
+
Additionally to the smell configuration you can exclude whole directories from scans using `exclude_paths` as you can see at the end of the configuration above.
|
|
183
|
+
|
|
149
184
|
### Source code comments
|
|
150
185
|
|
|
151
|
-
`reek` is not the police. In case you need to suppress a smell
|
|
186
|
+
`reek` is not the police. In case you need to suppress a smell
|
|
187
|
+
warning and you can't or don't want to use configuration files for
|
|
188
|
+
whatever reasons you can also use source code comments like this:
|
|
152
189
|
|
|
153
190
|
```Ruby
|
|
154
191
|
# This method smells of :reek:NestedIterators
|
|
@@ -157,7 +194,7 @@ def smelly_method foo
|
|
|
157
194
|
end
|
|
158
195
|
```
|
|
159
196
|
|
|
160
|
-
This is further explained [
|
|
197
|
+
This is further explained under [Smell Suppresion](docs/Smell-Suppression.md).
|
|
161
198
|
|
|
162
199
|
|
|
163
200
|
## Integration
|
|
@@ -168,21 +205,21 @@ Besides the obvious
|
|
|
168
205
|
reek [options] [dir_or_source_file]*
|
|
169
206
|
```
|
|
170
207
|
|
|
171
|
-
there are quite a few other ways how to use reek in your projects:
|
|
208
|
+
there are quite a few other ways how to use `reek` in your projects:
|
|
172
209
|
|
|
173
|
-
* Use `reek`'s [Rake
|
|
174
|
-
* Add `reek`'s custom matcher to your [RSpec examples](
|
|
175
|
-
* Include `reek` using the [Developer API](
|
|
210
|
+
* Use `reek`'s [Rake task](docs/Rake-Task.md) to automate detecting code smells
|
|
211
|
+
* Add `reek`'s custom matcher to your [RSpec examples](docs/RSpec-matchers.md)
|
|
212
|
+
* Include `reek` using the [Developer API](docs/API.md)
|
|
176
213
|
|
|
177
|
-
## Developing reek / Contributing
|
|
214
|
+
## Developing `reek` / Contributing
|
|
178
215
|
|
|
179
|
-
The first thing you want to do after checking out the source code is to run
|
|
216
|
+
The first thing you want to do after checking out the source code is to run Bundler:
|
|
180
217
|
|
|
181
218
|
```
|
|
182
219
|
bundle install
|
|
183
220
|
```
|
|
184
221
|
|
|
185
|
-
and then
|
|
222
|
+
and then run the tests:
|
|
186
223
|
|
|
187
224
|
```bash
|
|
188
225
|
bundle exec rspec spec/your/file_spec.rb # Runs all tests in spec/your/file_spec.rb
|
|
@@ -191,49 +228,65 @@ bundle exec cucumber features/your_file.feature # Runs all scenarios in your
|
|
|
191
228
|
bundle exec cucumber features/your_file.feature:23 # Runs scenario at line 23
|
|
192
229
|
```
|
|
193
230
|
|
|
194
|
-
Or just run the whole test suite
|
|
231
|
+
Or just run the whole test suite:
|
|
195
232
|
|
|
196
233
|
```
|
|
197
234
|
bundle exec rake
|
|
198
235
|
```
|
|
199
236
|
|
|
200
|
-
From then on
|
|
237
|
+
From then on you should check out:
|
|
238
|
+
* [How reek works internally](docs/How-reek-works-internally.md)
|
|
239
|
+
* [the contributing guide](CONTRIBUTING.md)
|
|
240
|
+
|
|
201
241
|
|
|
202
242
|
If you don't feel like getting your hands dirty with code there are still other ways you can help us:
|
|
203
243
|
|
|
204
|
-
*
|
|
205
|
-
*
|
|
244
|
+
* Open up an [issue](https://github.com/troessner/reek/issues) and report bugs
|
|
245
|
+
* Suggest other improvements like additional smells for instance
|
|
206
246
|
|
|
207
247
|
## Output formats
|
|
208
248
|
|
|
209
|
-
`reek` supports
|
|
249
|
+
`reek` supports 5 output formats:
|
|
210
250
|
|
|
211
251
|
* plain text (default)
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
252
|
+
* HTML (`--format html`)
|
|
253
|
+
* YAML (`--format yaml`, see also [YAML Reports](docs/YAML-Reports.md))
|
|
254
|
+
* JSON (`--format json`)
|
|
255
|
+
* XML (`--format xml`)
|
|
256
|
+
|
|
257
|
+
## Working with Rails
|
|
258
|
+
|
|
259
|
+
With current versions of `reek` it's best to examine only your `app/models` folder, because `reek` raises false positives against views and controllers.
|
|
260
|
+
|
|
261
|
+
For example, `params` is a kind of DTO (data transfer object) close to the system boundary, and so its characteristics should be different than regular code. But Reek doesn't know that (yet); `reek` thinks that all those `params[:something]` calls are a problem, and reports them as smells.
|
|
262
|
+
|
|
263
|
+
We plan to improve Reek in the near future so that it plays better with Rails. For now though, your best bet is to restrict it to looking at `app/models` and `lib`.
|
|
215
264
|
|
|
216
265
|
## Additional resources
|
|
217
266
|
|
|
218
267
|
### Tools
|
|
219
268
|
|
|
220
|
-
|
|
221
|
-
[
|
|
269
|
+
* [Vim plugin for `reek`](https://github.com/rainerborene/vim-reek)
|
|
270
|
+
* [TextMate Bundle for `reek`](https://github.com/peeyush1234/reek.tmbundle)
|
|
271
|
+
* [Colorful output for `reek`](https://github.com/joenas/preek)
|
|
272
|
+
(also with [Guard::Preek](https://github.com/joenas/guard-preek))
|
|
273
|
+
* [Atom plugin for `reek`](https://atom.io/packages/linter-reek)
|
|
274
|
+
* [overcommit, a Git commit hook manager with support for
|
|
275
|
+
`reek`](https://github.com/brigade/overcommit)
|
|
222
276
|
|
|
223
|
-
|
|
224
|
-
[https://github.com/peeyush1234/reek.tmbundle](https://github.com/peeyush1234/reek.tmbundle)
|
|
277
|
+
### Miscellaneous
|
|
225
278
|
|
|
226
|
-
|
|
227
|
-
[
|
|
279
|
+
* [Reek Driven Development](docs/Reek-Driven-Development.md)
|
|
280
|
+
* [Versioning policy](docs/Versioning-Policy.md)
|
|
228
281
|
|
|
229
|
-
###
|
|
282
|
+
### More information
|
|
230
283
|
|
|
231
284
|
* [Stack Overflow](https://stackoverflow.com/questions/tagged/reek)
|
|
232
|
-
* [
|
|
285
|
+
* [RubyDoc.info](http://www.rubydoc.info/gems/reek)
|
|
233
286
|
|
|
234
287
|
## Contributors
|
|
235
288
|
|
|
236
|
-
A non
|
|
289
|
+
A non-exhaustive list:
|
|
237
290
|
|
|
238
291
|
* Kevin Rutherford
|
|
239
292
|
* Matijs van Zuijlen
|
data/bin/reek
CHANGED
data/config/cucumber.yml
ADDED
data/config/defaults.reek
CHANGED