reek 3.8.3 → 3.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/CHANGELOG.md +5 -0
  4. data/Gemfile +16 -6
  5. data/README.md +1 -0
  6. data/features/command_line_interface/smells_count.feature +1 -1
  7. data/features/command_line_interface/stdin.feature +1 -1
  8. data/features/configuration_loading.feature +2 -2
  9. data/features/programmatic_access.feature +2 -2
  10. data/features/rake_task/rake_task.feature +4 -4
  11. data/features/reports/json.feature +2 -2
  12. data/features/reports/reports.feature +6 -6
  13. data/features/reports/yaml.feature +2 -2
  14. data/features/samples.feature +19 -19
  15. data/features/step_definitions/sample_file_steps.rb +1 -1
  16. data/lib/reek/ast/node.rb +12 -1
  17. data/lib/reek/ast/sexp_extensions.rb +1 -0
  18. data/lib/reek/ast/sexp_extensions/constant.rb +9 -0
  19. data/lib/reek/ast/sexp_extensions/methods.rb +1 -20
  20. data/lib/reek/ast/sexp_extensions/module.rb +2 -2
  21. data/lib/reek/ast/sexp_extensions/self.rb +12 -0
  22. data/lib/reek/ast/sexp_extensions/send.rb +4 -9
  23. data/lib/reek/ast/sexp_extensions/super.rb +1 -1
  24. data/lib/reek/ast/sexp_extensions/variables.rb +5 -0
  25. data/lib/reek/context/attribute_context.rb +12 -0
  26. data/lib/reek/context/code_context.rb +28 -26
  27. data/lib/reek/context/ghost_context.rb +54 -0
  28. data/lib/reek/context/method_context.rb +28 -1
  29. data/lib/reek/context/module_context.rb +55 -1
  30. data/lib/reek/context/root_context.rb +8 -0
  31. data/lib/reek/context/singleton_attribute_context.rb +15 -0
  32. data/lib/reek/context/singleton_method_context.rb +20 -0
  33. data/lib/reek/context/visibility_tracker.rb +25 -16
  34. data/lib/reek/context_builder.rb +61 -31
  35. data/lib/reek/examiner.rb +0 -6
  36. data/lib/reek/smells/control_parameter.rb +1 -1
  37. data/lib/reek/smells/nested_iterators.rb +1 -1
  38. data/lib/reek/smells/nil_check.rb +2 -2
  39. data/lib/reek/smells/utility_function.rb +1 -2
  40. data/lib/reek/version.rb +1 -1
  41. data/reek.gemspec +1 -12
  42. data/spec/reek/ast/node_spec.rb +51 -3
  43. data/spec/reek/ast/sexp_extensions_spec.rb +16 -3
  44. data/spec/reek/context/code_context_spec.rb +12 -31
  45. data/spec/reek/context/ghost_context_spec.rb +60 -0
  46. data/spec/reek/context/module_context_spec.rb +22 -2
  47. data/spec/reek/context_builder_spec.rb +225 -2
  48. data/spec/reek/examiner_spec.rb +1 -1
  49. data/spec/reek/smells/attribute_spec.rb +35 -0
  50. data/spec/reek/smells/duplicate_method_call_spec.rb +1 -1
  51. data/spec/reek/tree_dresser_spec.rb +0 -1
  52. data/spec/samples/checkstyle.xml +2 -2
  53. metadata +8 -152
  54. data/lib/reek/ast/sexp_formatter.rb +0 -31
  55. data/spec/reek/ast/sexp_formatter_spec.rb +0 -35
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bee0377800c5a5a58c7a27bf63f92cc56b195327
4
- data.tar.gz: d824f0e71d925b69c3c2d23d95b4a4c68f4d5a2c
3
+ metadata.gz: 06a12fafe3940db75ef71b4c2a1b94d690156bf5
4
+ data.tar.gz: e38b40afe0d1be94dc9f449274d57568c42018d7
5
5
  SHA512:
