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
@@ -47,7 +47,7 @@ RSpec.describe Reek::Smells::DuplicateMethodCall do
47
47
 
48
48
  it 'reports call parameters' do
49
49
  src = 'def double_thing() @other.thing(2,3) + @other.thing(2,3) end'
50
- expect(src).to reek_of(:DuplicateMethodCall, name: '@other.thing(2, 3)')
50
+ expect(src).to reek_of(:DuplicateMethodCall, name: '@other.thing(2,3)')
51
51
  end
52
52
 
53
53
  it 'should report nested calls' do
@@ -34,7 +34,6 @@ RSpec.describe Reek::TreeDresser do
34
34
 
35
35
  it 'dresses `def` nodes properly' do
36
36
  expect(def_node).to be_a Reek::AST::SexpExtensions::DefNode
37
- expect(def_node).to be_a Reek::AST::SexpExtensions::SingletonMethod
38
37
  expect(def_node).to be_a Reek::AST::SexpExtensions::MethodNodeBase
39
38
  end
40
39
 
@@ -3,8 +3,8 @@
3
3
  <file name='spec/samples/two_smelly_files/dirty_one.rb'>
4
4
  <error column='0' line='4' message='calls @s.title 2 times' severity='warning' source='DuplicateMethodCall'/>
5
5
  <error column='0' line='6' message='calls @s.title 2 times' severity='warning' source='DuplicateMethodCall'/>
6
- <error column='0' line='4' message='calls puts(@s.title) 2 times' severity='warning' source='DuplicateMethodCall'/>
7
- <error column='0' line='6' message='calls puts(@s.title) 2 times' severity='warning' source='DuplicateMethodCall'/>
6
+ <error column='0' line='4' message='calls puts @s.title 2 times' severity='warning' source='DuplicateMethodCall'/>
7
+ <error column='0' line='6' message='calls puts @s.title 2 times' severity='warning' source='DuplicateMethodCall'/>
8
8
  <error column='0' line='5' message='contains iterators nested 2 deep' severity='warning' source='NestedIterators'/>
9
9
  <error column='0' line='3' message='has the name &apos;a&apos;' severity='warning' source='UncommunicativeMethodName'/>
10
10
  <error column='0' line='5' message='has the variable name &apos;@s&apos;' severity='warning' source='UncommunicativeVariableName'/>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reek
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.8.3
4
+ version: 3.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Rutherford
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-01-15 00:00:00.000000000 Z
14
+ date: 2016-01-22 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: codeclimate-engine-rb
@@ -33,20 +33,14 @@ dependencies:
33
33
  requirements:
34
34
  - - "~>"
35
35
  - !ruby/object:Gem::Version
36
- version: '2.2'
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: 2.2.2.5
36
+ version: '2.3'
40
37
  type: :runtime
41
38
  prerelease: false
42
39
  version_requirements: !ruby/object:Gem::Requirement
43
40
  requirements:
44
41
  - - "~>"
45
42
  - !ruby/object:Gem::Version
46
- version: '2.2'
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: 2.2.2.5
43
+ version: '2.3'
50
44
  - !ruby/object:Gem::Dependency
51
45
  name: private_attr
52
46
  requirement: !ruby/object:Gem::Requirement
@@ -75,146 +69,6 @@ dependencies:
75
69
  - - "~>"
76
70
  - !ruby/object:Gem::Version
77
71
  version: '2.0'
