reek 6.0.2 → 6.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 83760bf0344db6b8f65cd5bbb6e57f90ee4e1b54c10edb3920821a517e6649cd
4
- data.tar.gz: 258214d9022fda0ecbe287c4313719472c30f056c1ff6ffd4f7ff023b255b199
3
+ metadata.gz: 967e95555fe823e1924a78ff2a8c94c40bdb4d16d031bacd51b885d1475bce30
4
+ data.tar.gz: c9760389b64b3bb9f96f1896192a540a4de8b7f395808299b9a67e47238e8c42
5
5
  SHA512:
6
- metadata.gz: 56c12a16cc200dd475d84a543fd9edf2ce888f550a5d4d22cbe813c3439ed0915263340d7c02654417666bcd728ee5e9ba976670cae46098293b58595589f36c
7
- data.tar.gz: 0f012f16ec237bdece4f797ea2977c0db5fa083df32ac86ce57b14911777eec0d832aff8e861df67c5cc80b847b0c3caf801a157b759724cc9f858ae4236ace9
6
+ metadata.gz: ea4c588166903c10bed44c2a459e43e4db479943f8f489ca1eaefbb6db375605e06ff678f5411def292e19ef8c2754245bca78eb24373532474091b0ab8eadbe
7
+ data.tar.gz: 9e0804841d54d4278149422d66c7e379597e3f99275ba8b9ab4aef6e7041bde6c928db5f3c62a3b5c3d1d6fc4da0216ba5d13aa5562f9e0b565ec31bb115d0fe
@@ -0,0 +1,9 @@
1
+ # Documentation for all configuration options:
2
+ # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
3
+
4
+ version: 2
5
+ updates:
6
+ - package-ecosystem: "bundler"
7
+ directory: "/"
8
+ schedule:
9
+ interval: "daily"
@@ -0,0 +1,52 @@
1
+ # This workflow will download a prebuilt Ruby version, install dependencies and
2
+ # run tests with Rake
3
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
4
+
5
+ name: Ruby
6
+
7
+ on:
8
+ push:
9
+ branches: [ master ]
10
+ pull_request:
11
+ branches: [ master ]
12
+
13
+ jobs:
14
+ test:
15
+
16
+ runs-on: ubuntu-latest
17
+
18
+ strategy:
19
+ matrix:
20
+ ruby: [2.4, 2.5, 2.6, 2.7, jruby-9.2]
21
+
22
+ steps:
23
+ - uses: actions/checkout@v2
24
+ - name: Set up Ruby
25
+ uses: ruby/setup-ruby@v1
26
+ with:
27
+ ruby-version: ${{ matrix.ruby }}
28
+ bundler-cache: true
29
+ - name: Run specs
30
+ run: bundle exec rake test:spec
31
+ - name: Run performance tests
32
+ run: bundle exec rake test:performance
33
+ - name: Update default configuration
34
+ run: bundle exec rake configuration:update_default_configuration
35
+ - name: Run cucumber features
36
+ run: bundle exec rake test:features
37
+ - name: Run code quality specs
38
+ run: bundle exec rake test:quality
39
+
40
+ rubocop:
41
+
42
+ runs-on: ubuntu-latest
43
+
44
+ steps:
45
+ - uses: actions/checkout@v2
46
+ - name: Set up Ruby
47
+ uses: ruby/setup-ruby@v1
48
+ with:
49
+ ruby-version: 2.7
50
+ bundler-cache: true
51
+ - name: Run RuboCop
52
+ run: bundle exec rubocop -P
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2020-08-19 19:02:50 UTC using RuboCop version 0.89.1.
3
+ # on 2021-01-03 18:17:11 UTC using RuboCop version 1.7.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -13,22 +13,24 @@ Lint/MissingSuper:
13
13
  - 'lib/reek/smell_detectors/base_detector.rb'
14
14
 
15
15
  # Offense count: 2
16
+ # Configuration parameters: IgnoredPatterns.
17
+ # IgnoredPatterns: (?-mix:(exactly|at_least|at_most)\(\d+\)\.times)
16
18
  Lint/UnreachableLoop:
17
19
  Exclude:
18
20
  - 'spec/reek/ast/node_spec.rb'
19
21
 
20
22
  # Offense count: 2
21
- # Configuration parameters: IgnoredMethods.
23
+ # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
22
24
  Metrics/AbcSize:
23
25
  Max: 21
24
26
 
25
27
  # Offense count: 1
26
28
  # Configuration parameters: CountComments, CountAsOne.
27
29
  Metrics/ClassLength:
28
- Max: 161
30
+ Max: 170
29
31
 
30
32
  # Offense count: 13
31
- # Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
33
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
32
34
  Metrics/MethodLength:
33
35
  Max: 16
34
36
 
@@ -1,6 +1,11 @@
1
1
  # Change log
2
2
 
3
- ## 6.0.2 (2020-10-17)
3
+ ## 6.0.3 (2021-01-11)
4
+
5
+ * (mvz) Require parser 3.0
6
+ * (mvz) In a refinement, assign smells to the refined module or class
7
+
8
+ ## 6.0.3 (2020-10-17)
4
9
 
5
10
  * (mvz) Loosen dependency on psych. This should resolve installation problems on
6
11
  mingw32
data/Gemfile CHANGED
@@ -13,10 +13,10 @@ group :development do
13
13
  gem 'rake', '~> 13.0'
14
14
  gem 'rspec', '~> 3.0'
15
15
  gem 'rspec-benchmark', '~> 0.6.0'
16
- gem 'rubocop', '~> 0.93.0'
17
- gem 'rubocop-performance', '~> 1.8.0'
18
- gem 'rubocop-rspec', '~> 1.43.1'
19
- gem 'simplecov', ['>= 0.18.0', '< 0.20.0']
16
+ gem 'rubocop', '~> 1.7.0'
17
+ gem 'rubocop-performance', '~> 1.9.1'
18
+ gem 'rubocop-rspec', '~> 2.1.0'
19
+ gem 'simplecov', ['>= 0.18.0', '< 0.21.0']
20
20
  gem 'yard', '~> 0.9.5'
21
21
 
22
22
  platforms :mri do
@@ -42,7 +42,7 @@ This is highly dependent on your exact architecture, but looking at the example
42
42
 
43
43
  * Move everything in the `if` branch into a separate method
44
44
  * Move everything in the `else` branch into a separate method
45
- * Get rid of the `hit_the_switch` method alltogether
45
+ * Get rid of the `hit_the_switch` method altogether
46
46
  * Make the decision what method to call in the initial caller of `hit_the_switch`
47
47
 
48
48
  ## Current support in Reek
@@ -27,9 +27,7 @@ def show_api_marker_section?
27
27
  return false if object.type == :root
28
28
 
29
29
  case api_text
30
- when 'public'
31
- false
32
- when 'private'
30
+ when 'public', 'private'
33
31
  false
34
32
  else
35
33
  true
@@ -43,7 +43,7 @@ Feature: Reek can be controlled using command-line options
43
43
  -c, --config FILE Read configuration options from FILE
44
44
  --smell SMELL Only look for a specific smell.
45
45
  Call it like this: reek --smell MissingSafeMethod source.rb
46
- Check out https://github.com/troessner/reek/blob/v6.0.2/docs/Code-Smells.md for a list of smells
46
+ Check out https://github.com/troessner/reek/blob/v6.0.3/docs/Code-Smells.md for a list of smells
47
47
  --stdin-filename FILE When passing code in via pipe, assume this filename when checking file or directory rules in the config.
48
48
 
49
49
  Generate a todo list:
@@ -119,5 +119,5 @@ Feature: Reek can be controlled using command-line options
119
119
  UnusedPrivateMethod
120
120
  UtilityFunction
121
121
 
122
- Check out https://github.com/troessner/reek/blob/v6.0.2/docs/Code-Smells.md for a details on each detector
122
+ Check out https://github.com/troessner/reek/blob/v6.0.3/docs/Code-Smells.md for a details on each detector
123
123
  """
@@ -24,7 +24,7 @@ Feature: Report smells using simple JSON layout
24
24
  "context": "Smelly#x",
25
25
  "lines": [ 4 ],
26
26
  "message": "has the name 'x'",
27
- "documentation_link": "https://github.com/troessner/reek/blob/v6.0.2/docs/Uncommunicative-Method-Name.md",
27
+ "documentation_link": "https://github.com/troessner/reek/blob/v6.0.3/docs/Uncommunicative-Method-Name.md",
28
28
  "name": "x"
29
29
  },
30
30
  {
@@ -33,7 +33,7 @@ Feature: Report smells using simple JSON layout
33
33
  "context": "Smelly#x",
34
34
  "lines": [ 5 ],
35
35
  "message": "has the variable name 'y'",
36
- "documentation_link": "https://github.com/troessner/reek/blob/v6.0.2/docs/Uncommunicative-Variable-Name.md",
36
+ "documentation_link": "https://github.com/troessner/reek/blob/v6.0.3/docs/Uncommunicative-Variable-Name.md",
37
37
  "name": "y"
38
38
  }
39
39
  ]
@@ -53,7 +53,7 @@ Feature: Report smells using simple JSON layout
53
53
  1
54
54
  ],
55
55
  "message": "has no descriptive comment",
56
- "documentation_link": "https://github.com/troessner/reek/blob/v6.0.2/docs/Irresponsible-Module.md"
56
+ "documentation_link": "https://github.com/troessner/reek/blob/v6.0.3/docs/Irresponsible-Module.md"
57
57
  }
58
58
  ]
59
59
  """
