reek 6.0.5 → 6.1.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
  SHA256:
3
- metadata.gz: 23929fdfa24a401c782d5390e43941b9a3829ed51083e2f1b7d6bcfe1280cd4e
4
- data.tar.gz: 24ce8ccc73f1db8f7f2571d80d14ae95ba52060efd37f2d76af39a8bdaf0f177
3
+ metadata.gz: 2e1e79296b4eb0b93d7b6d7bc7b13704b6831765416cab19c729473d2fe135ea
4
+ data.tar.gz: f9a49ffd6ad47e308a617bafb0901d438617c863ff5279c867d5db8e9148c0e4
5
5
  SHA512:
6
- metadata.gz: 147a1013216674c7ead0cea2299ccaa37ccd89d2f409f11f65cf64706f747b96bbe06364059391a8f252c05fba3c2a9f7b4f314f424e92af5673ecc8eae20b74
7
- data.tar.gz: 2255554dbf2f7c1b3bb11daa8da1b7956c2ce1bb4a9c02da420f0db24fd285c8857dbbdf4b04616029ff1b0ed30bdd857012435d8557e6e1a7237d9c38887710
6
+ metadata.gz: 3ea8856c9c0f32543af3bb336790d9875cdf385ed45d2609af219f1857931d1b15de7802386954caff9c68f5753657f138e2eb304ef4ae94edc0e7a0e7e4e070
7
+ data.tar.gz: 407628086e04a8d2972f1343a34d299e77d462b0236f18e8b4570a9b9dfcd290dc6d690be56c67e06c0fff95326e764254b70c127962f5a90914a73bae115aed
@@ -2,14 +2,19 @@
2
2
  # run tests with Rake
3
3
  # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
4
4
 
5
- name: Ruby
5
+ name: CI
6
6
 
7
7
  on:
8
8
  push:
9
9
  branches: [ master ]
10
10
  pull_request:
11
11
  branches: [ master ]
12
+ schedule:
13
+ - cron: '16 4 12 * *'
12
14
 
15
+ env:
16
+ CUCUMBER_PUBLISH_QUIET: true
17
+ RUBYOPTS: "--disable-did-you-mean"
13
18
  jobs:
14
19
  test:
15
20
 
@@ -17,36 +22,36 @@ jobs:
17
22
 
18
23
  strategy:
19
24
  matrix:
20
- ruby: [2.4, 2.5, 2.6, 2.7, jruby-9.2]
25
+ ruby: [2.6, 2.7, "3.0", "3.1", jruby-9.3]
21
26
 
22
27
  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
28
+ - uses: actions/checkout@v2
29
+ - name: Set up Ruby
30
+ uses: ruby/setup-ruby@v1
31
+ with:
32
+ ruby-version: ${{ matrix.ruby }}
33
+ bundler-cache: true
34
+ - name: Run specs
35
+ run: bundle exec rake test:spec
36
+ - name: Run performance tests
37
+ run: bundle exec rake test:performance
38
+ - name: Update default configuration
39
+ run: bundle exec rake configuration:update_default_configuration
40
+ - name: Run cucumber features
41
+ run: bundle exec rake test:features
42
+ - name: Run code quality specs
43
+ run: bundle exec rake test:quality
39
44
 
40
45
  rubocop:
41
46
 
42
47
  runs-on: ubuntu-latest
43
48
 
44
49
  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
50
+ - uses: actions/checkout@v2
51
+ - name: Set up Ruby
52
+ uses: ruby/setup-ruby@v1
53
+ with:
54
+ ruby-version: 2.7
55
+ bundler-cache: true
56
+ - name: Run RuboCop
57
+ run: bundle exec rubocop -P
data/.rubocop.yml CHANGED
@@ -1,5 +1,9 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
+ inherit_mode:
4
+ merge:
5
+ - Exclude
6
+
3
7
  require:
4
8
  - rubocop-rspec
5
9
  - rubocop-performance
@@ -7,10 +11,8 @@ require:
7
11
  AllCops:
8
12
  Exclude:
9
13
  - 'samples/**/*'
10
- - 'tmp/**/*'
11
- - 'vendor/**/*'
12
14
  NewCops: enable
13
- TargetRubyVersion: 2.4
15
+ TargetRubyVersion: 2.6
14
16
 
15
17
  # Tables are nice
16
18
  Layout/HashAlignment:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Change log
2
2
 
