reek 3.10.0 → 3.10.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb34a3d020ec6d9c214ba0601080f6f3f1be9f62
4
- data.tar.gz: 7f9ce71ca71ef44adad6fc79f99abeef88f72a02
3
+ metadata.gz: bf831607e9695f0bd26f4cd6ba2c5e155c43bbdf
4
+ data.tar.gz: d8288adc73c7bfbd81af8d81546f1e0583181a74
5
5
  SHA512:
6
- metadata.gz: b1f7e66b52c231fe72f07e209ca06bd3abe9f65af64e9b886d1137b744f244cd93de634769da9598f6bd403d82bfce674d4ace97118b77d19c5d19da974f6496
7
- data.tar.gz: d43adf2de2ffb4ec3a4351afed0ddd1be460b1d1dbfcd10afd3a04a15e747d54da7132c56f5cc324e44c39ad167546204195f96ef6b35e024af142d41852fd10
6
+ metadata.gz: 408e265b23ef389a7d8a1f651c1b1c3d6cd77a3521abcb5cdd7233043ae389b709f48dbb1509cfceed38c815266b97acfcb0d2376811cc36da32fe71edec1534
7
+ data.tar.gz: af007da9b29b3c6f3bd70ccb0caec7aa7b8177a09ac3036cccb7725d2e208bd060bb167dba0e165df708f48aac87717d9fb645540da281c6de3ee36690d48ba1
data/.travis.yml CHANGED
@@ -9,6 +9,7 @@ rvm:
9
9
  - 2.0.0
10
10
  - 2.1
11
11
  - 2.2
12
+ - 2.3.0
12
13
  - rbx-2
13
14
  - ruby-head
14
15
  matrix:
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 3.10.1 (2016-02-07)
6
+
7
+ * (mvz) Fix edge case syntax problems
8
+ * (troessner) Disable UnusedPrivateMethod detector by default
9
+
5
10
  ## 3.10.0 (2016-01-27)
6
11
 
7
12
  * Add CodeClimate Docker integration. This will allow users to deduct their own docker image
data/README.md CHANGED
@@ -172,6 +172,15 @@ Reek currently includes checks for some aspects of
172
172
  and more. See the [Code Smells](docs/Code-Smells.md)
173
173
  for up to date details of exactly what Reek will check in your code.
174
174
 
