reek 4.2.3 → 4.2.4

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.
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
@@ -3,8 +3,8 @@ Feature: Report smells using simple JSON layout
3
3
  output a list of smells in JSON.
4
4
 
5
5
  Scenario: output is empty when there are no smells
6
- Given a directory called 'clean_files' containing some clean files
7
- When I run reek --format json clean_files
6
+ Given a directory called 'clean' containing two clean files
7
+ When I run reek --format json clean
8
8
  Then it succeeds
9
9
  And it reports this JSON:
10
10
  """
@@ -12,40 +12,29 @@ Feature: Report smells using simple JSON layout
12
12
  """
13
13
 
14
14
  Scenario: Indicate smells and print them as JSON when using files
15
- Given a smelly file called 'smelly.rb'
15
+ Given the smelly file 'smelly.rb'
16
16
  When I run reek --format json smelly.rb
17
17
  Then the exit status indicates smells
18
18
  And it reports this JSON:
19
19
  """
20
20
  [
21
21
  {
22
- "smell_type": "DuplicateMethodCall",
23
- "source": "smelly.rb",
24
- "context": "Smelly#m",
25
- "lines": [ 4, 5 ],
26
- "message": "calls @foo.bar 2 times",
27
- "name": "@foo.bar",
28
- "wiki_link": "https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md",
29
- "count": 2
30
- },
31
- {
32
- "smell_type": "DuplicateMethodCall",
22
+ "smell_type": "UncommunicativeMethodName",
33
23
  "source": "smelly.rb",
34
- "context": "Smelly#m",
35
- "lines": [ 4, 5 ],
36
- "message": "calls puts @foo.bar 2 times",
37
- "name": "puts @foo.bar",
38
- "wiki_link": "https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md",
39
- "count": 2
24
+ "context": "Smelly#x",
25
+ "lines": [ 4 ],
26
+ "message": "has the name 'x'",
27
+ "wiki_link": "https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md",
28
+ "name": "x"
40
29
  },
41
30
  {
42
- "smell_type": "UncommunicativeMethodName",
31
+ "smell_type": "UncommunicativeVariableName",
43
32
  "source": "smelly.rb",
44
- "context": "Smelly#m",
45
- "lines": [ 3 ],
46
- "message": "has the name 'm'",
47
- "wiki_link": "https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md",
48
- "name": "m"
33
+ "context": "Smelly#x",
34
+ "lines": [ 5 ],
35
+ "message": "has the variable name 'y'",
36
+ "wiki_link": "https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md",
37
+ "name": "y"
49
38
  }
50
39
  ]
51
40
  """
@@ -64,8 +53,7 @@ Feature: Report smells using simple JSON layout
64
53
  1
65
54
  ],
66
55
  "message": "has no descriptive comment",
67
- "wiki_link": "https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md",
68
- "name": "Turn"
56
+ "wiki_link": "https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md"
69
57
  }
70
58
  ]
71
59
  """
@@ -10,13 +10,12 @@ Feature: Correctly formatted reports
10
10
  And it reports:
11
11
  """
12
12
  smelly/dirty_one.rb -- 2 warnings:
13
- [1]:IrresponsibleModule: Dirty has no descriptive comment [https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md]
14
- [2]:UncommunicativeMethodName: Dirty#a has the name 'a' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
15
- smelly/dirty_two.rb -- 3 warnings:
16
- [1]:IrresponsibleModule: Dirty has no descriptive comment [https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md]
17
- [2]:UncommunicativeMethodName: Dirty#a has the name 'a' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
18
- [3]:UncommunicativeMethodName: Dirty#b has the name 'b' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
19
- 5 total 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
+ smelly/dirty_two.rb -- 2 warnings:
16
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
17
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
18
+ 4 total warnings
20
19
  """
21
20
 
22
21
  Examples:
@@ -31,13 +30,12 @@ Feature: Correctly formatted reports
31
30
  And it reports:
32
31
  """
33
32
  smelly/dirty_one.rb -- 2 warnings:
34
- [1]:IrresponsibleModule: Dirty has no descriptive comment [https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md]
35
- [2]:UncommunicativeMethodName: Dirty#a has the name 'a' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
36
- smelly/dirty_two.rb -- 3 warnings:
37
- [1]:IrresponsibleModule: Dirty has no descriptive comment [https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md]
38
- [2]:UncommunicativeMethodName: Dirty#a has the name 'a' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
39
- [3]:UncommunicativeMethodName: Dirty#b has the name 'b' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
40
- 5 total warnings
33
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
34
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
35
+ smelly/dirty_two.rb -- 2 warnings:
36
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
37
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
38
+ 4 total warnings
41
39
  """
42
40
 
43
41
  Examples:
@@ -52,14 +50,13 @@ Feature: Correctly formatted reports
52
50
  Then the exit status indicates smells
53
51
  And it reports:
54
52
  """
55
- smelly/dirty_two.rb -- 3 warnings:
56
- [1]:IrresponsibleModule: Dirty has no descriptive comment [https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md]
57
- [2]:UncommunicativeMethodName: Dirty#a has the name 'a' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
58
- [3]:UncommunicativeMethodName: Dirty#b has the name 'b' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
53
+ smelly/dirty_two.rb -- 2 warnings:
54
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
55
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
59
56
  smelly/dirty_one.rb -- 2 warnings:
60
- [1]:IrresponsibleModule: Dirty has no descriptive comment [https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md]
61
- [2]:UncommunicativeMethodName: Dirty#a has the name 'a' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
62
- 5 total warnings
57
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
58
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
59
+ 4 total warnings
63
60
  """
64
61
 
65
62
  Examples:
@@ -68,8 +65,8 @@ Feature: Correctly formatted reports
68
65
  | --sort-by s |
69
66
 
70
67
  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
68
+ Given a directory called 'clean' containing two clean files
69
+ When I run reek clean
73
70
  Then it succeeds
74
71
  And it reports:
75
72
  """
@@ -77,14 +74,13 @@ Feature: Correctly formatted reports
77
74
  """
78
75
 
79
76
  Scenario Outline: --empty-headings turns on headings for fragrant files
80
- Given a directory called 'clean_files' containing some clean files
81
- When I run reek <option> clean_files
77
+ Given a directory called 'clean' containing two clean files
78
+ When I run reek <option> clean
82
79
  Then it succeeds
83
80
  And it reports:
84
81
  """
85
- clean_files/clean_one.rb -- 0 warnings
86
- clean_files/clean_three.rb -- 0 warnings
87
- clean_files/clean_two.rb -- 0 warnings
82
+ clean/clean_one.rb -- 0 warnings
83
+ clean/clean_two.rb -- 0 warnings
88
84
  0 total warnings
89
85
  """
90
86
 
@@ -94,8 +90,8 @@ Feature: Correctly formatted reports
94
90
  | -V |
95
91
 
96
92
  Scenario Outline: --no-empty-headings turns off headings for fragrant files
97
- Given a directory called 'clean_files' containing some clean files
98
- When I run reek <option> clean_files
93
+ Given a directory called 'clean' containing two clean files
94
+ When I run reek <option> clean
99
95
  Then it succeeds
100
96
  And it reports:
101
97
  """
@@ -108,15 +104,14 @@ Feature: Correctly formatted reports
108
104
  | -V --no-empty-headings |
109
105
 
110
106
  Scenario Outline: --no-line-numbers turns off line numbers
111
- Given a smelly file called 'smelly.rb'
107
+ Given the smelly file 'smelly.rb'
112
108
  When I run reek <option> smelly.rb
113
109
  Then the exit status indicates smells
114
110
  And it reports:
115
111
  """
116
- smelly.rb -- 3 warnings:
117
- DuplicateMethodCall: Smelly#m calls @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
118
- DuplicateMethodCall: Smelly#m calls puts @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
119
- UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
112
+ smelly.rb -- 2 warnings:
113
+ UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
114
+ UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
120
115
  """