3
+ ## 6.1.1 (2022-04-20)
4
+
5
+ * (ydah) UnusedPrivateMethod to be detect use of methods via `Method#to_proc`
6
+
7
+ ## 6.1.0 (2022-01-14)
8
+
9
+ * (mvz) Drop support for Ruby 2.4 and 2.5
10
+ * (mvz) Support Ruby 3.0 and 3.1
11
+ * (mvz) Support argument forwarding after regular arguments
12
+
13
+ ## 6.0.6 (2021-08-12)
14
+
15
+ * (mvz) Remove explicit dependency on psych. This fixes an issue where
16
+ installing Reek would unintentionally pull in psych 4.0
17
+
3
18
  ## 6.0.5 (2021-08-01)
4
19
 
5
20
  * (dependabot) Loosen dependency on psych
data/Gemfile CHANGED
@@ -5,17 +5,17 @@ gemspec
5
5
  ruby RUBY_VERSION
6
6
 
7
7
  group :development do
8
- gem 'aruba', '~> 1.0'
8
+ gem 'aruba', '~> 2.0'
9
9
  gem 'codeclimate-engine-rb', '~> 0.4.0'
10
- gem 'cucumber', ['>= 4.0', '< 7.0']
10
+ gem 'cucumber', '>= 4.0', '< 8.0'
11
11
  gem 'kramdown', '~> 2.1'
12
12
  gem 'kramdown-parser-gfm', '~> 1.0'
13
13
  gem 'rake', '~> 13.0'
14
14
  gem 'rspec', '~> 3.0'
15
15
  gem 'rspec-benchmark', '~> 0.6.0'
16
- gem 'rubocop', '~> 1.12.0'
17
- gem 'rubocop-performance', '~> 1.10.1'
18
- gem 'rubocop-rspec', '~> 2.2.0'
16
+ gem 'rubocop', '~> 1.27.0'
17
+ gem 'rubocop-performance', '~> 1.13.1'
18
+ gem 'rubocop-rspec', '~> 2.9.0'
19
19
  gem 'simplecov', ['>= 0.18.0', '< 0.22.0']
20
20
  gem 'yard', '~> 0.9.5'
21
21
 
data/README.md CHANGED
@@ -94,7 +94,7 @@ demo.rb -- 2 warnings:
94
94
 
95
95
  ## Supported Ruby versions
96
96
 
97
- Reek is officially supported for CRuby 2.4 to 2.7 and for JRuby 9.2.
97
+ Reek is officially supported for CRuby 2.6 through 3.1 and for JRuby 9.3.
98
98
  Other Ruby implementations (like Rubinius) are not officially supported but
99
99
  should work as well.
100
100
 
@@ -104,6 +104,17 @@ module Reek
104
104
  end
105
105
  end
106
106
  # rubocop:enable Naming/ClassAndModuleCamelCase
107
+
108
+ # Utility methods for :forward_arg nodes.
109
+ # rubocop:disable Naming/ClassAndModuleCamelCase
110
+ module Forward_ArgNode
111
+ include ArgNodeBase
112
+
113
+ def anonymous_splat?
114
+ true
115
+ end
116
+ end
117
+ # rubocop:enable Naming/ClassAndModuleCamelCase
107
118
  end
108
119
  end
109
120
  end
@@ -10,7 +10,7 @@ module Reek
10
10
  end
11
11
 
12
12
  def body_nodes(type, ignoring = [])
13
- children[1..-1].compact.flat_map do |child|
13
+ children[1..].compact.flat_map do |child|
14
14
  child.each_node(type, ignoring | type).to_a
15
15
  end
16
16
  end
@@ -31,7 +31,7 @@ module Reek
31
31
 
32
32
  # @quality :reek:FeatureEnvy
33
33
  def body_nodes(type, ignoring = [])
34
- children[1..-1].compact.flat_map do |child|
34
+ children[1..].compact.flat_map do |child|
35
35
  if ignoring.include? child.type
36
36
  []
37
37
  else
@@ -16,7 +16,7 @@ module Reek
16
16
  end
17
17
 
18
18
  def args
19
- children[2..-1]
19
+ children[2..]
20
20
  end
21
21
 
22
22
  def participants
@@ -24,7 +24,7 @@ module Reek
24
24
  else
25
25
  write_to_file
26
26
  puts "\n'#{DEFAULT_CONFIGURATION_FILE_NAME}' generated! "\
