reek 4.2.3 → 4.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/CHANGELOG.md +6 -0
  4. data/CONTRIBUTING.md +7 -6
  5. data/Gemfile +2 -2
  6. data/README.md +8 -15
  7. data/Rakefile +1 -1
  8. data/defaults.reek +1 -0
  9. data/features/command_line_interface/basic_usage.feature +8 -14
  10. data/features/command_line_interface/smell_selection.feature +4 -4
  11. data/features/command_line_interface/smells_count.feature +12 -14
  12. data/features/configuration_files/masking_smells.feature +31 -24
  13. data/features/configuration_loading.feature +15 -18
  14. data/features/programmatic_access.feature +7 -9
  15. data/features/rake_task/rake_task.feature +20 -24
  16. data/features/reports/json.feature +16 -28
  17. data/features/reports/reports.feature +56 -67
  18. data/features/reports/yaml.feature +13 -26
  19. data/features/samples.feature +3 -3
  20. data/features/step_definitions/sample_file_steps.rb +22 -156
  21. data/features/todo_list.feature +13 -14
  22. data/lib/reek/cli/options.rb +1 -1
  23. data/lib/reek/examiner.rb +45 -10
  24. data/lib/reek/smells/attribute.rb +3 -4
  25. data/lib/reek/smells/boolean_parameter.rb +2 -2
  26. data/lib/reek/smells/class_variable.rb +1 -1
  27. data/lib/reek/smells/control_parameter.rb +4 -4
  28. data/lib/reek/smells/data_clump.rb +2 -3
  29. data/lib/reek/smells/duplicate_method_call.rb +1 -1
  30. data/lib/reek/smells/feature_envy.rb +2 -2
  31. data/lib/reek/smells/irresponsible_module.rb +2 -3
  32. data/lib/reek/smells/long_parameter_list.rb +1 -1
  33. data/lib/reek/smells/long_yield_list.rb +1 -1
  34. data/lib/reek/smells/module_initialize.rb +1 -1
  35. data/lib/reek/smells/nested_iterators.rb +2 -2
  36. data/lib/reek/smells/nil_check.rb +1 -1
  37. data/lib/reek/smells/prima_donna_method.rb +5 -2
  38. data/lib/reek/smells/repeated_conditional.rb +1 -1
  39. data/lib/reek/smells/smell_detector.rb +1 -1
  40. data/lib/reek/smells/smell_warning.rb +6 -5
  41. data/lib/reek/smells/subclassed_from_core_class.rb +3 -3
  42. data/lib/reek/smells/too_many_constants.rb +1 -1
  43. data/lib/reek/smells/too_many_instance_variables.rb +1 -1
  44. data/lib/reek/smells/too_many_methods.rb +1 -1
  45. data/lib/reek/smells/too_many_statements.rb +1 -1
  46. data/lib/reek/smells/uncommunicative_method_name.rb +1 -1
  47. data/lib/reek/smells/uncommunicative_module_name.rb +1 -1
  48. data/lib/reek/smells/uncommunicative_parameter_name.rb +1 -1
  49. data/lib/reek/smells/uncommunicative_variable_name.rb +1 -1
  50. data/lib/reek/smells/unused_parameters.rb +1 -1
  51. data/lib/reek/smells/unused_private_method.rb +1 -1
  52. data/lib/reek/smells/utility_function.rb +2 -3
  53. data/lib/reek/spec/should_reek_of.rb +14 -1
  54. data/lib/reek/version.rb +1 -1
  55. data/samples/checkstyle.xml +7 -0
  56. data/samples/clean.rb +6 -0
  57. data/samples/configuration/.reek +0 -0
  58. data/samples/configuration/corrupt.reek +1 -0
  59. data/samples/configuration/empty.reek +0 -0
  60. data/samples/configuration/full_configuration.reek +9 -0
  61. data/{spec/samples/configuration/simple_configuration.reek → samples/configuration/full_mask.reek} +2 -2
  62. data/samples/configuration/non_public_modifiers_mask.reek +3 -0
  63. data/samples/configuration/partial_mask.reek +3 -0
  64. data/samples/configuration/with_excluded_paths.reek +4 -0
  65. data/{spec/samples → samples}/exceptions.reek +0 -0
  66. data/{spec/samples → samples}/inline.rb +0 -0
  67. data/{spec/samples → samples}/optparse.rb +0 -0
  68. data/samples/paths.rb +4 -0
  69. data/{spec/samples → samples}/redcloth.rb +0 -0
  70. data/samples/smelly.rb +7 -0
  71. data/samples/smelly_with_inline_mask.rb +8 -0
  72. data/samples/smelly_with_modifiers.rb +12 -0
  73. data/{spec/samples → samples}/source_with_exclude_paths/ignore_me/uncommunicative_method_name.rb +0 -0
  74. data/{spec/samples → samples}/source_with_exclude_paths/nested/ignore_me_as_well/irresponsible_module.rb +0 -0
  75. data/{spec/samples → samples}/source_with_exclude_paths/nested/uncommunicative_parameter_name.rb +0 -0
  76. data/{spec/samples → samples}/source_with_hidden_directories/.hidden/uncommunicative_method_name.rb +0 -0
  77. data/{spec/samples → samples}/source_with_hidden_directories/uncommunicative_parameter_name.rb +0 -0
  78. data/{spec/samples → samples}/source_with_non_ruby_files/gibberish +0 -0
  79. data/{spec/samples → samples}/source_with_non_ruby_files/python_source.py +0 -0
  80. data/{spec/samples → samples}/source_with_non_ruby_files/uncommunicative_parameter_name.rb +0 -0
  81. data/spec/reek/cli/application_spec.rb +1 -1
  82. data/spec/reek/cli/command/report_command_spec.rb +2 -5
  83. data/spec/reek/configuration/app_configuration_spec.rb +10 -8
  84. data/spec/reek/configuration/configuration_file_finder_spec.rb +24 -17
  85. data/spec/reek/examiner_spec.rb +84 -5
  86. data/spec/reek/report/json_report_spec.rb +1 -3
  87. data/spec/reek/report/xml_report_spec.rb +2 -3
  88. data/spec/reek/report/yaml_report_spec.rb +0 -2
  89. data/spec/reek/smells/attribute_spec.rb +21 -10
  90. data/spec/reek/smells/boolean_parameter_spec.rb +13 -12
  91. data/spec/reek/smells/class_variable_spec.rb +4 -4
  92. data/spec/reek/smells/control_parameter_spec.rb +25 -18
  93. data/spec/reek/smells/data_clump_spec.rb +5 -5
  94. data/spec/reek/smells/duplicate_method_call_spec.rb +1 -1
  95. data/spec/reek/smells/feature_envy_spec.rb +8 -2
  96. data/spec/reek/smells/irresponsible_module_spec.rb +16 -14
  97. data/spec/reek/smells/long_parameter_list_spec.rb +5 -1
  98. data/spec/reek/smells/long_yield_list_spec.rb +5 -2
  99. data/spec/reek/smells/nested_iterators_spec.rb +37 -13
  100. data/spec/reek/smells/nil_check_spec.rb +50 -53
  101. data/spec/reek/smells/prima_donna_method_spec.rb +9 -1
  102. data/spec/reek/smells/too_many_instance_variables_spec.rb +1 -1
  103. data/spec/reek/smells/too_many_methods_spec.rb +4 -4
  104. data/spec/reek/smells/too_many_statements_spec.rb +1 -1
  105. data/spec/reek/smells/uncommunicative_method_name_spec.rb +3 -3
  106. data/spec/reek/smells/uncommunicative_module_name_spec.rb +3 -3
  107. data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +3 -3
  108. data/spec/reek/smells/uncommunicative_variable_name_spec.rb +3 -3
  109. data/spec/reek/smells/utility_function_spec.rb +12 -8
  110. data/spec/reek/source/source_locator_spec.rb +5 -1
  111. data/spec/reek/spec/should_reek_of_spec.rb +20 -13
  112. data/spec/reek/spec/should_reek_spec.rb +6 -11
  113. data/spec/spec_helper.rb +2 -2
  114. metadata +28 -36
  115. data/spec/samples/all_but_one_masked/clean_one.rb +0 -7
  116. data/spec/samples/all_but_one_masked/dirty.rb +0 -8
  117. data/spec/samples/all_but_one_masked/masked.reek +0 -9
  118. data/spec/samples/checkstyle.xml +0 -13
  119. data/spec/samples/clean_due_to_masking/clean_one.rb +0 -7
  120. data/spec/samples/clean_due_to_masking/clean_three.rb +0 -7
  121. data/spec/samples/clean_due_to_masking/clean_two.rb +0 -7
  122. data/spec/samples/clean_due_to_masking/dirty_one.rb +0 -7
  123. data/spec/samples/clean_due_to_masking/dirty_two.rb +0 -7
  124. data/spec/samples/clean_due_to_masking/masked.reek +0 -11
  125. data/spec/samples/configuration/full_configuration.reek +0 -9
  126. data/spec/samples/configuration/with_excluded_paths.reek +0 -4
  127. data/spec/samples/masked_by_dotfile/.reek +0 -9
  128. data/spec/samples/masked_by_dotfile/dirty.rb +0 -8
  129. data/spec/samples/no_config_file/dirty.rb +0 -8
  130. data/spec/samples/three_clean_files/clean_one.rb +0 -7
  131. data/spec/samples/three_clean_files/clean_three.rb +0 -7
  132. data/spec/samples/three_clean_files/clean_two.rb +0 -7
  133. data/spec/samples/two_smelly_files/dirty_one.rb +0 -8
  134. data/spec/samples/two_smelly_files/dirty_two.rb +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: febd828ee14c493e88c62e3676181d9aed38cda2
