reek 6.3.0 → 6.4.0

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: a1093258cb1b25a91e16e800eabcee4087d4ae8830d579decc6b11433b6fd9c4
4
- data.tar.gz: ea2c3a5e1f51edd9bdfcb1fe973b4d08210491f34bcfb26278bc970cd61325bf
3
+ metadata.gz: f1d7aa8fda924b6b7065c1b5b9d399dfb7939e88036daa94d83c1a5c3f843e2d
4
+ data.tar.gz: 2a8417aa6caa28030557e54296664ade7c66c387a260d5fe65edf12cdb492d50
5
5
  SHA512:
6
- metadata.gz: 56e29753527fc67429285f7da3537411ac951567d41a59024895fefa4287523e67c8c78332bc46375b4b6b154bf68bb6b5d6665f10cadec4f86654e0f5ea0a00
7
- data.tar.gz: e2b1f0f40d67f5ba966f527d9afdd1a18e6c6150ade2658a5316750f1d03ca5aef7580a82f59d59e617c581323dff8ef0b7d71ea070442a45cc924649edf32e7
6
+ metadata.gz: 3068fc3007df15268479103c8a41c6fa75b59458aac4a2573c60fb478fadf46460f2f6b9a5e34a80626c5a918c7e48486e4e873ad215dba71c5255aac98f07d4
7
+ data.tar.gz: 2296dce209f76ddbb7da331af94cba1ec44b30fe7476861707e422f191633f336b3f9f13fab4b1db9e70ead8fb6eac2bd30d425c254b25f4ef040737ebd8d1a7
@@ -11,6 +11,7 @@ name: CI
11
11
  branches: [master]
12
12
  schedule:
13
13
  - cron: '16 4 12 * *'
14
+ workflow_dispatch:
14
15
 
15
16
  env:
16
17
  CUCUMBER_PUBLISH_QUIET: true
data/.gitignore CHANGED
@@ -11,7 +11,6 @@ coverage
11
11
  Gemfile.lock
12
12
  *.swp
13
13
  tags
14
- .pryrc
15
14
  .tags*
16
15
  .DS_Store
17
16
  .idea/
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
 
2
2
  # Change log
3
3
 