121
116
 
122
117
  Examples:
@@ -126,15 +121,14 @@ Feature: Correctly formatted reports
126
121
  | -V --no-line-numbers |
127
122
 
128
123
  Scenario Outline: --line-numbers turns on line numbers
129
- Given a smelly file called 'smelly.rb'
124
+ Given the smelly file 'smelly.rb'
130
125
  When I run reek <option> smelly.rb
131
126
  Then the exit status indicates smells
132
127
  And it reports:
133
128
  """
134
- smelly.rb -- 3 warnings:
135
- [4, 5]:DuplicateMethodCall: Smelly#m calls @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
136
- [4, 5]:DuplicateMethodCall: Smelly#m calls puts @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
137
- [3]:UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
129
+ smelly.rb -- 2 warnings:
130
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
131
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
138
132
  """
139
133
 
140
134
  Examples:
@@ -144,15 +138,14 @@ Feature: Correctly formatted reports
144
138
  | --no-line-numbers -n |
145
139
 
146
140
  Scenario Outline: --single-line shows filename and one line number
147
- Given a smelly file called 'smelly.rb'
141
+ Given the smelly file 'smelly.rb'
148
142
  When I run reek <option> smelly.rb
149
143
  Then the exit status indicates smells
150
144
  And it reports:
151
145
  """
152
- smelly.rb -- 3 warnings:
153
- smelly.rb:4: DuplicateMethodCall: Smelly#m calls @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
154
- smelly.rb:4: DuplicateMethodCall: Smelly#m calls puts @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
155
- smelly.rb:3: UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
146
+ smelly.rb -- 2 warnings:
147
+ smelly.rb:4: UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
148
+ smelly.rb:5: UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
156
149
  """
157
150
 
158
151
  Examples:
@@ -169,13 +162,12 @@ Feature: Correctly formatted reports
169
162
  And it reports:
170
163
  """
171
164
  smelly/dirty_one.rb -- 2 warnings:
172
- [1]:IrresponsibleModule: Dirty has no descriptive comment [https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md]
173
- [2]:UncommunicativeMethodName: Dirty#a has the name 'a' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
174
- smelly/dirty_two.rb -- 3 warnings:
175
- [1]:IrresponsibleModule: Dirty has no descriptive comment [https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md]
176
- [2]:UncommunicativeMethodName: Dirty#a has the name 'a' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
177
- [3]:UncommunicativeMethodName: Dirty#b has the name 'b' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
178
- 5 total warnings
165
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
166
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
167
+ smelly/dirty_two.rb -- 2 warnings:
168
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
169
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
170
+ 4 total warnings
179
171
  """
180
172
 
181
173
  Examples:
@@ -184,15 +176,14 @@ Feature: Correctly formatted reports
184
176
  | smelly |
185
177
 
186
178
  Scenario Outline: -U or --wiki-links adds helpful links to smell warnings
187
- Given a smelly file called 'smelly.rb'
179
+ Given the smelly file 'smelly.rb'
188
180
  When I run reek <option> smelly.rb
189
181
  Then the exit status indicates smells
190
182
  And it reports:
191
183
  """
192
- smelly.rb -- 3 warnings:
193
- [4, 5]:DuplicateMethodCall: Smelly#m calls @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
194
- [4, 5]:DuplicateMethodCall: Smelly#m calls puts @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
195
- [3]:UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
184
+ smelly.rb -- 2 warnings:
185
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
186
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
196
187
  """
197
188
 
198
189
  Examples:
@@ -201,27 +192,25 @@ Feature: Correctly formatted reports
201
192
  | --wiki-links |
202
193
 
203
194
  Scenario: --no-wiki-links drops links from smell warnings
204
- Given a smelly file called 'smelly.rb'
195
+ Given the smelly file 'smelly.rb'
205
196
  When I run reek --no-wiki-links smelly.rb
206
197
  Then the exit status indicates smells