27
- 'You can now use this as a starting point.'
27
+ 'You can now use this as a starting point.'
28
28
  end
29
29
  options.success_exit_code
30
30
  end
@@ -232,7 +232,7 @@ module Reek
232
232
  puts "All available smell detectors:\n\n"
233
233
  puts DetectorRepository.available_detector_names
234
234
  puts "\nCheck out #{DocumentationLink.build('Code Smells')} "\
235
- 'for a details on each detector'
235
+ 'for a details on each detector'
236
236
  exit
237
237
  end
238
238
  parser.on_tail('-v', '--version', 'Show version') do
@@ -39,13 +39,13 @@ module Reek
39
39
 
40
40
  @original_comment.scan(CONFIGURATION_REGEX) do |detector_name, separator, options|
41
41
  escalate_legacy_separator separator
42
- CodeCommentValidator.new(detector_name: detector_name,
43
- original_comment: original_comment,
44
- line: line,
45
- source: source,
46
- options: options).validate
47
- @config.merge! detector_name => YAML.safe_load(options || DISABLE_DETECTOR_CONFIGURATION,
48
- permitted_classes: [Regexp])
42
+ validator = CodeCommentValidator.new(detector_name: detector_name,
43
+ original_comment: original_comment,
44
+ line: line,
45
+ source: source,
46
+ options: options)
47
+ validator.validate
48
+ @config.merge! detector_name => validator.parsed_options
49
49
  end
50
50
  end
51
51
 
@@ -115,6 +115,21 @@ module Reek
115
115
  escalate_unknown_configuration_key
116
116
  end
117
117
 
118
+ def parsed_options
119
+ @parsed_options ||=
120
+ if Psych::VERSION < '3.1.0'
121
+ YAML.safe_load(options || CodeComment::DISABLE_DETECTOR_CONFIGURATION, [Regexp])
122
+ else
123
+ YAML.safe_load(options || CodeComment::DISABLE_DETECTOR_CONFIGURATION,
124
+ permitted_classes: [Regexp])
125
+ end
126
+ rescue Psych::SyntaxError
127
+ raise Errors::GarbageDetectorConfigurationInCommentError.new(detector_name: detector_name,
128
+ original_comment: original_comment,
129
+ source: source,
130
+ line: line)
131
+ end
132
+
118
133
  private
119
134
 
120
135
  attr_reader :detector_name,
@@ -124,16 +139,6 @@ module Reek
124
139
  :separator,
125
140
  :options
126
141
 
127
- def parsed_options
128
- @parsed_options ||= YAML.safe_load(options || CodeComment::DISABLE_DETECTOR_CONFIGURATION,
129
- permitted_classes: [Regexp])
130
- rescue Psych::SyntaxError
131
- raise Errors::GarbageDetectorConfigurationInCommentError.new(detector_name: detector_name,
132
- original_comment: original_comment,
133
- source: source,
134
- line: line)
135
- end
136
-
137
142
  def escalate_unknown_configuration_key
138
143
  return if given_keys_legit?
139
144
 
@@ -55,6 +55,10 @@ module Reek
55
55
  end
56
56
  end
57
57
 
58
+ def instance_method_names_via_to_call
59
+ instance_method_calls.flat_map(&:method_name_called_to_call).compact
60
+ end
61
+
58
62
  #
59
63
  # @deprecated use `defined_instance_methods` instead
60
64
  #
@@ -14,6 +14,12 @@ module Reek
14
14
  @name = name
15
15
  super exp
16
16
  end
17
+
18
+ def method_name_called_to_call
19
+ return unless @name == :method
20
+
21
+ local_nodes(:sym).map(&:name)
22
+ end
17
23
  end
18
24
  end
19
25
  end
@@ -422,7 +422,7 @@ module Reek
422
422
  # See `process_rescue` for additional reference.
423
423
  #
424
424
  def process_resbody(exp, _parent)
425
- increase_statement_count_by(exp.children[1..-1].compact)
425
+ increase_statement_count_by(exp.children[1..].compact)
426
426
  process(exp)
427
427
  end
428
428
 
@@ -88,7 +88,7 @@ module Reek
88
88
  def source_files=(files)
89
89
  unless files.is_a?(String) || files.is_a?(FileList)
90
90
  raise ArgumentError, 'File list should be a FileList or a String that can contain'\
91
- " a glob pattern, e.g. '{app,lib,spec}/**/*.rb'"
91
+ " a glob pattern, e.g. '{app,lib,spec}/**/*.rb'"
92
92
  end