4
- data.tar.gz: a7d7d7a5dc1e964a21466b4c94d5e1c7ad5a1550
3
+ metadata.gz: 7756b10a94b5df5b45c50b6cdaa6577146dbbf15
4
+ data.tar.gz: d1e67defd358f1ce5f60affaa2c33e45aa09d744
5
5
  SHA512:
6
- metadata.gz: f43c2262139ad0bfc26ed4fdc200480b4cdc228f7480ea65d62df34ec01339ce0feb9c1187c4be6a00be6199602ac638c44ae1fcffe3aaa1bcd31a4994243564
7
- data.tar.gz: d6e90ce2c090073d73e9abe81fd95a430a56dc6aa07490e064383669a4e9bf7fc1be36393f545a83659f751ba1445705ccc5c0d607e6962456f1dc11c04a7617
6
+ metadata.gz: f2cbb1aacb409e57504ab7206b917648ad9e5db97a98302179a5902ab8a8b83335fcc674580f380f2314ec055f9c8be35156c1bab5d7b5ba6384429a8b42fdf9
7
+ data.tar.gz: 7476f5a7ce8dc2a0ab1f4791c1d5d0a4688b2462761f50775dd8404928faced642dfeedbbacbb2d3525e673003889fe3e7c643305bb92658ea397ad5fcdc4368
data/.rubocop.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  AllCops:
2
2
  Exclude:
3
- - 'spec/samples/**/*'
3
+ - 'samples/**/*'
4
4
  - 'tmp/**/*'
5
5
  - 'vendor/**/*'
6
6
  TargetRubyVersion: 2.1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change log
2
2
 
3
+ ## 4.2.4 (2016-08-15)
4
+
5
+ * (troessner) Make Reek more resilient on incomprehensible source.
6
+ * (troessner) Make our parameter handling consistent in smell detectors.
7
+ * (Drenmi) Rename `#inspect` method to `#sniff`
8
+
3
9
  ## 4.2.3 (2016-08-05)
4
10
 
5
11
  * (soutaro) Add SexpExtensions::CSendNode for safe navigation operator
data/CONTRIBUTING.md CHANGED
@@ -10,8 +10,6 @@ only to find us suggesting large parts should be rewritten.
10
10
  Don’t hesitate to offer trivial fixes (spelling, better naming
11
11
  ideas, etc.) – we’ll let you know if you’re overdoing it. :)
12
12
 
13
-
14
-
15
13
  ## Reporting Issues
16
14
 
17
15
  Search [all existing (open _and_ closed)
@@ -29,8 +27,6 @@ version, Ruby platform (MRI, JRuby, etc.), operating system.
29
27
  Try to provide a minimal example that reproduces the issue.
30
28
  Extra kudos if you can write it as a failing test. :)
31
29
 