207
198
  And it reports:
208
199
  """
209
- smelly.rb -- 3 warnings:
210
- [4, 5]:DuplicateMethodCall: Smelly#m calls @foo.bar 2 times
211
- [4, 5]:DuplicateMethodCall: Smelly#m calls puts @foo.bar 2 times
212
- [3]:UncommunicativeMethodName: Smelly#m has the name 'm'
200
+ smelly.rb -- 2 warnings:
201
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x'
202
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y'
213
203
  """
214
204
 
215
205
  Scenario Outline: --wiki-links is independent of --line-numbers
216
- Given a smelly file called 'smelly.rb'
206
+ Given the smelly file 'smelly.rb'
217
207
  When I run reek <option> smelly.rb
218
208
  Then the exit status indicates smells
219
209
  And it reports:
220
210
  """
221
- smelly.rb -- 3 warnings:
222
- DuplicateMethodCall: Smelly#m calls @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
223
- DuplicateMethodCall: Smelly#m calls puts @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
224
- UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
211
+ smelly.rb -- 2 warnings:
212
+ UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
213
+ UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md]
225
214
  """
226
215
 
227
216
  Examples:
@@ -3,8 +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
- Given a directory called 'clean_files' containing some clean files
7
- When I run reek --format yaml clean_files
6
+ Given a directory called 'clean' containing two clean files
7
+ When I run reek --format yaml clean
8
8
  Then it succeeds
9
9
  And it reports this yaml:
10
10
  """
@@ -12,40 +12,28 @@ Feature: Report smells using simple YAML layout
12
12
  """
13
13
 
14
14
  Scenario: Indicate smells and print them as yaml when using files
15
- Given a smelly file called 'smelly.rb'
15
+ Given the smelly file 'smelly.rb'
16
16
  When I run reek --format yaml smelly.rb
17
17
  Then the exit status indicates smells
18
18
  And it reports this yaml:
19
19
  """
20
20
  ---
21
- - smell_type: DuplicateMethodCall
22
- source: smelly.rb
23
- context: Smelly#m
21
+ - context: Smelly#x
24
22
  lines:
25
23
  - 4
26
- - 5
27
- message: calls @foo.bar 2 times
28
- name: "@foo.bar"
29
- count: 2
30
- wiki_link: https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md
31
- - smell_type: DuplicateMethodCall
24
+ message: has the name 'x'
25
+ smell_type: UncommunicativeMethodName
32
26
  source: smelly.rb
33
- context: Smelly#m
27
+ name: x
28
+ wiki_link: https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md
29
+ - context: Smelly#x
34
30
  lines:
35
- - 4
36
31
  - 5
37
- message: calls puts @foo.bar 2 times
38
- name: puts @foo.bar
39
- count: 2
40
- wiki_link: https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md
41
- - smell_type: UncommunicativeMethodName
32
+ message: has the variable name 'y'
33
+ smell_type: UncommunicativeVariableName
42
34
  source: smelly.rb
43
- context: Smelly#m
44
- lines:
45
- - 3
46
- message: has the name 'm'
47
- name: m
48
- wiki_link: https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md
35
+ name: y
36
+ wiki_link: https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md
49
37
  """
50
38
 
51
39
  Scenario: Indicate smells and print them as yaml when using STDIN
@@ -60,6 +48,5 @@ Feature: Report smells using simple YAML layout
60
48
  lines:
61
49
  - 1
62
50
  message: has no descriptive comment
63
- name: Turn
64
51
  wiki_link: https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md