6
- metadata.gz: fdd5cd74638b200650968a537305b71aca06e986643a30a06f703652f59e0b663510425dd4aaf5ebc292fd315ecf85793dca4bfe3aff14873ddfddb15602103c
7
- data.tar.gz: 9bea39cdfbaf775cf748852b69bc009f8b1adfa7b6cfa1f5763810c3236c1ed5f5336691e81e34d88bc66ba2c3208605d291104531711beb4778614d91d2af55
6
+ metadata.gz: 01fadfe2c811ab7762ccb7994767dc6e4e4c78b7e425a089c551c609fd289fd542fdde5ab2fe3c891af243b240d74148618efb5c84c10dc8ff83c287a6b87224
7
+ data.tar.gz: 98d4b2aa2a433892b4b65943d8a3f98ba9c5b0645acc1eed971225d1543fc2ab3d318fd60cf4a321348efa9339dbcd572c29e87e6eb49dcda96eb61e8b9579b4
@@ -1,7 +1,7 @@
1
1
  sudo: false
2
2
  cache: bundler
3
3
  language: ruby
4
- bundler_args: --without local_development
4
+ bundler_args: --without debugging
5
5
  script:
6
6
  - bundle exec rake
7
7
  - bundle exec ataru check
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 3.9.0 (2016-01-22)
6
+
7
+ * (chastell) Bump Parser dependency to support Ruby 2.3
8
+ * (mvz) Remove the `unparser` gem as dependency
9
+
5
10
  ## 3.8.3 (2016-01-15)
6
11
 
7
12
  * (avdgaag) Accept FileList as Rake task source file
data/Gemfile CHANGED
@@ -1,16 +1,26 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # The gem's dependencies are specified in the gemspec
4
3
  gemspec
5
4
 
6
- group :local_development do
7
- gem 'pry'
8
- gem 'yard', '~> 0.8.7'
5
+ group :development do
6
+ gem 'aruba', '~> 0.10.0'
7
+ gem 'ataru', '~> 0.2.0'
8
+ gem 'cucumber', '~> 2.0'
9
+ gem 'factory_girl', '~> 4.0'
10
+ gem 'rake', '~> 10.0'
11
+ gem 'rspec', '~> 3.0'
12
+ gem 'rubocop', '~> 0.34.0'
13
+ gem 'yard', '~> 0.8.7'
9
14
 
15
+ platforms :mri do
16
+ gem 'redcarpet', '~> 3.3.1'
17
+ end
18
+ end
19
+
20
+ group :debugging do
21
+ gem 'pry'
10
22
  platforms :mri do
11
23
  gem 'pry-byebug'
12
24
  gem 'pry-stack_explorer'
13
-
14
- gem 'redcarpet', '~> 3.3.1'
15
25
  end
16
26
  end