@@ -182,8 +182,8 @@ Feature: Correctly formatted reports
182
182
  And it reports:
183
183
  """
184
184
  smelly.rb -- 2 warnings:
185
- [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/v6.0.2/docs/Uncommunicative-Method-Name.md]
186
- [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/v6.0.2/docs/Uncommunicative-Variable-Name.md]
185
+ [4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/v6.0.3/docs/Uncommunicative-Method-Name.md]
186
+ [5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/v6.0.3/docs/Uncommunicative-Variable-Name.md]
187
187
  """
188
188
 
189
189
  Examples:
@@ -209,8 +209,8 @@ Feature: Correctly formatted reports
209
209
  And it reports:
210
210
  """
211
211
  smelly.rb -- 2 warnings:
212
- UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/v6.0.2/docs/Uncommunicative-Method-Name.md]
213
- UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/v6.0.2/docs/Uncommunicative-Variable-Name.md]
212
+ UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/v6.0.3/docs/Uncommunicative-Method-Name.md]
213
+ UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/v6.0.3/docs/Uncommunicative-Variable-Name.md]
214
214
  """
215
215
 
216
216
  Examples:
@@ -25,7 +25,7 @@ Feature: Report smells using simple YAML layout
25
25
  smell_type: UncommunicativeMethodName
26
26
  source: smelly.rb
27
27
  name: x
28
- documentation_link: https://github.com/troessner/reek/blob/v6.0.2/docs/Uncommunicative-Method-Name.md
28
+ documentation_link: https://github.com/troessner/reek/blob/v6.0.3/docs/Uncommunicative-Method-Name.md
29
29
  - context: Smelly#x
30
30
  lines:
31
31
  - 5
@@ -33,7 +33,7 @@ Feature: Report smells using simple YAML layout
33
33
  smell_type: UncommunicativeVariableName
34
34
  source: smelly.rb
35
35
  name: y
36
- documentation_link: https://github.com/troessner/reek/blob/v6.0.2/docs/Uncommunicative-Variable-Name.md
36
+ documentation_link: https://github.com/troessner/reek/blob/v6.0.3/docs/Uncommunicative-Variable-Name.md
37
37
  """
38
38
 
39
39
  Scenario: Indicate smells and print them as yaml when using STDIN
@@ -48,5 +48,5 @@ Feature: Report smells using simple YAML layout
48
48
  lines:
49
49
  - 1
50
50
  message: has no descriptive comment
51
- documentation_link: https://github.com/troessner/reek/blob/v6.0.2/docs/Irresponsible-Module.md
51
+ documentation_link: https://github.com/troessner/reek/blob/v6.0.3/docs/Irresponsible-Module.md
52
52
  """
@@ -60,7 +60,7 @@ module Reek
60
60
  #
61
61
  # Returns an array with all matching nodes.
62
62
  def each_node(target_types, ignoring = [], &blk)
63
- return enum_for(:each_node, target_types, ignoring) unless block_given?
63
+ return enum_for(:each_node, target_types, ignoring) unless blk
64
64
 
65
65
  look_for(Array(target_types), ignoring, &blk)
66
66
  end
@@ -14,7 +14,8 @@ module Reek
14
14
  # @param paths [String]
15
15
  # @return [undefined]
16
16
  def add(paths)
17
- paths.each { |path| self << Pathname(path) }
17
+ paths.flat_map { |path| Dir[path] }.
18
+ each { |path| self << Pathname(path) }
18
19
  end
19
20
  end
20
21
  end
@@ -51,7 +51,7 @@ module Reek
51
51
  # @return [Enumerator]
52
52
  #
53
53
  def each(&block)
54
- return enum_for(:each) unless block_given?
54
+ return enum_for(:each) unless block
55
55
 
56
56
  yield self