93
93
  @source_files = FileList[files]
94
94
  end
@@ -61,6 +61,7 @@ module Reek
61
61
  def unused_private_methods
62
62
  defined_private_methods = context.defined_instance_methods(visibility: :private)
63
63
  called_method_names = context.instance_method_calls.map(&:name)
64
+ called_method_names.concat(context.instance_method_names_via_to_call)
64
65
 
65
66
  defined_private_methods.reject do |defined_method|
66
67
  called_method_names.include?(defined_method.name)
@@ -59,7 +59,7 @@ module Reek
59
59
 
60
60
  # @public
61
61
  def to_hash
62
- stringified_params = parameters.map { |key, val| [key.to_s, val] }.to_h
62
+ stringified_params = parameters.transform_keys(&:to_s)
63
63
  base_hash.merge(stringified_params)
64
64
  end
65
65
 
@@ -70,18 +70,20 @@ module Reek
70
70
 
71
71
  def set_failure_messages_for_smell_type
72
72
  self.failure_message = "Expected #{origin} to reek of #{smell_type}, "\
73
- 'but it didn\'t'
73
+ 'but it didn\'t'
74
74
  self.failure_message_when_negated = "Expected #{origin} not to reek "\
75
- "of #{smell_type}, but it did"
75
+ "of #{smell_type}, but it did"
76
76
  end
77
77
 
78
78
  def set_failure_messages_for_smell_details
79
- self.failure_message = "Expected #{origin} to reek of #{smell_type} "\
79
+ self.failure_message =
80
+ "Expected #{origin} to reek of #{smell_type} "\
80
81
  "(which it did) with smell details #{smell_details}, which it didn't.\n"\
81
82
  "The number of smell details I had to compare with the given one was #{matching_smell_types.count} "\
82
83
  "and here they are:\n"\
83
84
  "#{all_relevant_smell_details_formatted}"
84
- self.failure_message_when_negated = "Expected #{origin} not to reek of "\
85
+ self.failure_message_when_negated =
86
+ "Expected #{origin} not to reek of "\
85
87
  "#{smell_type} with smell details #{smell_details}, but it did"
86
88
  end
87
89
 
data/lib/reek/version.rb CHANGED
@@ -3,11 +3,11 @@
3
3
  # @public
4
4
  module Reek
5
5
  #
6
- # This module holds the Reek version informations
6
+ # This module holds the Reek version information
7
7
  #
8
8
  # @public
9
9
  module Version
10
10
  # @public
11
- STRING = '6.0.5'
11
+ STRING = '6.1.1'
12
12
  end
13
13
  end
data/reek.gemspec CHANGED
@@ -1,37 +1,37 @@
1
- require File.join(File.dirname(__FILE__), 'lib/reek/version')
1
+ require_relative 'lib/reek/version'
2
2
 
3
- Gem::Specification.new do |s|
4
- s.name = 'reek'
5
- s.version = Reek::Version::STRING
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'reek'
5
+ spec.version = Reek::Version::STRING
6
+ spec.authors = ['Kevin Rutherford', 'Timo Roessner', 'Matijs van Zuijlen', 'Piotr Szotkowski']
7
+ spec.email = ['timo.roessner@googlemail.com']
6
8
 
7
- s.authors = ['Kevin Rutherford', 'Timo Roessner', 'Matijs van Zuijlen', 'Piotr Szotkowski']
8
- s.description =
9
+ spec.summary = 'Code smell detector for Ruby'
10
+ spec.description =
9
11
  'Reek is a tool that examines Ruby classes, modules and methods and reports ' \
10
12
  'any code smells it finds.'
13
+ spec.homepage = 'https://github.com/troessner/reek'
14
+ spec.license = 'MIT'
11
15
 
12
- s.license = 'MIT'
13
- s.email = ['timo.roessner@googlemail.com']
14
- s.extra_rdoc_files = ['CHANGELOG.md', 'License.txt']
15
- s.files = Dir.chdir(File.expand_path(__dir__)) do
16
+ spec.extra_rdoc_files = ['CHANGELOG.md', 'License.txt']
17
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
16
18
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|samples|docs|tasks)/}) }
17
19
  end
18
20
 