175
+ Note that [Unused Private Method](docs/Unused-Private-Method.md) is disabled by default
176
+ because it is [kind of controversial](https://github.com/troessner/reek/issues/844) which means
177
+ you have to explicitly activate in your configuration via
178
+
179
+ ```Yaml
180
+ UnusedPrivateMethod:
181
+ enabled: true
182
+ ```
183
+
175
184
  ## Configuration
176
185
 
177
186
  ### Command-line interface
data/defaults.reek CHANGED
@@ -107,7 +107,7 @@ UnusedParameters:
107
107
  enabled: true
108
108
  exclude: []
109
109
  UnusedPrivateMethod:
110
- enabled: true
110
+ enabled: false
111
111
  exclude: []
112
112
  UtilityFunction:
113
113
  enabled: true
@@ -177,7 +177,7 @@ Feature: Basic smell detection
177
177
  UnusedParameters: OptionParser::Completion#convert has unused parameter 'opt' [https://github.com/troessner/reek/blob/master/docs/Unused-Parameters.md]
178
178
  UnusedParameters: OptionParser::Switch::NoArgument#parse has unused parameter 'argv' [https://github.com/troessner/reek/blob/master/docs/Unused-Parameters.md]
179
179
  UnusedParameters: OptionParser::Switch::OptionalArgument#parse has unused parameter 'argv' [https://github.com/troessner/reek/blob/master/docs/Unused-Parameters.md]
180
- redcloth.rb -- 121 warnings:
180
+ redcloth.rb -- 101 warnings:
181
181
  Attribute: RedCloth#filter_html is a writable attribute [https://github.com/troessner/reek/blob/master/docs/Attribute.md]
182
182
  Attribute: RedCloth#filter_styles is a writable attribute [https://github.com/troessner/reek/blob/master/docs/Attribute.md]
183
183
  Attribute: RedCloth#hard_breaks is a writable attribute [https://github.com/troessner/reek/blob/master/docs/Attribute.md]
@@ -269,26 +269,6 @@ Feature: Basic smell detection
269
269
  UnusedParameters: RedCloth#textile_fn_ has unused parameter 'cite' [https://github.com/troessner/reek/blob/master/docs/Unused-Parameters.md]
270
270
  UnusedParameters: RedCloth#textile_fn_ has unused parameter 'tag' [https://github.com/troessner/reek/blob/master/docs/Unused-Parameters.md]
271
271
  UnusedParameters: RedCloth#textile_p has unused parameter 'cite' [https://github.com/troessner/reek/blob/master/docs/Unused-Parameters.md]
272
- UnusedPrivateMethod: RedCloth has the unused private instance method `block_markdown_atx` [https://github.com/troessner/reek/blob/master/docs/Unused-Private-Method.md]
273
- UnusedPrivateMethod: RedCloth has the unused private instance method `block_markdown_bq` [https://github.com/troessner/reek/blob/master/docs/Unused-Private-Method.md]
274
- UnusedPrivateMethod: RedCloth has the unused private instance method `block_markdown_lists` [https://github.com/troessner/reek/blob/master/docs/Unused-Private-Method.md]
275
- UnusedPrivateMethod: RedCloth has the unused private instance method `block_markdown_rule` [https://github.com/troessner/reek/blob/master/docs/Unused-Private-Method.md]
276
- UnusedPrivateMethod: RedCloth has the unused private instance method `block_markdown_setext` [https://github.com/troessner/reek/blob/master/docs/Unused-Private-Method.md]
277
- UnusedPrivateMethod: RedCloth has the unused private instance method `block_textile_lists` [https://github.com/troessner/reek/blob/master/docs/Unused-Private-Method.md]
278
- UnusedPrivateMethod: RedCloth has the unused private instance method `block_textile_prefix` [https://github.com/troessner/reek/blob/master/docs/Unused-Private-Method.md]
279
- UnusedPrivateMethod: RedCloth has the unused private instance method `block_textile_table` [https://github.com/troessner/reek/blob/master/docs/Unused-Private-Method.md]
280
- UnusedPrivateMethod: RedCloth has the unused private instance method `inline_markdown_link` [https://github.com/troessner/reek/blob/master/docs/Unused-Private-Method.md]
281
- UnusedPrivateMethod: RedCloth has the unused private instance method `inline_markdown_reflink` [https://github.com/troessner/reek/blob/master/docs/Unused-Private-Method.md]
282
- UnusedPrivateMethod: RedCloth has the unused private instance method `inline_textile_code` [https://github.com/troessner/reek/blob/master/docs/Unused-Private-Method.md]
283
- UnusedPrivateMethod: RedCloth has the unused private instance method `inline_textile_image` [https://github.com/troessner/reek/blob/master/docs/Unused-Private-Method.md]
284
- UnusedPrivateMethod: RedCloth has the unused private instance method `inline_textile_link` [https://github.com/troessner/reek/blob/master/docs/Unused-Private-Method.md]
285
- UnusedPrivateMethod: RedCloth has the unused private instance method `inline_textile_span` [https://github.com/troessner/reek/blob/master/docs/Unused-Private-Method.md]
286
- UnusedPrivateMethod: RedCloth has the unused private instance method `refs_markdown` [https://github.com/troessner/reek/blob/master/docs/Unused-Private-Method.md]
287
- UnusedPrivateMethod: RedCloth has the unused private instance method `refs_textile` [https://github.com/troessner/reek/blob/master/docs/Unused-Private-Method.md]
288
- UnusedPrivateMethod: RedCloth has the unused private instance method `textile_bq` [https://github.com/troessner/reek/blob/master/docs/Unused-Private-Method.md]
289
- UnusedPrivateMethod: RedCloth has the unused private instance method `textile_fn_` [https://github.com/troessner/reek/blob/master/docs/Unused-Private-Method.md]
290
- UnusedPrivateMethod: RedCloth has the unused private instance method `textile_p` [https://github.com/troessner/reek/blob/master/docs/Unused-Private-Method.md]
291
- UnusedPrivateMethod: RedCloth has the unused private instance method `textile_popup_help` [https://github.com/troessner/reek/blob/master/docs/Unused-Private-Method.md]
292
272
  UtilityFunction: RedCloth#block_markdown_rule doesn't depend on instance state (maybe move it to another class?) [https://github.com/troessner/reek/blob/master/docs/Utility-Function.md]
293
273
  UtilityFunction: RedCloth#clean_html doesn't depend on instance state (maybe move it to another class?) [https://github.com/troessner/reek/blob/master/docs/Utility-Function.md]
294
274
  UtilityFunction: RedCloth#flush_left doesn't depend on instance state (maybe move it to another class?) [https://github.com/troessner/reek/blob/master/docs/Utility-Function.md]
@@ -299,5 +279,5 @@ Feature: Basic smell detection
299
279
  UtilityFunction: RedCloth#lT doesn't depend on instance state (maybe move it to another class?) [https://github.com/troessner/reek/blob/master/docs/Utility-Function.md]
300
280
  UtilityFunction: RedCloth#no_textile doesn't depend on instance state (maybe move it to another class?) [https://github.com/troessner/reek/blob/master/docs/Utility-Function.md]
301
281
  UtilityFunction: RedCloth#v_align doesn't depend on instance state (maybe move it to another class?) [https://github.com/troessner/reek/blob/master/docs/Utility-Function.md]
302
- 285 total warnings
282
+ 265 total warnings
303
283
  """
@@ -30,7 +30,9 @@ module Reek
30
30
  end
31
31
 
32
32
  def module_creation_receiver?
33
- receiver && [:Class, :Struct].include?(receiver.simple_name)
33
+ receiver &&
34
+ receiver.type == :const &&
35
+ [:Class, :Struct].include?(receiver.simple_name)
34
36
  end
35
37
 
36
38
  def object_creation_call?
@@ -11,6 +11,10 @@ module Reek
11
11
  # See {file:docs/Unused-Private-Method.md} for details.
12
12
  #
13
13
  class UnusedPrivateMethod < SmellDetector
14
+ def self.default_config
15
+ super.merge(SmellConfiguration::ENABLED_KEY => false)
16
+ end
17
+
14
18
  # Class for storing `hits` which are unused private methods
15
19
  # we found in the given context. `name` and `line` are then used to
16
20
  # construct SmellWarnings.
data/lib/reek/version.rb CHANGED
@@ -6,6 +6,6 @@ module Reek
6
6
  # @public
7
7
  module Version
8
8
  # @public
9
- STRING = '3.10.0'
9
+ STRING = '3.10.1'
10
10
  end
11
11
  end
@@ -269,6 +269,22 @@ RSpec.describe Reek::AST::SexpExtensions::SendNode do
269
269
  end
270
270
  end
271
271
 
272
+ context 'when it’s ‘new’ with a complex receiver' do
273
+ let(:node) { Reek::Source::SourceCode.from('(foo ? bar : baz).new').syntax_tree }
274
+
275
+ it 'is not considered to be a module creation call' do
276
+ expect(node.module_creation_call?).to be_falsey
277
+ end
278
+
279
+ it 'is not considered to have a module creation receiver' do
280
+ expect(node.module_creation_receiver?).to be_falsey
281
+ end
282
+
283
+ it 'is considered to be an object creation call' do
284
+ expect(node.object_creation_call?).to be_truthy
285
+ end
286
+ end
287
+
272
288
  context 'with 1 literal parameter' do
273
289
  let(:node) { sexp(:send, nil, :hello, sexp(:lit, :param)) }
274
290
 
@@ -162,6 +162,13 @@ RSpec.describe Reek::Smells::IrresponsibleModule do
162
162
  expect(src).to reek_of(:IrresponsibleModule, name: 'Foo')
163
163
  end
164
164
 
165
+ it 'reports top level classes defined through assignment' do
166
+ src = <<-EOS
167
+ Foo = Class.new Bar
168
+ EOS
169
+ expect(src).to reek_of(:IrresponsibleModule, name: 'Foo')
170
+ end
171
+
165
172
  it 'reports structs defined through assignment' do
166
173
  src = <<-EOS
167
174
  # Qux is responsible, but Foo is not
@@ -172,12 +179,20 @@ RSpec.describe Reek::Smells::IrresponsibleModule do
172
179
  expect(src).to reek_of(:IrresponsibleModule, name: 'Foo')
173
180
  end
174
181
 
182
+ it 'reports top level structs defined through assignment' do
183
+ src = <<-EOS
184
+ Foo = Struct.new(:x, :y)
185
+ EOS
186
+ expect(src).to reek_of(:IrresponsibleModule, name: 'Foo')
187
+ end
188
+
175
189
  it 'does not report constants that are not classes' do
176
190
  src = <<-EOS
177
191
  module Qux
178
192
  Foo = 23
179
193
  Bar = Hash.new
180
194
  Quuz = 'foo'.freeze
195
+ Zyxxy = Class.new.new
181
196
  end
182
197
  EOS
183
198
  expect(src).not_to reek_of(:IrresponsibleModule)
@@ -4,6 +4,12 @@ require_lib 'reek/examiner'
4
4
  require_relative 'smell_detector_shared'
5
5
 
6
6
  RSpec.describe Reek::Smells::UnusedPrivateMethod do
7
+ let(:configuration) do
8
+ test_configuration_for(
9
+ described_class =>
10
+ { Reek::Smells::SmellConfiguration::ENABLED_KEY => true }
11
+ )
12
+ end
7
13
  let(:detector) { build(:smell_detector, smell_type: :UnusedPrivateMethod) }
8
14
 
9
15
  it_should_behave_like 'SmellDetector'
@@ -18,8 +24,8 @@ RSpec.describe Reek::Smells::UnusedPrivateMethod do
18
24
  end
19
25
  EOF
20
26
 
21
- expect(source).to reek_of(:UnusedPrivateMethod, name: :start)
22
- expect(source).to reek_of(:UnusedPrivateMethod, name: :drive)
27
+ expect(source).to reek_of(:UnusedPrivateMethod, { name: :start }, configuration)
28
+ expect(source).to reek_of(:UnusedPrivateMethod, { name: :drive }, configuration)
23
29
  end
24
30
 
25
31
  it 'creates warnings correctly' do
@@ -31,7 +37,7 @@ RSpec.describe Reek::Smells::UnusedPrivateMethod do
31
37
  end
32
38
  EOF
33
39
 
34
- examiner = Reek::Examiner.new(source, 'UnusedPrivateMethod')
40
+ examiner = Reek::Examiner.new(source, 'UnusedPrivateMethod', configuration: configuration)
35
41
 
36
42
  first_warning = examiner.smells.first
37
43
  expect(first_warning.smell_category).to eq(Reek::Smells::UnusedPrivateMethod.smell_category)
@@ -58,7 +64,7 @@ RSpec.describe Reek::Smells::UnusedPrivateMethod do
58
64
  end
59
65
  EOF
60
66
 
61
- examiner = Reek::Examiner.new(source, 'UnusedPrivateMethod')
67
+ examiner = Reek::Examiner.new(source, 'UnusedPrivateMethod', configuration: configuration)
62
68
 
63
69
  expect(examiner.smells.size).to eq(1)
64
70
  warning_for_drive = examiner.smells.first
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.10.0
4
+ version: 3.10.1
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-27 00:00:00.000000000 Z
14
+ date: 2016-02-07 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: codeclimate-engine-rb
@@ -401,7 +401,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
401
401
  version: '0'
402
402
  requirements: []
403
403
  rubyforge_project:
404
- rubygems_version: 2.5.1
404
+ rubygems_version: 2.4.5.1
405
405
  signing_key:
406
406
  specification_version: 4
407
407
  summary: Code smell detector for Ruby