4
+ ## 6.4.0 (2025-01-12)
5
+
6
+ ### Features and bugfixes
7
+
8
+ * Fix DataClump smell in Reek::AST::Node class ([#1799] by [le-santos])
9
+
4
10
  ## 6.3.0 (2024-01-28)
5
11
 
6
12
  ### Features and bugfixes
data/Gemfile CHANGED
@@ -6,7 +6,6 @@ ruby RUBY_VERSION
6
6
 
7
7
  group :development do
8
8
  gem 'aruba', '~> 2.1'
9
- gem 'bigdecimal', '>= 2.0.0', '< 4.0'
10
9
  gem 'codeclimate-engine-rb', '~> 0.4.0'
11
10
  gem 'cucumber', '~> 9.0'
12
11
  gem 'kramdown', '~> 2.1'
@@ -14,17 +13,14 @@ group :development do
14
13
  gem 'rake', '~> 13.0'
15
14
  gem 'rspec', '~> 3.0'
16
15
  gem 'rspec-benchmark', '~> 0.6.0'
17
- gem 'rubocop', '~> 1.60.2'
18
- gem 'rubocop-performance', '~> 1.20.0'
19
- gem 'rubocop-rspec', '~> 2.26.0'
20
- gem 'simplecov', '>= 0.18.0', '< 0.23.0'
16
+ gem 'rubocop', '~> 1.69.0'
17
+ gem 'rubocop-performance', '~> 1.23.0'
18
+ gem 'rubocop-rspec', '~> 3.2.0'
19
+ gem 'simplecov', '~> 0.22.0'
21
20
  gem 'yard', '~> 0.9.5'
22
21
 
23
22
  platforms :mri do
23
+ # Needed for YARD to properly parse GFM code blocks in the documentation
24
24
  gem 'redcarpet', '~> 3.4'
25
25
  end
26
26
  end
27
-
28
- group :debugging do
29
- gem 'pry', '~> 0.14.0'
30
- end
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.6 through 3.1 and for JRuby 9.3.
97
+ Reek is officially supported for CRuby 3.0 through 3.3 and for JRuby 9.4.
98
98
  Other Ruby implementations (like Rubinius) are not officially supported but
99
99
  should work as well.
100
100
 
@@ -514,18 +514,15 @@ Another useful Rake task is the `console` task. This will throw you right into a
514
514
  ```
515
515
  bundle exec rake console
516
516
 
517
- [3] pry(main)> require_relative 'lib/reek/examiner'
518
- => true
519
- [4] pry(main)> Reek::Examiner
517
+ irb(main):001> Reek::Examiner
520
518
  => Reek::Examiner
521
519
  ```
522
520
 
523
- You can also use Pry while running the tests by adding the following at the
521
+ You can also use IRB while running the tests by adding the following at the
524
522
  point where you want to start debugging:
525
523
 
526
524
  ```ruby
527
- require 'pry'
528
- binding.pry
525
+ binding.irb
529
526
  ```
530
527
 
531
528
  Have a look at our [Developer API](docs/API.md) for more inspiration.
@@ -556,13 +553,14 @@ e.g., `codeclimate analyze -e duplication`
556
553
 
557
554
  ## Output formats
558
555
 
559
- Reek supports 5 output formats:
556
+ Reek supports 6 output formats:
560
557
 
561
558
  * plain text (default)
562
- * HTML (`--format html`)
563
- * YAML (`--format yaml`, see also [YAML Reports](docs/YAML-Reports.md))
564
- * JSON (`--format json`)
565
- * XML (`--format xml`)
559
+ * HTML (`--format html`)
560
+ * YAML (`--format yaml`, see also [YAML Reports](docs/YAML-Reports.md))
561
+ * JSON (`--format json`)
562
+ * XML (`--format xml`)
563
+ * GitHub (`--format github`)
566
564
 
567
565
  ## Working with Rails
568
566
 
@@ -0,0 +1,17 @@
1
+ require 'yard'
2
+
3
+ # Template helper to modify processing of links in HTML generated from our
4
+ # markdown files.
5
+ module LocalLinkHelper
6
+ # Rewrites links to (assumed local) markdown files so they're processed as
7
+ # {file: } directives.
8
+ def resolve_links(text)
9
+ text = text.gsub(%r{<a href="([^"]*.md)">([^<]*)</a>}, '{file:\1 \2}')
10
+ super
11
+ end
12
+ end
13
+
14
+ YARD::Templates::Template.extra_includes << LocalLinkHelper
15
+ YARD::Tags::Library.define_tag('Guaranteed public API', :public)
16
+ YARD::Tags::Library.define_tag('Code quality configuration', :quality)
17
+ YARD::Templates::Engine.register_template_path File.join(File.dirname(__FILE__), 'templates')
data/lib/reek/ast/node.rb CHANGED
@@ -9,6 +9,11 @@ module Reek
9
9
  # methods to ease the transition from Sexp to AST::Node.
10
10
  #
11
11
  class Node < ::Parser::AST::Node
12
+ # Struct representing the rules for the search performed by each_node method.
13
+ NodeLookupRule = Struct.new(:target_types, :ignoring)
14
+
15
+ private_constant :NodeLookupRule
16
+
12
17
  def initialize(type, children = [], options = {})
13
18
  @comments = options.fetch(:comments, [])
14
19
  super
@@ -62,7 +67,8 @@ module Reek
62
67
  def each_node(target_types, ignoring = [], &blk)
63
68
  return enum_for(:each_node, target_types, ignoring) unless blk
64
69
 
65
- look_for(Array(target_types), ignoring, &blk)
70
+ lookup_rule = NodeLookupRule.new(Array(target_types), ignoring)
71
+ look_for(lookup_rule, &blk)
66
72
  end
67
73
 
68
74
  def contains_nested_node?(target_type)
@@ -108,23 +114,23 @@ module Reek
108
114
  protected
109
115
 
110
116
  # See ".each_node" for documentation.
111
- def look_for(target_types, ignoring, &blk)
112
- if target_types.include? type
117
+ def look_for(lookup_rule, &blk)
118
+ if lookup_rule.target_types.include?(type)
113
119
  yield self
114
- return if ignoring.include?(type)
120
+ return if lookup_rule.ignoring.include?(type)
115
121
  end
116
122
  each_sexp do |elem|
117
- elem.look_for_recurse(target_types, ignoring, &blk)
123
+ elem.look_for_recurse(lookup_rule, &blk)
118
124
  end
119
125
  end
120
126
 
121
127
  # See ".each_node" for documentation.
122
- def look_for_recurse(target_types, ignoring, &blk)
123
- yield self if target_types.include? type
124
- return if ignoring.include? type
128
+ def look_for_recurse(lookup_rule, &blk)
129
+ yield self if lookup_rule.target_types.include?(type)
130
+ return if lookup_rule.ignoring.include?(type)
125
131
 
126
132
  each_sexp do |elem|
127
- elem.look_for_recurse(target_types, ignoring, &blk)
133
+ elem.look_for_recurse(lookup_rule, &blk)
128
134
  end
129
135
  end
130
136
 
@@ -131,9 +131,9 @@ module Reek
131
131
  def set_alternative_formatter_options
132
132
  parser.separator "\nReport format:"
133
133
  parser.on(
134
- '-f', '--format FORMAT', [:html, :text, :yaml, :json, :xml],
134
+ '-f', '--format FORMAT', [:html, :text, :yaml, :json, :xml, :github],
135
135
  'Report smells in the given format:',
136
- ' html', ' text (default)', ' yaml', ' json', ' xml') do |opt|
136
+ ' html', ' text (default)', ' yaml', ' json', ' xml', ' github') do |opt|
137
137
  self.report_format = opt
138
138
  end
139
139
  end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base_report'
4
+
5
+ module Reek
6
+ module Report
7
+ #
8
+ # Displays smells as GitHub Workflow commands.
9
+ #
10
+ # @public
11
+ #
12
+ class GithubReport < BaseReport
13
+ def show(out = $stdout)
14
+ out.print(workflow_commands.join)
15
+ end
16
+
17
+ private
18
+
19
+ def workflow_commands
20
+ smells.map do |smell|
21
+ WorkflowCommand.new(smell)
22
+ end
23
+ end
24
+
25
+ # Represents a smell as a GitHub Workflow command.
26
+ class WorkflowCommand
27
+ def initialize(smell)
28
+ @smell = smell
29
+ end
30
+
31
+ def to_s
32
+ format(
33
+ "::warning file=%<file>s,line=%<line>d::%<message>s\n",
34
+ file: file,
35
+ line: line,
36
+ message: message)
37
+ end
38
+
39
+ private
40
+
41
+ def file
42
+ @smell.source
43
+ end
44
+
45
+ def line
46
+ @smell.lines.first
47
+ end
48
+
49
+ def message
50
+ @smell.base_message.gsub('%', '%25').gsub("\r", '%0D').gsub("\n", '%0A')
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -20,7 +20,7 @@ module Reek
20
20
  # @public
21
21
  def add_examiner(examiner)
22
22
  print progress_formatter.progress examiner
23
- super(examiner)
23
+ super
24
24
  end
25
25
 
26
26
  # @public
data/lib/reek/report.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'report/github_report'
3
4
  require_relative 'report/html_report'
4
5
  require_relative 'report/json_report'
5
6
  require_relative 'report/text_report'
@@ -16,11 +17,12 @@ module Reek
16
17
  # Reek reporting functionality.
17
18
  module Report
18
19
  REPORT_CLASSES = {
19
- yaml: YAMLReport,
20
- json: JSONReport,
21
- html: HTMLReport,
22
- xml: XMLReport,
23
- text: TextReport
20
+ yaml: YAMLReport,
21
+ json: JSONReport,
22
+ html: HTMLReport,
23
+ xml: XMLReport,
24
+ text: TextReport,
25
+ github: GithubReport
24
26
  }.freeze
25
27
 
26
28
  LOCATION_FORMATTERS = {
@@ -84,7 +84,7 @@ module Reek
84
84
  end
85
85
 
86
86
  def candidate_clumps
87
- candidate_methods.each_cons(max_copies + 1).map do |methods|
87
+ candidate_methods.combination(max_copies + 1).map do |methods|
88
88
  common_argument_names_for(methods)
89
89
  end.select do |clump|
90
90
  clump.length >= min_clump_size
@@ -31,7 +31,7 @@ module Reek
31
31
  DEFAULT_ACCEPT_PATTERNS = [].freeze
32
32
 
33
33
  def self.default_config
34
- super().merge(
34
+ super.merge(
35
35
  REJECT_KEY => DEFAULT_REJECT_PATTERNS,
36
36
  ACCEPT_KEY => DEFAULT_ACCEPT_PATTERNS)
37
37
  end
data/lib/reek/version.rb CHANGED
@@ -8,6 +8,6 @@ module Reek
8
8
  # @public
9
9
  module Version
10
10
  # @public
11
- STRING = '6.3.0'
11
+ STRING = '6.4.0'
12
12
  end
13
13
  end
data/reek.gemspec CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
18
18
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|samples|docs|tasks)/}) }
19
19
  end