65
52
  """
@@ -4,9 +4,9 @@ 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
- Given the "inline.rb" sample file exists
8
- And the "optparse.rb" sample file exists
9
- And the "redcloth.rb" sample file exists
7
+ Given the smelly file 'inline.rb'
8
+ And the smelly file 'optparse.rb'
9
+ And the smelly file 'redcloth.rb'
10
10
  When I run reek --no-line-numbers inline.rb optparse.rb redcloth.rb
11
11
  Then the exit status indicates smells
12
12
  And it reports:
@@ -1,181 +1,47 @@
1
- Given(/^the smelly file 'smelly.rb'$/) do
2
- contents = <<-EOS.strip_heredoc
3
- class Smelly
4
- def x; end
5
- end
6
- EOS
7
- write_file('smelly.rb', contents)
1
+ require_relative '../../samples/paths'
2
+
3
+ Given(/^the smelly file '(.+)'$/) do |filename|
4
+ write_file(filename, SAMPLES_PATH.join(filename).read)
8
5
  end
9
6
 
10
7
  Given(/^the clean file 'clean.rb'$/) do
11
- contents = <<-EOS.strip_heredoc
12
- # Explanatory comment
13
- class Clean
14
- def foo; end
15
- end
16
- EOS
17
- write_file('clean.rb', contents)
8
+ write_file('clean.rb', CLEAN_FILE.read)
18
9
  end
19
10
 
20
- Given(/^the smelly file 'demo.rb' from the example in the README$/) do
21
- contents = <<-EOS.strip_heredoc
22
- class Dirty
23
- # This method smells of :reek:NestedIterators but ignores them
24
- def awful(x, y, offset = 0, log = false)
25
- puts @screen.title
26
- @screen = widgets.map {|w| w.each {|key| key += 3 * x}}
27
- puts @screen.contents
28
- end
29
- end
30
- EOS
31
- write_file('demo.rb', contents)
32
- end
11
+ Given(/^a directory called 'clean' containing two clean files$/) do
12
+ contents = CLEAN_FILE.read
33
13
 
34
- Given(/^a smelly file with inline masking called 'inline.rb'$/) do
35
- write_file 'inline.rb', <<-EOS.strip_heredoc
36
- # smells of :reek:NestedIterators but ignores them
37
- class Dirty
38
- def a
39
- puts @s.title
40
- @s = foo.map {|x| x.each {|key| key += 3}}
41
- puts @s.title
42
- end
43
- end
44
- EOS
45
- end
46
-
47
- Given(/^the "(.*?)" sample file exists$/) do |file_name|
48
- full_path = Pathname.new("#{__dir__}/../../spec/samples/#{file_name}")
49
- cd('.') { FileUtils.cp full_path, file_name }
50
- end
51
-
52
- Given(/^a directory called 'clean_files' containing some clean files$/) do
53
- contents = <<-EOS.strip_heredoc
54
- # clean class for testing purposes
55
- class Clean
56
- def assign
57
- puts @sub.title
58
- @sub.map {|para| para.name }
59
- end
60
- end
61
- EOS
62
- write_file 'clean_files/clean_one.rb', contents
63
- write_file 'clean_files/clean_two.rb', contents
64
- write_file 'clean_files/clean_three.rb', contents
14
+ write_file('clean/clean_one.rb', contents)
15
+ write_file('clean/clean_two.rb', contents)
65
16
  end
66
17
 
67
18
  Given(/^a directory called 'smelly' containing two smelly files$/) do
68
- write_file('smelly/dirty_one.rb', <<-EOS.strip_heredoc)
69
- class Dirty
70
- def a; end
71
- end
72
- EOS
73
- write_file('smelly/dirty_two.rb', <<-EOS.strip_heredoc)
74
- class Dirty
75
- def a; end
76
- def b; end
77
- end
78
- EOS
79
- end
80
-
81
- Given(/^a smelly file called 'smelly.rb'( in a subdirectory)?$/) do |in_subdir|
82
- file_name = in_subdir ? 'subdir/smelly.rb' : 'smelly.rb'
83
- write_file file_name, <<-EOS.strip_heredoc
84
- # smelly class for testing purposes
85
- class Smelly
86
- def m
87
- puts @foo.bar
88
- puts @foo.bar
89
- end
90
- end
91
- EOS
92
- end
19
+ contents = SMELLY_FILE.read
93
20
 
94
- Given(/^an empty configuration file called 'empty.reek'$/) do
95
- write_file('empty.reek', '')
21
+ write_file('smelly/dirty_one.rb', contents)
22
+ write_file('smelly/dirty_two.rb', contents)
96
23
  end
97
24
 
98
- Given(/^a corrupt configuration file called 'corrupt.reek'$/) do
99
- write_file('corrupt.reek', 'This is not a configuration file')
100
- end
101
-
102
- Given(/^a masking configuration file called 'config.reek'$/) do
103
- write_file('config.reek', <<-EOS.strip_heredoc)
104
- ---
105
- DuplicateMethodCall:
106
- enabled: false
107
- UncommunicativeMethodName:
108
- enabled: false
109
- EOS
110
- end
25
+ Given(/^the smelly file '(.+)' in a subdirectory$/) do |filename|
26
+ contents = SAMPLES_PATH.join(filename).read
111
27
 
112
- Given(/^a configuration file masking some duplication smells called 'config.reek'$/) do
113
- write_file('config.reek', <<-EOS.strip_heredoc)
114
- ---
115
- DuplicateMethodCall:
116
- allow_calls:
117
- - puts @foo.bar
118
- EOS
28
+ write_file("subdir/#{filename}", contents)
119
29
  end
120
30
 
121
- Given(/^a configuration file disabling DuplicateMethodCall called 'config.reek'$/) do
122
- write_file('config.reek', <<-EOS.strip_heredoc)
123
- ---
124
- DuplicateMethodCall:
125
- enabled: false
126
- EOS
31
+ Given(/^a configuration file '(.+)'$/) do |filename|
32
+ write_file(filename, CONFIG_PATH.join(filename).read)
127
33
  end
128
34
 
129
- When(/^I run "reek (.*?)" in the subdirectory$/) do |args|
35
+ When(/^I run "reek (.*?)" in a subdirectory$/) do |args|
130
36
  cd 'subdir'
131
- reek(args)
132
- end
133
37
 
134
- Given(/^a masking configuration file in the HOME directory$/) do
135
- set_environment_variable 'HOME', Pathname.new("#{expand_path('.')}/home")
136
- write_file('home/config.reek', <<-EOS.strip_heredoc)
137
- ---
138
- DuplicateMethodCall:
139
- enabled: false
140
- UncommunicativeMethodName:
141
- enabled: false
142
- EOS
143
- end
144
-
145
- Given(/^an enabling configuration file in the subdirectory$/) do
146
- write_file('subdir/config.reek', <<-EOS.strip_heredoc)
147
- ---
148
- IrresponsibleModule:
149
- enabled: true
150
- UncommunicativeModuleName:
151
- enabled: true
152
- UncommunicativeMethodName:
153
- enabled: true
154
- EOS
38
+ reek(args)
155
39
  end
156
40
 
157
- Given(/^a smelly file called 'smelly.rb' with private, protected and public UtilityFunction methods$/) do
158
- write_file 'smelly.rb', <<-EOS.strip_heredoc
159
- # smelly class for testing purposes
160
- class Klass
161
- def public_method(arg) arg.to_s; end
162
- protected
163
- def protected_method(arg) arg.to_s; end
164
- private
165
- def private_method(arg) arg.to_s; end
166
- end
167
- EOS
168
- end
41
+ Given(/^a configuration file '(.+)' in a subdirectory$/) do |filename|
42
+ contents = CONFIG_PATH.join(filename).read
169
43
 
170
- Given(/^a configuration file disabling UtilityFunction for non-public methods called 'config.reek'$/) do
171
- write_file('config.reek', <<-EOS.strip_heredoc)
172
- ---
173
- UtilityFunction:
174
- public_methods_only: true
175
- # Not necessary for the feature per se but for removing distracting output.
176
- UnusedPrivateMethod:
177
- enabled: false
178
- EOS
44
+ write_file("subdir/#{filename}", contents)
179
45
  end
180
46
 
181
47
  Then(/^it does not report private or protected methods$/) do