19
- s.executables = s.files.grep(%r{^bin/}).map { |path| File.basename(path) }
20
- s.homepage = 'https://github.com/troessner/reek'
21
- s.rdoc_options = %w(--main README.md -x assets/|bin/|config/|features/|spec/|tasks/)
22
- s.required_ruby_version = '>= 2.4.0'
23
- s.summary = 'Code smell detector for Ruby'
21
+ spec.executables = spec.files.grep(%r{^bin/}).map { |path| File.basename(path) }
22
+ spec.rdoc_options = %w(--main README.md -x assets/|bin/|config/|features/|spec/|tasks/)
23
+ spec.required_ruby_version = '>= 2.6.0'
24
24
 
25
- s.metadata = {
26
- 'homepage_uri' => 'https://github.com/troessner/reek',
27
- 'source_code_uri' => 'https://github.com/troessner/reek',
28
- 'bug_tracker_uri' => 'https://github.com/troessner/reek/issues',
29
- 'changelog_uri' => 'https://github.com/troessner/reek/CHANGELOG.md',
30
- 'documentation_uri' => 'https://www.rubydoc.info/gems/reek'
25
+ spec.metadata = {
26
+ 'homepage_uri' => 'https://github.com/troessner/reek',
27
+ 'source_code_uri' => 'https://github.com/troessner/reek',
28
+ 'bug_tracker_uri' => 'https://github.com/troessner/reek/issues',
29
+ 'changelog_uri' => 'https://github.com/troessner/reek/CHANGELOG.md',
30
+ 'documentation_uri' => 'https://www.rubydoc.info/gems/reek',
31
+ 'rubygems_mfa_required' => 'true'
31
32
  }
32
33
 
33
- s.add_runtime_dependency 'kwalify', '~> 0.7.0'
34
- s.add_runtime_dependency 'parser', '~> 3.0.0'
35
- s.add_runtime_dependency 'psych', '>= 3.1', '< 5.0'
36
- s.add_runtime_dependency 'rainbow', '>= 2.0', '< 4.0'
34
+ spec.add_runtime_dependency 'kwalify', '~> 0.7.0'
35
+ spec.add_runtime_dependency 'parser', '~> 3.1.0'
36
+ spec.add_runtime_dependency 'rainbow', '>= 2.0', '< 4.0'
37
37
  end
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.5
4
+ version: 6.1.1
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: 2021-08-01 00:00:00.000000000 Z
14
+ date: 2022-04-20 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: kwalify
@@ -33,34 +33,14 @@ dependencies:
33
33
  requirements:
34
34
  - - "~>"
35
35
  - !ruby/object:Gem::Version
36
- version: 3.0.0
36
+ version: 3.1.0
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - "~>"
42
42
  - !ruby/object:Gem::Version
43
- version: 3.0.0
44
- - !ruby/object:Gem::Dependency
45
- name: psych
46
- requirement: !ruby/object:Gem::Requirement
47
- requirements:
48
- - - ">="
49
- - !ruby/object:Gem::Version
50
- version: '3.1'
51
- - - "<"
52
- - !ruby/object:Gem::Version
53
- version: '5.0'
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: '3.1'
61
- - - "<"
62
- - !ruby/object:Gem::Version
63
- version: '5.0'
43
+ version: 3.1.0
64
44
  - !ruby/object:Gem::Dependency
65
45
  name: rainbow
66
46
  requirement: !ruby/object:Gem::Requirement
@@ -263,7 +243,8 @@ metadata:
263
243
  bug_tracker_uri: https://github.com/troessner/reek/issues
264
244
  changelog_uri: https://github.com/troessner/reek/CHANGELOG.md
265
245
  documentation_uri: https://www.rubydoc.info/gems/reek
266
- post_install_message:
246
+ rubygems_mfa_required: 'true'
247
+ post_install_message:
267
248
  rdoc_options:
268
249
  - "--main"
269
250
  - README.md
@@ -275,15 +256,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
275
256
  requirements:
276
257
  - - ">="
277
258
  - !ruby/object:Gem::Version
278
- version: 2.4.0
259
+ version: 2.6.0
279
260
  required_rubygems_version: !ruby/object:Gem::Requirement
280
261
  requirements:
281
262
  - - ">="
282
263
  - !ruby/object:Gem::Version
283
264
  version: '0'
284
265
  requirements: []
285
- rubygems_version: 3.2.22
286
- signing_key:
266
+ rubygems_version: 3.1.6
267
+ signing_key:
287
268
  specification_version: 4
288
269
  summary: Code smell detector for Ruby
289
270
  test_files: []