data/README.md CHANGED
@@ -403,6 +403,7 @@ Be careful though, Reek does not merge your configuration entries, so if you alr
403
403
  * [Vim plugin](https://github.com/rainerborene/vim-reek)
404
404
  * [TextMate Bundle](https://github.com/peeyush1234/reek.tmbundle)
405
405
  * [Atom plugin](https://atom.io/packages/linter-reek)
406
+ * [SublimeLinter plugin](https://packagecontrol.io/packages/SublimeLinter-contrib-reek)
406
407
 
407
408
  ### Projects that use or support us
408
409
 
@@ -10,7 +10,7 @@ Feature: Reports total number of code smells
10
10
  """
11
11
  smelly.rb -- 3 warnings:
12
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]
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
14
  [3]:UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
15
15
  """
16
16
 
@@ -33,7 +33,7 @@ Feature: Reek reads from $stdin when no files are given
33
33
  """
34
34
 
35
35
  Scenario: syntax error causes the source to be ignored
36
- When I pass "def incomplete" to reek
36
+ When I pass "= invalid syntax =" to reek
37
37
  Then it reports a parsing error
38
38
  Then it succeeds
39
39
  And it reports nothing
@@ -18,7 +18,7 @@ Feature: Offer different ways how to load configuration
18
18
  """
19
19
  smelly.rb -- 3 warnings:
20
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]
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
22
  [3]:UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
23
23
  """
24
24
 
@@ -46,6 +46,6 @@ Feature: Offer different ways how to load configuration
46
46
  """
47
47
  smelly.rb -- 3 warnings:
48
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]
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
50
  [3]:UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
51
51
  """
@@ -18,7 +18,7 @@ Feature: Using Reek programmatically
18
18
  And it reports:
19
19
  """
20
20
  calls @foo.bar 2 times
21
- calls puts(@foo.bar) 2 times
21
+ calls puts @foo.bar 2 times
22
22
  has the name 'm'
23
23
  """
24
24
 
@@ -38,6 +38,6 @@ Feature: Using Reek programmatically
38
38
  """
39
39
  smelly.rb -- 3 warnings:
40
40
  DuplicateMethodCall: Smelly#m calls @foo.bar 2 times
41
- DuplicateMethodCall: Smelly#m calls puts(@foo.bar) 2 times
41
+ DuplicateMethodCall: Smelly#m calls puts @foo.bar 2 times
42
42
  UncommunicativeMethodName: Smelly#m has the name 'm'
43
43
  """
@@ -16,7 +16,7 @@ Feature: Reek can be driven through its Task
16
16
  """
17
17
  smelly.rb -- 3 warnings:
18
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]
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
20
  [3]:UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
21
21
  """
22
22
 
@@ -34,7 +34,7 @@ Feature: Reek can be driven through its Task
34
34
  """
35
35
  smelly.rb -- 3 warnings:
36
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]
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
38
  [3]:UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
39
39
  """
40
40
 
@@ -52,7 +52,7 @@ Feature: Reek can be driven through its Task
52
52
  """
53
53
  smelly.rb -- 3 warnings:
54
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]
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
56
  [3]:UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
57
57
  """
58
58
 
@@ -84,7 +84,7 @@ Feature: Reek can be driven through its Task
84
84
  """
85
85
  smelly.rb -- 3 warnings:
86
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]
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
88
  [3]:UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
89
89
  """
90
90
 
@@ -35,8 +35,8 @@ Feature: Report smells using simple JSON layout
35
35
  "source": "smelly.rb",
36
36
  "context": "Smelly#m",
37
37
  "lines": [ 4, 5 ],
38
- "message": "calls puts(@foo.bar) 2 times",
39
- "name": "puts(@foo.bar)",
38
+ "message": "calls puts @foo.bar 2 times",
39
+ "name": "puts @foo.bar",
40
40
  "wiki_link": "https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md",
41
41
  "count": 2
42
42
  },
@@ -115,7 +115,7 @@ Feature: Correctly formatted reports
115
115
  """
116
116
  smelly.rb -- 3 warnings:
117
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]
118
+ DuplicateMethodCall: Smelly#m calls puts @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
119
119
  UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
120
120
  """
121
121
 
@@ -133,7 +133,7 @@ Feature: Correctly formatted reports
133
133
  """
134
134
  smelly.rb -- 3 warnings:
135
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]
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
137
  [3]:UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
138
138
  """
139
139
 
@@ -151,7 +151,7 @@ Feature: Correctly formatted reports
151
151
  """
152
152
  smelly.rb -- 3 warnings:
153
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]
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
155
  smelly.rb:3: UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
156
156
  """
157
157
 
@@ -191,7 +191,7 @@ Feature: Correctly formatted reports
191
191
  """
192
192
  smelly.rb -- 3 warnings:
193
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]
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
195
  [3]:UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
196
196
  """
197
197
 
@@ -208,7 +208,7 @@ Feature: Correctly formatted reports
208
208
  """
209
209
  smelly.rb -- 3 warnings:
210
210
  [4, 5]:DuplicateMethodCall: Smelly#m calls @foo.bar 2 times
211
- [4, 5]:DuplicateMethodCall: Smelly#m calls puts(@foo.bar) 2 times
211
+ [4, 5]:DuplicateMethodCall: Smelly#m calls puts @foo.bar 2 times
212
212
  [3]:UncommunicativeMethodName: Smelly#m has the name 'm'