57
57
  children.each do |child|
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'module_context'
4
+
5
+ module Reek
6
+ module Context
7
+ #
8
+ # A context wrapper for any refinement blocks found in a syntax tree.
9
+ #
10
+ class RefinementContext < ModuleContext
11
+ def full_name
12
+ exp.call.args.first.name
13
+ end
14
+ end
15
+ end
16
+ end
@@ -5,6 +5,7 @@ require_relative 'context/class_context'
5
5
  require_relative 'context/ghost_context'
6
6
  require_relative 'context/method_context'
7
7
  require_relative 'context/module_context'
8
+ require_relative 'context/refinement_context'
8
9
  require_relative 'context/root_context'
9
10
  require_relative 'context/send_context'
10
11
  require_relative 'context/singleton_attribute_context'
@@ -20,7 +21,7 @@ module Reek
20
21
  # counting. Ideally `ContextBuilder` would only build up the context tree and leave the
21
22
  # statement and reference counting to the contexts.
22
23
  #
23
- # @quality :reek:TooManyMethods { max_methods: 31 }
24
+ # @quality :reek:TooManyMethods { max_methods: 32 }
24
25
  # @quality :reek:UnusedPrivateMethod { exclude: [ !ruby/regexp /process_/ ] }
25
26
  # @quality :reek:DataClump
26
27
  class ContextBuilder
@@ -263,9 +264,16 @@ module Reek
263
264
  #
264
265
  # Counts non-empty blocks as one statement.
265
266
  #
267
+ # A refinement block is handled differently and causes a RefinementContext
268
+ # to be opened.
269
+ #
266
270
  def process_block(exp, _parent)
267
271
  increase_statement_count_by(exp.block)
268
- process(exp)
272
+ if exp.call.name == :refine
273
+ handle_refinement_block(exp)
274
+ else
275
+ process(exp)
276
+ end
269
277
  end
270
278
 
271
279
  # Handles `begin` and `kwbegin` nodes. `begin` nodes are created implicitly
@@ -508,6 +516,12 @@ module Reek
508
516
  end
509
517
  end
510
518
 
519
+ def handle_refinement_block(exp)
520
+ inside_new_context(Context::RefinementContext, exp) do
521
+ process(exp)
522
+ end
523
+ end
524
+
511
525
  def handle_send_for_modules(exp)
512
526
  arg_names = exp.args.map { |arg| arg.children.first }
513
527
  current_context.track_visibility(exp.name, arg_names)
@@ -8,6 +8,6 @@ module Reek
8
8
  # @public
9
9
  module Version
10
10
  # @public
11
- STRING = '6.0.2'
11
+ STRING = '6.0.3'
12
12
  end
13
13
  end
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
28
28
  }
29
29
 
30
30
  s.add_runtime_dependency 'kwalify', '~> 0.7.0'
31
- s.add_runtime_dependency 'parser', '< 2.8', '>= 2.5.0.0', '!= 2.5.1.1'
31
+ s.add_runtime_dependency 'parser', '~> 3.0.0'
32
32
  s.add_runtime_dependency 'psych', '~> 3.1'
33
33
  s.add_runtime_dependency 'rainbow', '>= 2.0', '< 4.0'
34
34
  end
@@ -5,12 +5,21 @@ require_lib 'reek/configuration/excluded_paths'
5
5
  RSpec.describe Reek::Configuration::ExcludedPaths do
6
6
  describe '#add' do
7
7
  let(:exclusions) { [].extend(described_class) }
8
- let(:paths) { ['smelly/sources'] }
9
- let(:expected_exclude_paths) { [Pathname('smelly/sources')] }
8
+ let(:paths) do
9
+ %w(samples/directory_does_not_exist/
10
+ samples/source_with_non_ruby_files/
11
+ samples/**/ignore_me*)
12
+ end
13
+
14
+ let(:expected_exclude_paths) do
15
+ [Pathname('samples/source_with_non_ruby_files/'),
16
+ Pathname('samples/source_with_exclude_paths/ignore_me'),
17
+ Pathname('samples/source_with_exclude_paths/nested/ignore_me_as_well')]
18
+ end
10
19
 
11
20
  it 'adds the given paths as Pathname' do
12
21
  exclusions.add(paths)
13
- expect(exclusions).to eq expected_exclude_paths
22
+ expect(exclusions).to match_array expected_exclude_paths
14
23
  end
15
24
  end
16
25
  end
@@ -161,6 +161,22 @@ RSpec.describe Reek::SmellDetectors::UtilityFunction do
161
161
  end
162
162
  end
163
163
 