20
+ spec.files << Dir['docs/yard_plugin.rb']
20
21
 
21
22
  spec.executables = spec.files.grep(%r{^bin/}).map { |path| File.basename(path) }
22
23
  spec.rdoc_options = %w(--main README.md -x assets/|bin/|config/|features/|spec/|tasks/)
@@ -31,8 +32,9 @@ Gem::Specification.new do |spec|
31
32
  'rubygems_mfa_required' => 'true'
32
33
  }
33
34
 
34
- spec.add_runtime_dependency 'dry-schema', '~> 1.13.0'
35
- spec.add_runtime_dependency 'parser', '~> 3.3.0'
36
- spec.add_runtime_dependency 'rainbow', '>= 2.0', '< 4.0'
37
- spec.add_runtime_dependency 'rexml', '~> 3.1'
35
+ spec.add_dependency 'dry-schema', '~> 1.13.0'
36
+ spec.add_dependency 'logger', '~> 1.6'
37
+ spec.add_dependency 'parser', '~> 3.3.0'
38
+ spec.add_dependency 'rainbow', '>= 2.0', '< 4.0'
39
+ spec.add_dependency 'rexml', '~> 3.1'
38
40
  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.3.0
4
+ version: 6.4.0
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: 2024-01-28 00:00:00.000000000 Z
14
+ date: 2025-01-12 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: dry-schema
@@ -27,6 +27,20 @@ dependencies:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
29
  version: 1.13.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: logger
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - "~>"
35
+ - !ruby/object:Gem::Version
36
+ version: '1.6'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '1.6'
30
44
  - !ruby/object:Gem::Dependency