78
- - !ruby/object:Gem::Dependency
79
- name: unparser
80
- requirement: !ruby/object:Gem::Requirement
81
- requirements:
82
- - - "~>"
83
- - !ruby/object:Gem::Version
84
- version: 0.2.2
85
- type: :runtime
86
- prerelease: false
87
- version_requirements: !ruby/object:Gem::Requirement
88
- requirements:
89
- - - "~>"
90
- - !ruby/object:Gem::Version
91
- version: 0.2.2
92
- - !ruby/object:Gem::Dependency
93
- name: activesupport
94
- requirement: !ruby/object:Gem::Requirement
95
- requirements:
96
- - - "~>"
97
- - !ruby/object:Gem::Version
98
- version: '4.2'
99
- type: :development
100
- prerelease: false
101
- version_requirements: !ruby/object:Gem::Requirement
102
- requirements:
103
- - - "~>"
104
- - !ruby/object:Gem::Version
105
- version: '4.2'
106
- - !ruby/object:Gem::Dependency
107
- name: aruba
108
- requirement: !ruby/object:Gem::Requirement
109
- requirements:
110
- - - "~>"
111
- - !ruby/object:Gem::Version
112
- version: 0.10.0
113
- type: :development
114
- prerelease: false
115
- version_requirements: !ruby/object:Gem::Requirement
116
- requirements:
117
- - - "~>"
118
- - !ruby/object:Gem::Version
119
- version: 0.10.0
120
- - !ruby/object:Gem::Dependency
121
- name: ataru
122
- requirement: !ruby/object:Gem::Requirement
123
- requirements:
124
- - - "~>"
125
- - !ruby/object:Gem::Version
126
- version: 0.2.0
127
- type: :development
128
- prerelease: false
129
- version_requirements: !ruby/object:Gem::Requirement
130
- requirements:
131
- - - "~>"
132
- - !ruby/object:Gem::Version
133
- version: 0.2.0
134
- - !ruby/object:Gem::Dependency
135
- name: bundler
136
- requirement: !ruby/object:Gem::Requirement
137
- requirements:
138
- - - "~>"
139
- - !ruby/object:Gem::Version
140
- version: '1.1'
141
- type: :development
142
- prerelease: false
143
- version_requirements: !ruby/object:Gem::Requirement
144
- requirements:
145
- - - "~>"
146
- - !ruby/object:Gem::Version
147
- version: '1.1'
148
- - !ruby/object:Gem::Dependency
149
- name: cucumber
150
- requirement: !ruby/object:Gem::Requirement
151
- requirements:
152
- - - "~>"
153
- - !ruby/object:Gem::Version
154
- version: '2.0'
155
- type: :development
156
- prerelease: false
157
- version_requirements: !ruby/object:Gem::Requirement
158
- requirements:
159
- - - "~>"
160
- - !ruby/object:Gem::Version
161
- version: '2.0'
162
- - !ruby/object:Gem::Dependency
163
- name: factory_girl
164
- requirement: !ruby/object:Gem::Requirement
165
- requirements:
166
- - - "~>"
167
- - !ruby/object:Gem::Version
168
- version: '4.0'
169
- type: :development
170
- prerelease: false
171
- version_requirements: !ruby/object:Gem::Requirement
172
- requirements:
173
- - - "~>"
174
- - !ruby/object:Gem::Version
175
- version: '4.0'
176
- - !ruby/object:Gem::Dependency
177
- name: rake
178
- requirement: !ruby/object:Gem::Requirement
179
- requirements:
180
- - - "~>"
181
- - !ruby/object:Gem::Version
182
- version: '10.0'
183
- type: :development
184
- prerelease: false
185
- version_requirements: !ruby/object:Gem::Requirement
186
- requirements:
187
- - - "~>"
188
- - !ruby/object:Gem::Version
189
- version: '10.0'
190
- - !ruby/object:Gem::Dependency
191
- name: rspec
192
- requirement: !ruby/object:Gem::Requirement
193
- requirements:
194
- - - "~>"
195
- - !ruby/object:Gem::Version
196
- version: '3.0'
197
- type: :development
198
- prerelease: false
199
- version_requirements: !ruby/object:Gem::Requirement
200
- requirements:
201
- - - "~>"
202
- - !ruby/object:Gem::Version
203
- version: '3.0'
204
- - !ruby/object:Gem::Dependency
205
- name: rubocop
206
- requirement: !ruby/object:Gem::Requirement
207
- requirements:
208
- - - "~>"
209
- - !ruby/object:Gem::Version
210
- version: 0.34.0
211
- type: :development
212
- prerelease: false
213
- version_requirements: !ruby/object:Gem::Requirement
214
- requirements:
215
- - - "~>"
216
- - !ruby/object:Gem::Version
217
- version: 0.34.0
218
72
  description: |2
219
73
  Reek is a tool that examines Ruby classes, modules and methods and reports
220
74
  any code smells it finds.
@@ -320,13 +174,13 @@ files:
320
174
  - lib/reek/ast/sexp_extensions/methods.rb
321
175
  - lib/reek/ast/sexp_extensions/module.rb
322
176
  - lib/reek/ast/sexp_extensions/nested_assignables.rb
177
+ - lib/reek/ast/sexp_extensions/self.rb
323
178
  - lib/reek/ast/sexp_extensions/send.rb
324
179
  - lib/reek/ast/sexp_extensions/super.rb
325
180
  - lib/reek/ast/sexp_extensions/symbols.rb
326
181
  - lib/reek/ast/sexp_extensions/variables.rb