213
213
  """
214
214
 
@@ -220,7 +220,7 @@ Feature: Correctly formatted reports
220
220
  """
221
221
  smelly.rb -- 3 warnings:
222
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]
223
+ DuplicateMethodCall: Smelly#m calls puts @foo.bar 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
224
224
  UncommunicativeMethodName: Smelly#m has the name 'm' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md]
225
225
  """
226
226
 
@@ -36,8 +36,8 @@ Feature: Report smells using simple YAML layout
36
36
  lines:
37
37
  - 4
38
38
  - 5
39
- message: calls puts(@foo.bar) 2 times
40
- name: puts(@foo.bar)
39
+ message: calls puts @foo.bar 2 times
40
+ name: puts @foo.bar
41
41
  count: 2
42
42
  wiki_link: https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md
43
43
  - smell_category: UncommunicativeName
@@ -21,14 +21,14 @@ Feature: Basic smell detection
21
21
  DuplicateMethodCall: Inline#self.rootdir calls env.nil? 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
22
22
  DuplicateMethodCall: Inline::C#build calls $? != 0 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
23
23
  DuplicateMethodCall: Inline::C#build calls Inline.directory 5 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
24
+ DuplicateMethodCall: Inline::C#build calls io.puts "#endif" 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
25
+ DuplicateMethodCall: Inline::C#build calls io.puts "#ifdef __cplusplus" 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
24
26
  DuplicateMethodCall: Inline::C#build calls io.puts 6 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
25
- DuplicateMethodCall: Inline::C#build calls io.puts("#endif") 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
26
- DuplicateMethodCall: Inline::C#build calls io.puts("#ifdef __cplusplus") 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
27
- DuplicateMethodCall: Inline::C#build calls warn("Output:\n#{result}") 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
28
- DuplicateMethodCall: Inline::C#crap_for_windoze calls Config::CONFIG["libdir"] 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
29
- DuplicateMethodCall: Inline::C#generate calls result.sub!(/\A\n/, "") 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
30
- DuplicateMethodCall: Inline::C#generate calls signature["args"] 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
31
- DuplicateMethodCall: Inline::C#generate calls signature["args"].map 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
27
+ DuplicateMethodCall: Inline::C#build calls warn "Output:\n#{result}" 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
28
+ DuplicateMethodCall: Inline::C#crap_for_windoze calls Config::CONFIG['libdir'] 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
29
+ DuplicateMethodCall: Inline::C#generate calls result.sub!(/\A\n/, '') 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
30
+ DuplicateMethodCall: Inline::C#generate calls signature['args'] 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
31
+ DuplicateMethodCall: Inline::C#generate calls signature['args'].map 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
32
32
  DuplicateMethodCall: Inline::C#initialize calls stack.empty? 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
33
33
  DuplicateMethodCall: Module#inline calls Inline.const_get(lang) 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
34
34
  DuplicateMethodCall: Module#inline calls options[:testing] 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
@@ -40,7 +40,7 @@ Feature: Basic smell detection
40
40
  NilCheck: Inline#self.rootdir performs a nil-check [https://github.com/troessner/reek/blob/master/docs/Nil-Check.md]
41
41
  RepeatedConditional: Inline::C tests $DEBUG at least 7 times [https://github.com/troessner/reek/blob/master/docs/Repeated-Conditional.md]
42
42
  RepeatedConditional: Inline::C tests $TESTING at least 4 times [https://github.com/troessner/reek/blob/master/docs/Repeated-Conditional.md]
43
- RepeatedConditional: Inline::C tests @@type_map.has_key?(type) at least 3 times [https://github.com/troessner/reek/blob/master/docs/Repeated-Conditional.md]
43
+ RepeatedConditional: Inline::C tests @@type_map.has_key? type at least 3 times [https://github.com/troessner/reek/blob/master/docs/Repeated-Conditional.md]
44
44
  TooManyInstanceVariables: Inline::C has at least 13 instance variables [https://github.com/troessner/reek/blob/master/docs/Too-Many-Instance-Variables.md]
45
45
  TooManyMethods: Inline::C has at least 25 methods [https://github.com/troessner/reek/blob/master/docs/Too-Many-Methods.md]
46
46
  TooManyStatements: File#self.write_with_backup has approx 6 statements [https://github.com/troessner/reek/blob/master/docs/Too-Many-Statements.md]
@@ -77,8 +77,8 @@ Feature: Basic smell detection
77
77
  DuplicateMethodCall: OptionParser#getopts calls result[opt] = false 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
78
78
  DuplicateMethodCall: OptionParser#make_switch calls default_style.guess(arg = a) 4 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
79
79
  DuplicateMethodCall: OptionParser#make_switch calls long << (o = q.downcase) 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
80
- DuplicateMethodCall: OptionParser#make_switch calls notwice(NilClass, klass, "type") 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
81
- DuplicateMethodCall: OptionParser#make_switch calls notwice(if a ... end, klass, "type") 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
80
+ DuplicateMethodCall: OptionParser#make_switch calls notwice(NilClass, klass, 'type') 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
81
+ DuplicateMethodCall: OptionParser#make_switch calls notwice(a ? Object : TrueClass, klass, 'type') 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
82
82
  DuplicateMethodCall: OptionParser#make_switch calls pattern.method(:convert) 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
83
83
  DuplicateMethodCall: OptionParser#make_switch calls pattern.method(:convert).to_proc 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
84
84
  DuplicateMethodCall: OptionParser#make_switch calls pattern.respond_to?(:convert) 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
@@ -90,7 +90,7 @@ Feature: Basic smell detection
90
90
  DuplicateMethodCall: OptionParser#parse calls argv[0] 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
91
91
  DuplicateMethodCall: OptionParser#parse_in_order calls $!.set_option(arg, true) 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
92
92
  DuplicateMethodCall: OptionParser#parse_in_order calls cb.call(val) 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
93
- DuplicateMethodCall: OptionParser#parse_in_order calls raise($!.set_option(arg, true)) 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
93
+ DuplicateMethodCall: OptionParser#parse_in_order calls raise $!.set_option(arg, true) 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
94
94
  DuplicateMethodCall: OptionParser#parse_in_order calls raise(*exc) 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
95
95
  DuplicateMethodCall: OptionParser#parse_in_order calls setter.call(sw.switch_name, val) 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
96
96
  DuplicateMethodCall: OptionParser#parse_in_order calls sw.block 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
@@ -101,11 +101,11 @@ Feature: Basic smell detection
101
101
  DuplicateMethodCall: OptionParser::Switch#parse_arg calls s.length 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
102
102
  DuplicateMethodCall: OptionParser::Switch#summarize calls indent + l 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
103
103
  DuplicateMethodCall: OptionParser::Switch#summarize calls left.collect 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
104
- DuplicateMethodCall: OptionParser::Switch#summarize calls left.collect do |s| ... end 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
105
- DuplicateMethodCall: OptionParser::Switch#summarize calls left.collect do |s| ... end.max 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
106
- DuplicateMethodCall: OptionParser::Switch#summarize calls left.collect do |s| ... end.max.to_i 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
104
+ DuplicateMethodCall: OptionParser::Switch#summarize calls left.collect {|s| s.length} 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
105
+ DuplicateMethodCall: OptionParser::Switch#summarize calls left.collect {|s| s.length}.max 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
106
+ DuplicateMethodCall: OptionParser::Switch#summarize calls left.collect {|s| s.length}.max.to_i 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
107
107
  DuplicateMethodCall: OptionParser::Switch#summarize calls left.shift 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
108
- DuplicateMethodCall: OptionParser::Switch#summarize calls left[(-1)] 3 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
108
+ DuplicateMethodCall: OptionParser::Switch#summarize calls left[-1] 3 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
109
109
  DuplicateMethodCall: OptionParser::Switch#summarize calls s.length 3 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
110
110
  FeatureEnvy: OptionParser#order refers to argv more than self (maybe move it to another class?) [https://github.com/troessner/reek/blob/master/docs/Feature-Envy.md]
111
111
  FeatureEnvy: OptionParser#parse refers to argv more than self (maybe move it to another class?) [https://github.com/troessner/reek/blob/master/docs/Feature-Envy.md]
@@ -124,8 +124,8 @@ Feature: Basic smell detection
124
124
  NestedIterators: OptionParser#make_switch contains iterators nested 2 deep [https://github.com/troessner/reek/blob/master/docs/Nested-Iterators.md]
125
125
  NilCheck: OptionParser#make_switch performs a nil-check [https://github.com/troessner/reek/blob/master/docs/Nil-Check.md]
126
126
  NilCheck: OptionParser#self.inc performs a nil-check [https://github.com/troessner/reek/blob/master/docs/Nil-Check.md]
127
- RepeatedConditional: OptionParser tests (argv.size == 1) && (Array === argv[0]) at least 3 times [https://github.com/troessner/reek/blob/master/docs/Repeated-Conditional.md]
128
127
  RepeatedConditional: OptionParser tests a at least 7 times [https://github.com/troessner/reek/blob/master/docs/Repeated-Conditional.md]
128
+ RepeatedConditional: OptionParser tests argv.size == 1 and Array === argv[0] at least 3 times [https://github.com/troessner/reek/blob/master/docs/Repeated-Conditional.md]
129
129
  RepeatedConditional: OptionParser tests default_pattern at least 7 times [https://github.com/troessner/reek/blob/master/docs/Repeated-Conditional.md]
130
130
  RepeatedConditional: OptionParser tests not_style at least 3 times [https://github.com/troessner/reek/blob/master/docs/Repeated-Conditional.md]
131
131
  RepeatedConditional: OptionParser tests s at least 7 times [https://github.com/troessner/reek/blob/master/docs/Repeated-Conditional.md]
@@ -198,14 +198,14 @@ Feature: Basic smell detection
198
198
  DuplicateMethodCall: RedCloth#block_textile_lists calls tl.length 3 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
199
199
  DuplicateMethodCall: RedCloth#clean_html calls tags[tag] 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
200
200
  DuplicateMethodCall: RedCloth#pba calls $1.length 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
201
- DuplicateMethodCall: RedCloth#rip_offtags calls (codepre - used_offtags.length) > 0 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
202
201
  DuplicateMethodCall: RedCloth#rip_offtags calls @pre_list.last 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
203
202
  DuplicateMethodCall: RedCloth#rip_offtags calls @pre_list.last << line 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
204
203
  DuplicateMethodCall: RedCloth#rip_offtags calls codepre - used_offtags.length 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
204
+ DuplicateMethodCall: RedCloth#rip_offtags calls codepre - used_offtags.length > 0 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
205
205
  DuplicateMethodCall: RedCloth#rip_offtags calls codepre.zero? 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
206
- DuplicateMethodCall: RedCloth#rip_offtags calls htmlesc(line, :NoQuotes) 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
206
+ DuplicateMethodCall: RedCloth#rip_offtags calls htmlesc( line, :NoQuotes ) 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
207
207
  DuplicateMethodCall: RedCloth#rip_offtags calls used_offtags.length 2 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
208
- DuplicateMethodCall: RedCloth#rip_offtags calls used_offtags["notextile"] 3 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
208
+ DuplicateMethodCall: RedCloth#rip_offtags calls used_offtags['notextile'] 3 times [https://github.com/troessner/reek/blob/master/docs/Duplicate-Method-Call.md]
209
209
  FeatureEnvy: RedCloth#block_markdown_atx refers to text more than self (maybe move it to another class?) [https://github.com/troessner/reek/blob/master/docs/Feature-Envy.md]
210
210
  FeatureEnvy: RedCloth#block_markdown_setext refers to text more than self (maybe move it to another class?) [https://github.com/troessner/reek/blob/master/docs/Feature-Envy.md]
211
211
  FeatureEnvy: RedCloth#block_textile_lists refers to depth more than self (maybe move it to another class?) [https://github.com/troessner/reek/blob/master/docs/Feature-Envy.md]
@@ -114,7 +114,7 @@ Given(/^a configuration file masking some duplication smells called 'config.reek
114
114
  ---
115
115
  DuplicateMethodCall:
116
116
  allow_calls:
117
- - puts\\(@foo.bar\\)
117
+ - puts @foo.bar
118
118
  EOS
119
119
  end
120
120
 
@@ -87,8 +87,19 @@ module Reek
87
87
  false
88
88
  end
89
89
 
90
+ # :reek:DuplicateMethodCall { max_calls: 2 } is ok for lines.first
91
+ # :reek:FeatureEnvy
90
92
  def format_to_ruby
91
- SexpFormatter.format(self)
93
+ if location
94
+ lines = location.expression.source.split("\n").map(&:strip)
95
+ case lines.length
96
+ when 1 then lines.first
97
+ when 2 then lines.join('; ')
98
+ else [lines.first, lines.last].join(' ... ')
99
+ end
100
+ else
101
+ to_s
102
+ end
92
103
  end
93
104
 
94
105
  protected
@@ -11,6 +11,7 @@ require_relative 'sexp_extensions/logical_operators'
11
11
  require_relative 'sexp_extensions/methods'
12
12
  require_relative 'sexp_extensions/module'
13
13
  require_relative 'sexp_extensions/nested_assignables'
14
+ require_relative 'sexp_extensions/self'
14
15
  require_relative 'sexp_extensions/send'
15
16
  require_relative 'sexp_extensions/super'
16
17
  require_relative 'sexp_extensions/symbols'
@@ -3,6 +3,15 @@ module Reek
3
3
  module SexpExtensions
4
4
  # Utility methods for :const nodes.
5
5
  module ConstNode
6
+ def name
7
+ namespace = children.first
8
+ if namespace
9
+ "#{namespace.format_to_ruby}::#{simple_name}"
10
+ else
11
+ simple_name.to_s
12
+ end
13
+ end
14
+
6
15
  def simple_name
7
16
  children.last
8
17
  end
@@ -36,28 +36,9 @@ module Reek
36
36
  end
37
37
  end
38
38
 
39
- # Checking if a method is a singleton method.
40
- module SingletonMethod
41
- def singleton_method?
42
- singleton_method_via_class_self_notation?
43
- end
44
-
45
- # Ruby allows us to make a method a singleton_method using the
46
- # class << self syntax.
47
- #
48
- # To check for this we check if the parent node is of type :sclass.
49
- #
50
- # @return [Boolean]
51
- def singleton_method_via_class_self_notation?
52
- return unless parent
53
- parent.type == :sclass
54
- end
55
- end
56
-
57
39
  # Utility methods for :def nodes.
58
40
  module DefNode
59
41
  include MethodNodeBase
60
- include SingletonMethod
61
42
 
62
43
  def name
63
44
  children.first
@@ -102,7 +83,7 @@ module Reek
102
83
 
103
84
  def full_name(outer)
104
85
  prefix = outer == '' ? '' : "#{outer}#"
105
- "#{prefix}#{SexpFormatter.format(receiver)}.#{name}"
86
+ "#{prefix}#{receiver.name}.#{name}"
106
87
  end
107
88
 
108
89
  def depends_on_instance?
@@ -32,7 +32,7 @@ module Reek
32
32
  end
33
33
 
34
34
  def name
35
- SexpFormatter.format(children.first)
35
+ children.first.format_to_ruby
36
36
  end
37
37
  end
38
38
 
@@ -63,7 +63,7 @@ module Reek
63
63
  end
64
64
 
65
65
  def name
66
- SexpFormatter.format(children[1])
66
+ children[1].to_s
67
67
  end
68
68
 
69
69
  # there are two valid forms of the casgn sexp