31
45
  name: parser
32
46
  requirement: !ruby/object:Gem::Requirement
@@ -105,6 +119,7 @@ files:
105
119
  - Rakefile
106
120
  - bin/code_climate_reek
107
121
  - bin/reek
122
+ - docs/yard_plugin.rb
108
123
  - engine.json
109
124
  - lib/reek.rb
110
125
  - lib/reek/ast/ast_node_class_map.rb
@@ -186,6 +201,7 @@ files:
186
201
  - lib/reek/report.rb
187
202
  - lib/reek/report/base_report.rb
188
203
  - lib/reek/report/documentation_link_warning_formatter.rb
204
+ - lib/reek/report/github_report.rb
189
205
  - lib/reek/report/heading_formatter.rb
190
206
  - lib/reek/report/html_report.rb
191
207
  - lib/reek/report/html_report/html_report.html.erb
@@ -258,7 +274,7 @@ metadata:
258
274
  changelog_uri: https://github.com/troessner/reek/CHANGELOG.md
259
275
  documentation_uri: https://www.rubydoc.info/gems/reek
260
276
  rubygems_mfa_required: 'true'
261
- post_install_message:
277
+ post_install_message:
262
278
  rdoc_options:
263
279
  - "--main"
264
280
  - README.md
@@ -277,8 +293,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
277
293
  - !ruby/object:Gem::Version
278
294
  version: '0'
279
295
  requirements: []
280
- rubygems_version: 3.3.26
281
- signing_key:
296
+ rubygems_version: 3.0.3.1
297
+ signing_key:
282
298
  specification_version: 4
283
299
  summary: Code smell detector for Ruby
284
300
  test_files: []