32
-
33
-
34
30
  ## Setup and Pull Request Basics
35
31
 
36
32
  Fork Reek, then clone it, make sure you have
@@ -55,8 +51,13 @@ Make sure you have read our [style guide](docs/style-guide.md) before you
55
51
  start contributing.
56
52
 
57
53
  Then start hacking and add new tests which make sure that your new feature works or
58
- demonstrate that your fix was needed; please also [write good commit
59
- messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
54
+ demonstrate that your fix was needed.
55
+ Reek is using [Rspec](http://rspec.info/) for unit and functional testing and [cucumber]() for integration tests.
56
+
57
+ When it comes to Rspec we're trying to follow [betterspecs](http://betterspecs.org/).
58
+ Additonally you can find an excellent cheat sheet on how to write idiomatic Rspec [here](http://www.rubypigeon.com/posts/rspec-core-cheat-sheet).
59
+
60
+ We also care a lot about [good commit messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
60
61
 
61
62
  Once you’re happy with your feature / fix – or want to
62
63
  share it as a work-in-progress and request comments – once
data/Gemfile CHANGED
@@ -10,9 +10,9 @@ group :development do
10
10
  gem 'mutant-rspec', '~> 0.8.8'
11
11
  gem 'rake', '~> 11.1'
12
12
  gem 'rspec', '~> 3.0'
13
- gem 'rubocop', '~> 0.41.1'
13
+ gem 'rubocop', '~> 0.42.0'
14
14
  gem 'simplecov', '~> 0.12.0'
15
- gem 'yard', '~> 0.8.7'
15
+ gem 'yard', '~> 0.9.5'
16
16
  gem 'activesupport', '~> 4.2'
17
17
 
18
18
  platforms :mri do
data/README.md CHANGED
@@ -71,12 +71,11 @@ reek [options] [dir_or_source_file]*
71
71
  Imagine a source file `demo.rb` containing:
72
72
 
73
73
  ```Ruby
74
- class Dirty
75
- # This method smells of :reek:NestedIterators but ignores them
76
- def awful(x, y, offset = 0, log = false)
77
- puts @screen.title
78
- @screen = widgets.map { |w| w.each { |key| key += 3 * x } }
79
- puts @screen.contents
74
+ # Smelly class
75
+ class Smelly
76
+ # This will reek of UncommunicativeMethodName
77
+ def x
78
+ y = 10 # This will reek of UncommunicativeVariableName
80
79
  end
81
80
  end
82
81
  ```
@@ -85,15 +84,9 @@ Reek will report the following code smells in this file:
85
84
 
86
85
  ```
87
86
  $ reek demo.rb
88
- demo.rb -- 8 warnings:
89
- [1]:Dirty has no descriptive comment (IrresponsibleModule)
90
- [3]:Dirty#awful has 4 parameters (LongParameterList)
91
- [3]:Dirty#awful has boolean parameter 'log' (BooleanParameter)
92
- [3]:Dirty#awful has the parameter name 'x' (UncommunicativeParameterName)
93
- [5]:Dirty#awful has the variable name 'w' (UncommunicativeVariableName)
94
- [3]:Dirty#awful has unused parameter 'log' (UnusedParameters)
95
- [3]:Dirty#awful has unused parameter 'offset' (UnusedParameters)
96
- [3]:Dirty#awful has unused parameter 'y' (UnusedParameters)
87
+ demo.rb -- 2 warnings:
88
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
89
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
97
90
  ```
98
91
 
99
92
  ## Supported rubies
data/Rakefile CHANGED
@@ -4,5 +4,5 @@ require 'rake/clean'
4
4
  Dir['tasks/**/*.rake'].each { |t| load t }
5
5
 
6
6
  task local_test_run: [:test, :rubocop, 'test:quality']
7
- task ci: [:test, :rubocop, 'test:quality', :ataru, :mutant]
7
+ task ci: [:test, :rubocop, 'test:quality', :ataru]
8
8
  task default: :local_test_run
data/defaults.reek CHANGED
@@ -119,3 +119,4 @@ UnusedPrivateMethod:
119
119
  UtilityFunction:
120
120
  enabled: true
121
121
  exclude: []
122
+ public_methods_only: false
@@ -3,19 +3,13 @@ Feature: The Reek CLI maintains backwards compatibility
3
3
  As a developer
4
4
  I want to have a stable basic command line interface
5
5
 
6
- Scenario: the demo example reports as expected
7
- Given the smelly file 'demo.rb' from the example in the README
8
- When I run reek demo.rb
6
+ Scenario: the example from README reports as expected
7
+ Given the smelly file 'smelly.rb'
8
+ When I run reek smelly.rb
9
9
  Then the exit status indicates smells
10
10
  And it reports:
11
- """
12
- demo.rb -- 8 warnings:
13
- [3]:BooleanParameter: Dirty#awful has boolean parameter 'log' [https://github.com/troessner/reek/blob/master/docs/Boolean-Parameter.md]
14
- [1]:IrresponsibleModule: Dirty has no descriptive comment [https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md]
15
- [3]:LongParameterList: Dirty#awful has 4 parameters [https://github.com/troessner/reek/blob/master/docs/Long-Parameter-List.md]
16
- [3]:UncommunicativeParameterName: Dirty#awful has the parameter name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Parameter-Name.md]
17
- [5]:UncommunicativeVariableName: Dirty#awful has the variable name 'w' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
18
- [3]:UnusedParameters: Dirty#awful has unused parameter 'log' [https://github.com/troessner/reek/blob/master/docs/Unused-Parameters.md]
19
- [3]:UnusedParameters: Dirty#awful has unused parameter 'offset' [https://github.com/troessner/reek/blob/master/docs/Unused-Parameters.md]
20
- [3]:UnusedParameters: Dirty#awful has unused parameter 'y' [https://github.com/troessner/reek/blob/master/docs/Unused-Parameters.md]
21
- """
11
+ """
12
+ smelly.rb -- 2 warnings:
13
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
14
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
15
+ """
@@ -4,12 +4,12 @@ Feature: Smell selection
4
4
  I want to be able to selectively activate smell detectors
5
5
 
6
6
  Scenario: --smell selects a smell to detect
7
- Given a smelly file called 'smelly.rb'
8
- And a configuration file masking some duplication smells called 'config.reek'
9
- When I run reek --no-line-numbers --smell UncommunicativeMethodName smelly.rb
7
+ Given the smelly file 'smelly.rb'
8
+ And a configuration file 'partial_mask.reek'
9
+ When I run reek --no-line-numbers --smell UncommunicativeVariableName smelly.rb
10
10
  Then the exit status indicates smells
11
11
  And it reports:
12
12
  """
13
13
  smelly.rb -- 1 warning:
14
- UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
14
+ UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
15
15
  """
@@ -3,15 +3,14 @@ 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
- Given a smelly file called 'smelly.rb'
6
+ Given the smelly file 'smelly.rb'
7
7
  When I run reek smelly.rb
8
8
  Then the exit status indicates smells
9
9
  And it reports:
10
10
  """
11
- smelly.rb -- 3 warnings:
12
- [4, 5]:DuplicateMethodCall: Smelly#m calls @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
13
- [4, 5]:DuplicateMethodCall: Smelly#m calls puts @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
14
- [3]:UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
11
+ smelly.rb -- 2 warnings:
12
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
13
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
15
14
  """
16
15
 
17
16
  Scenario: Output total number of smells when inspecting multiple files
@@ -21,18 +20,17 @@ Feature: Reports total number of code smells
21
20
  And it reports:
22
21
  """
23
22
  smelly/dirty_one.rb -- 2 warnings:
24
- [1]:IrresponsibleModule: Dirty has no descriptive comment [https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md]
25
- [2]:UncommunicativeMethodName: Dirty#a has the name 'a' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
26
- smelly/dirty_two.rb -- 3 warnings:
27
- [1]:IrresponsibleModule: Dirty has no descriptive comment [https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md]
28
- [2]:UncommunicativeMethodName: Dirty#a has the name 'a' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
29
- [3]:UncommunicativeMethodName: Dirty#b has the name 'b' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
30
- 5 total warnings
23
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
24
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
25
+ smelly/dirty_two.rb -- 2 warnings:
26
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
27
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
28
+ 4 total warnings
31
29
  """
32
30
 
33
31
  Scenario: Output total number of smells even if total equals 0
34
- Given a directory called 'clean_files' containing some clean files
35
- When I run reek clean_files
32
+ Given a directory called 'clean' containing two clean files
33
+ When I run reek clean
36
34
  Then it succeeds
37
35
  And it reports:
38
36
  """
@@ -4,8 +4,8 @@ Feature: Masking smells using config files
4
4
  I want to mask some smells using config files
5
5
 
6
6
  Scenario: corrupt config file prevents normal output
7
- Given a smelly file called 'smelly.rb'
8
- And a corrupt configuration file called 'corrupt.reek'
7
+ Given the smelly file 'smelly.rb'
8
+ And a configuration file 'corrupt.reek'
9
9
  When I run reek -c corrupt.reek smelly.rb
10
10
  Then it reports the error 'Error: Invalid configuration file "corrupt.reek" -- Not a hash'
11
11
  And the exit status indicates an error
@@ -16,44 +16,51 @@ Feature: Masking smells using config files
16
16
  Then it reports the error "Error: No such file - not_here.rb"
17
17
 
18
18
  Scenario: masking smells in the configuration file
19
- Given a smelly file called 'smelly.rb'
20
- And a masking configuration file called 'config.reek'
21
- When I run reek -c config.reek smelly.rb
19
+ Given the smelly file 'smelly.rb'
20
+ And a configuration file 'full_mask.reek'
21
+ When I run reek -c full_mask.reek smelly.rb
22
22
  Then it succeeds
23
23
  And it reports nothing
24
24
 
25
25
  Scenario: allow masking some calls for duplication smell
26
- Given a smelly file called 'smelly.rb'
27
- And a configuration file masking some duplication smells called 'config.reek'
28
- When I run reek -c config.reek smelly.rb
26
+ Given the smelly file 'smelly.rb'
27
+ And a configuration file 'partial_mask.reek'
28
+ When I run reek -c partial_mask.reek smelly.rb
29
29
  Then the exit status indicates smells
30
30
  And it reports:
31
31
  """
32
- smelly.rb -- 2 warnings:
33
- [4, 5]:DuplicateMethodCall: Smelly#m calls @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
34
- [3]:UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
32
+ smelly.rb -- 1 warning:
33
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
35
34
  """
36
35
 
37
36
  Scenario: provide extra masking inline in comments
38
- Given a smelly file with inline masking called 'inline.rb'
39
- And a masking configuration file called 'config.reek'
40
- When I run reek -c config.reek inline.rb
37
+ Given the smelly file 'smelly_with_inline_mask.rb'
38
+ And a configuration file 'partial_mask.reek'
39
+ When I run reek -c partial_mask.reek smelly_with_inline_mask.rb
40
+ Then it succeeds
41
+ And it reports nothing
42
+
43
+ Scenario: empty config file outputs normally
44
+ Given the smelly file 'smelly.rb'
45
+ And a configuration file 'empty.reek'
46
+ When I run reek -c empty.reek smelly.rb
41
47
  Then the exit status indicates smells
42
48
  And it reports:
43
- """
44
- inline.rb -- 2 warnings:
45
- [5]:UncommunicativeVariableName: Dirty has the variable name '@s' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
46
- [5]:UncommunicativeVariableName: Dirty#a has the variable name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
47
- """
49
+ """
50
+ smelly.rb -- 2 warnings:
51
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
52
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
53
+ """
54
+
48
55
 
49
56
  Scenario: Disable UtilityFunction for non-public methods
50
- Given a smelly file called 'smelly.rb' with private, protected and public UtilityFunction methods
51
- And a configuration file disabling UtilityFunction for non-public methods called 'config.reek'
52
- When I run reek -c config.reek smelly.rb
57
+ Given the smelly file 'smelly_with_modifiers.rb'
58
+ And a configuration file 'non_public_modifiers_mask.reek'
59
+ When I run reek -c non_public_modifiers_mask.reek smelly_with_modifiers.rb
53
60
  Then the exit status indicates smells
54
61
  And it reports:
55
62
  """
56
- smelly.rb -- 1 warning:
57
- [3]:UtilityFunction: Klass#public_method doesn't depend on instance state (maybe move it to another class?) [https://github.com/troessner/reek/blob/master/docs/Utility-Function.md]
63
+ smelly_with_modifiers.rb -- 1 warning:
64
+ [7]:UtilityFunction: Klass#public_method doesn't depend on instance state (maybe move it to another class?) [https://github.com/troessner/reek/blob/master/docs/Utility-Function.md]
58
65
  """
59
66
  But it does not report private or protected methods
@@ -11,41 +11,38 @@ Feature: Offer different ways how to load configuration
11
11
  Reek will check these in order and stop after the first file found.
12
12
 
13
13
  Scenario: Default configuration
14
- Given a smelly file called 'smelly.rb'
14
+ Given the smelly file 'smelly.rb'
15
15
  When I run reek smelly.rb
16
16
  Then the exit status indicates smells
17
17
  And it reports:
18
18
  """
19
- smelly.rb -- 3 warnings:
20
- [4, 5]:DuplicateMethodCall: Smelly#m calls @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
21
- [4, 5]:DuplicateMethodCall: Smelly#m calls puts @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
22
- [3]:UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
19
+ smelly.rb -- 2 warnings:
20
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
21
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
23
22
  """
24
23
 
25
24
  Scenario: Configuration via CLI
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
25
+ Given the smelly file 'smelly.rb'
26
+ And a configuration file 'full_mask.reek'
27
+ When I run reek -c full_mask.reek smelly.rb
29
28
  Then it reports no errors
30
29
  And it succeeds
31
30
 
32
31
  Scenario: Configuration file in working directory
33
- Given a smelly file called 'smelly.rb'
34
- And a masking configuration file called 'config.reek'
32
+ Given the smelly file 'smelly.rb'
33
+ And a configuration file 'full_mask.reek'
35
34
  When I run reek smelly.rb
36
35
  Then it reports no errors
37
36
  And it succeeds
38
37
 
39
38
  Scenario: Two opposing configuration files and we stop after the first one
40
- Given a smelly file called 'smelly.rb' in a subdirectory
41
- And an enabling configuration file in the subdirectory
42
- And a masking configuration file called 'config.reek'
43
- When I run "reek smelly.rb" in the subdirectory
39
+ Given the smelly file 'smelly.rb' in a subdirectory
40
+ And a configuration file 'partial_mask.reek' in a subdirectory
41
+ And a configuration file 'full_mask.reek'
42
+ When I run "reek smelly.rb" in a subdirectory
44
43
  Then the exit status indicates smells
45
44
  And it reports:
46
45
  """
47
- smelly.rb -- 3 warnings:
48
- [4, 5]:DuplicateMethodCall: Smelly#m calls @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
49
- [4, 5]:DuplicateMethodCall: Smelly#m calls puts @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
50
- [3]:UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
46
+ smelly.rb -- 1 warning:
47
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
51
48
  """
@@ -4,7 +4,7 @@ Feature: Using Reek programmatically
4
4
  I want to be able to use its classes
5
5
 
6
6
  Scenario: Accessing smells found by an examiner
7
- Given a smelly file called 'smelly.rb'
7
+ Given the smelly file 'smelly.rb'
8
8
  And a file named "examine.rb" with:
9
9
  """
10
10
  require 'reek'
@@ -17,13 +17,12 @@ Feature: Using Reek programmatically
17
17
  Then it reports no errors
18
18
  And it reports:
19
19
  """
20
- calls @foo.bar 2 times
21
- calls puts @foo.bar 2 times
22
- has the name 'm'
20
+ has the name 'x'
21
+ has the variable name 'y'
23
22
  """
24
23
 
25
24
  Scenario: Using Reek's built-in report classes
26
- Given a smelly file called 'smelly.rb'
25
+ Given the smelly file 'smelly.rb'
27
26
  And a file named "examine.rb" with:
28
27
  """
29
28
  require 'reek'
@@ -36,8 +35,7 @@ Feature: Using Reek programmatically
36
35
  Then it reports no errors
37
36
  And it reports:
38
37
  """
39
- smelly.rb -- 3 warnings:
40
- DuplicateMethodCall: Smelly#m calls @foo.bar 2 times
41
- DuplicateMethodCall: Smelly#m calls puts @foo.bar 2 times
42
- UncommunicativeMethodName: Smelly#m has the name 'm'
38
+ smelly.rb -- 2 warnings:
39
+ UncommunicativeMethodName: Smelly#x has the name 'x'
40
+ UncommunicativeVariableName: Smelly#x has the variable name 'y'
43
41
  """
@@ -3,7 +3,7 @@ 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
+ Given the smelly file 'smelly.rb'
7
7
  When I run rake reek with:
8
8
  """
9
9
  Reek::Rake::Task.new do |t|
@@ -14,14 +14,13 @@ Feature: Reek can be driven through its Task
14
14
  Then the exit status indicates an error
15
15
  And it reports:
16
16
  """
17
- smelly.rb -- 3 warnings:
18
- [4, 5]:DuplicateMethodCall: Smelly#m calls @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
19
- [4, 5]:DuplicateMethodCall: Smelly#m calls puts @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
20
- [3]:UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
17
+ smelly.rb -- 2 warnings:
18
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
19
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
21
20
  """
22
21
 
23
22
  Scenario: source_files using a FileList instead of a String
24
- Given a smelly file called 'smelly.rb'
23
+ Given the smelly file 'smelly.rb'
25
24
  When I run rake reek with:
26
25
  """
27
26
  Reek::Rake::Task.new do |t|
@@ -32,14 +31,13 @@ Feature: Reek can be driven through its Task
32
31
  Then the exit status indicates an error
33
32
  And it reports:
34
33
  """
35
- smelly.rb -- 3 warnings:
36
- [4, 5]:DuplicateMethodCall: Smelly#m calls @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
37
- [4, 5]:DuplicateMethodCall: Smelly#m calls puts @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
38
- [3]:UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
34
+ smelly.rb -- 2 warnings:
35
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
36
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
39
37
  """
40
38
 
41
39
  Scenario: name changes the task name
42
- Given a smelly file called 'smelly.rb'
40
+ Given the smelly file 'smelly.rb'
43
41
  When I run rake silky with:
44
42
  """
45
43
  Reek::Rake::Task.new('silky') do |t|
@@ -50,14 +48,13 @@ Feature: Reek can be driven through its Task
50
48
  Then the exit status indicates an error
51
49
  And it reports:
52
50
  """
53
- smelly.rb -- 3 warnings:
54
- [4, 5]:DuplicateMethodCall: Smelly#m calls @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
55
- [4, 5]:DuplicateMethodCall: Smelly#m calls puts @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
56
- [3]:UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
51
+ smelly.rb -- 2 warnings:
52
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
53
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
57
54
  """
58
55
 
59
56
  Scenario: verbose prints the reek command
60
- Given a smelly file called 'smelly.rb'
57
+ Given the smelly file 'smelly.rb'
61
58
  When I run rake reek with:
62
59
  """
63
60
  Reek::Rake::Task.new do |t|
@@ -69,7 +66,7 @@ Feature: Reek can be driven through its Task
69
66
  And stdout includes "Running 'reek' rake command"
70
67
 
71
68
  Scenario: fail_on_error can hide the error status
72
- Given a smelly file called 'smelly.rb'
69
+ Given the smelly file 'smelly.rb'
73
70
  When I run rake reek with:
74
71
  """
75
72
  Reek::Rake::Task.new do |t|
@@ -82,19 +79,18 @@ Feature: Reek can be driven through its Task
82
79
  And it succeeds
83
80
  And it reports:
84
81
  """
85
- smelly.rb -- 3 warnings:
86
- [4, 5]:DuplicateMethodCall: Smelly#m calls @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
87
- [4, 5]:DuplicateMethodCall: Smelly#m calls puts @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
88
- [3]:UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
82
+ smelly.rb -- 2 warnings:
83
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
84
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
89
85
  """
90
86
 
91
87
  Scenario: can be configured with config_file
92
- Given a smelly file called 'smelly.rb'
93
- And a masking configuration file called 'config.reek'
88
+ Given the smelly file 'smelly.rb'
89
+ And a configuration file 'full_mask.reek'
94
90
  When I run rake reek with:
95
91
  """
96
92
  Reek::Rake::Task.new do |t|
97
- t.config_file = 'config.reek'
93
+ t.config_file = 'full_mask.reek'
98
94
  t.source_files = 'smelly.rb'
99
95
  end
100
96
  """