164
+ context 'when examining refinements' do
165
+ it 'reports on the refined class' do
166
+ src = <<-RUBY
167
+ module Alfa
168
+ refine Bravo do
169
+ def bravo(charlie)
170
+ charlie.delta.echo
171
+ end
172
+ end
173
+ end
174
+ RUBY
175
+
176
+ expect(src).to reek_of(:UtilityFunction, context: 'Bravo#bravo')
177
+ end
178
+ end
179
+
164
180
  describe 'method visibility' do
165
181
  it 'reports private methods' do
166
182
  src = <<-RUBY
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reek
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.2
4
+ version: 6.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Rutherford
8
8
  - Timo Roessner
9
9
  - Matijs van Zuijlen
10
10
  - Piotr Szotkowski
11
- autorequire:
11
+ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2020-10-17 00:00:00.000000000 Z
14
+ date: 2021-01-11 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: kwalify
@@ -31,28 +31,16 @@ dependencies:
31
31
  name: parser
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - "<"
35
- - !ruby/object:Gem::Version
36
- version: '2.8'
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: 2.5.0.0
40
- - - "!="
34
+ - - "~>"
41
35
  - !ruby/object:Gem::Version
42
- version: 2.5.1.1
36
+ version: 3.0.0
43
37
  type: :runtime
44
38
  prerelease: false
45
39
  version_requirements: !ruby/object:Gem::Requirement
46
40
  requirements:
47
- - - "<"
48
- - !ruby/object:Gem::Version
49
- version: '2.8'
50
- - - ">="
51
- - !ruby/object:Gem::Version
52
- version: 2.5.0.0
53
- - - "!="
41
+ - - "~>"
54
42
  - !ruby/object:Gem::Version
55
- version: 2.5.1.1
43
+ version: 3.0.0
56
44
  - !ruby/object:Gem::Dependency
57
45
  name: psych
58
46
  requirement: !ruby/object:Gem::Requirement
@@ -100,12 +88,13 @@ extra_rdoc_files:
100
88
  - License.txt
101
89
  files:
102
90
  - ".dockerignore"
91
+ - ".github/dependabot.yml"
92
+ - ".github/workflows/ruby.yml"
103
93
  - ".gitignore"
104
94
  - ".reek.yml"
105
95
  - ".rubocop.yml"
106
96
  - ".rubocop_todo.yml"
107
97
  - ".simplecov"
108
- - ".travis.yml"
109
98
  - ".yardopts"
110
99
  - CHANGELOG.md
111
100
  - CONTRIBUTING.md
@@ -251,6 +240,7 @@ files:
251
240
  - lib/reek/context/ghost_context.rb
252
241
  - lib/reek/context/method_context.rb
253
242
  - lib/reek/context/module_context.rb
243
+ - lib/reek/context/refinement_context.rb
254
244
  - lib/reek/context/root_context.rb
255
245
  - lib/reek/context/send_context.rb
256
246
  - lib/reek/context/singleton_attribute_context.rb
@@ -471,7 +461,7 @@ metadata:
471
461
  bug_tracker_uri: https://github.com/troessner/reek/issues
472
462
  changelog_uri: https://github.com/troessner/reek/CHANGELOG.md
473
463
  documentation_uri: https://www.rubydoc.info/gems/reek
474
- post_install_message:
464
+ post_install_message:
475
465
  rdoc_options:
476
466
  - "--main"
477
467
  - README.md
@@ -490,8 +480,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
490
480
  - !ruby/object:Gem::Version
491
481
  version: '0'
492
482
  requirements: []
493
- rubygems_version: 3.1.2
494
- signing_key:
483
+ rubyforge_project:
484
+ rubygems_version: 2.7.7
485
+ signing_key:
495
486
  specification_version: 4
496
487
  summary: Code smell detector for Ruby
497
488
  test_files: []
@@ -1,40 +0,0 @@
1
- language: ruby
2
-
3
- dist: xenial
4
-
5
- cache:
6
- bundler: true
7
-
8
- bundler_args: --without debugging
9
-
10
- script: bundle exec rake ci
11
-
12
- rvm:
13
- - 2.4
14
- - 2.5
15
- - 2.6
16
- - 2.7
17
- - jruby-9.2
18
- - jruby-head
19
- - ruby-head
20
-
21
- matrix:
22
- allow_failures:
23
- - rvm: jruby-head
24
- - rvm: ruby-head
25
- fast_finish: true
26
-
27
- notifications:
28
- email:
29
- - timo.roessner@googlemail.com
30
- - matijs@matijs.net
31
- - chastell@chastell.net
32
- irc: irc.freenode.org#reek
33
-
34
- branches:
35
- only:
36
- - master
37
-
38
- env:
39
- global:
40
- - JRUBY_OPTS="--dev"