327
182
  - lib/reek/ast/sexp_extensions/when.rb
328
183
  - lib/reek/ast/sexp_extensions/yield.rb
329
- - lib/reek/ast/sexp_formatter.rb
330
184
  - lib/reek/cli/application.rb
331
185
  - lib/reek/cli/command.rb
332
186
  - lib/reek/cli/input.rb
@@ -345,10 +199,12 @@ files:
345
199
  - lib/reek/context/attribute_context.rb
346
200
  - lib/reek/context/class_context.rb
347
201
  - lib/reek/context/code_context.rb
202
+ - lib/reek/context/ghost_context.rb
348
203
  - lib/reek/context/method_context.rb
349
204
  - lib/reek/context/module_context.rb
350
205
  - lib/reek/context/root_context.rb
351
206
  - lib/reek/context/send_context.rb
207
+ - lib/reek/context/singleton_attribute_context.rb
352
208
  - lib/reek/context/singleton_method_context.rb
353
209
  - lib/reek/context/statement_counter.rb
354
210
  - lib/reek/context/visibility_tracker.rb
@@ -414,7 +270,6 @@ files:
414
270
  - spec/reek/ast/object_refs_spec.rb
415
271
  - spec/reek/ast/reference_collector_spec.rb
416
272
  - spec/reek/ast/sexp_extensions_spec.rb
417
- - spec/reek/ast/sexp_formatter_spec.rb
418
273
  - spec/reek/cli/input_spec.rb
419
274
  - spec/reek/cli/option_interpreter_spec.rb
420
275
  - spec/reek/cli/options_spec.rb
@@ -426,6 +281,7 @@ files:
426
281
  - spec/reek/configuration/directory_directives_spec.rb
427
282
  - spec/reek/configuration/excluded_paths_spec.rb
428
283
  - spec/reek/context/code_context_spec.rb
284
+ - spec/reek/context/ghost_context_spec.rb
429
285
  - spec/reek/context/method_context_spec.rb
430
286
  - spec/reek/context/module_context_spec.rb
431
287
  - spec/reek/context/root_context_spec.rb
@@ -1,31 +0,0 @@
1
- require_relative '../cli/silencer'
2
-
3
- Reek::CLI::Silencer.silently do
4
- require 'unparser'
5
- end
6
-
7
- module Reek
8
- module AST
9
- #
10
- # Formats snippets of syntax tree back into Ruby source code.
11
- #
12
- class SexpFormatter
13
- # Formats the given sexp.
14
- #
15
- # @param [AST::Node, #to_s] sexp - The expression to format
16
- #
17
- # @return [String] a formatted string representation.
18
- #
19
- # :reek:DuplicateMethodCall { max_calls: 2 } is ok for lines.first
20
- def self.format(sexp)
21
- return sexp.to_s unless sexp.is_a? ::Parser::AST::Node
22
- lines = Unparser.unparse(sexp).split "\n"
23
- case lines.length
24
- when 1 then lines.first
25
- when 2 then lines.join('; ')
26
- else [lines.first, lines.last].join(' ... ')
27
- end
28
- end
29
- end
30
- end
31
- end
@@ -1,35 +0,0 @@
1
- require_relative '../../spec_helper'
2
- require_lib 'reek/ast/sexp_formatter'
3
-
4
- RSpec.describe Reek::AST::SexpFormatter do
5
- describe '::format' do
6
- it 'formats a simple s-expression' do
7
- result = described_class.format sexp(:lvar, :foo)
8
- expect(result).to eq('foo')
9
- end
10
-
11
- it 'formats a more complex s-expression' do
12
- ast = sexp(:send, nil, :foo, sexp(:lvar, :bar))
13
- result = described_class.format(ast)
14
- expect(result).to eq('foo(bar)')
15
- end
16
-
17
- it 'reduces very large ASTs to a single line' do
18
- ast = sexp(:if,
19
- sexp(:send, nil, :foo),
20
- sexp(:send, nil, :bar),
21
- sexp(:begin,
22
- sexp(:send, nil, :baz),
23
- sexp(:send, nil, :qux)))
24
- result = described_class.format ast
25
-
26
- expect(result).to eq 'if foo ... end'
27
- end
28
-
29
- it "doesn't reduce two-line ASTs" do
30
- ast = sexp(:def, 'my_method', sexp(:args))
31
- result = described_class.format ast
32
- expect(result).to eq 'def my_method; end'
33
- end
34
- end
35
- end