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 +4 -4
- data/.github/workflows/ruby.yml +1 -0
- data/.gitignore +0 -1
- data/CHANGELOG.md +6 -0
- data/Gemfile +5 -9
- data/README.md +10 -12
- data/docs/yard_plugin.rb +17 -0
- data/lib/reek/ast/node.rb +15 -9
- data/lib/reek/cli/options.rb +2 -2
- data/lib/reek/report/github_report.rb +55 -0
- data/lib/reek/report/text_report.rb +1 -1
- data/lib/reek/report.rb +7 -5
- data/lib/reek/smell_detectors/data_clump.rb +1 -1
- data/lib/reek/smell_detectors/uncommunicative_module_name.rb +1 -1
- data/lib/reek/version.rb +1 -1
- data/reek.gemspec +6 -4
- metadata +22 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1d7aa8fda924b6b7065c1b5b9d399dfb7939e88036daa94d83c1a5c3f843e2d
|
4
|
+
data.tar.gz: 2a8417aa6caa28030557e54296664ade7c66c387a260d5fe65edf12cdb492d50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3068fc3007df15268479103c8a41c6fa75b59458aac4a2573c60fb478fadf46460f2f6b9a5e34a80626c5a918c7e48486e4e873ad215dba71c5255aac98f07d4
|
7
|
+
data.tar.gz: 2296dce209f76ddbb7da331af94cba1ec44b30fe7476861707e422f191633f336b3f9f13fab4b1db9e70ead8fb6eac2bd30d425c254b25f4ef040737ebd8d1a7
|
data/.github/workflows/ruby.yml
CHANGED
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
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.
|
18
|
-
gem 'rubocop-performance', '~> 1.
|
19
|
-
gem 'rubocop-rspec', '~> 2.
|
20
|
-
gem 'simplecov', '
|
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
|
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
|
-
|
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
|
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
|
-
|
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
|
556
|
+
Reek supports 6 output formats:
|
560
557
|
|
561
558
|
* plain text (default)
|
562
|
-
* HTML
|
563
|
-
* YAML
|
564
|
-
* JSON
|
565
|
-
* 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
|
|
data/docs/yard_plugin.rb
ADDED
@@ -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
|
-
|
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(
|
112
|
-
if target_types.include?
|
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(
|
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(
|
123
|
-
yield self if target_types.include?
|
124
|
-
return if ignoring.include?
|
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(
|
133
|
+
elem.look_for_recurse(lookup_rule, &blk)
|
128
134
|
end
|
129
135
|
end
|
130
136
|
|
data/lib/reek/cli/options.rb
CHANGED
@@ -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
|
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:
|
20
|
-
json:
|
21
|
-
html:
|
22
|
-
xml:
|
23
|
-
text:
|
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.
|
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
|
data/lib/reek/version.rb
CHANGED
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.
|
35
|
-
spec.
|
36
|
-
spec.
|
37
|
-
spec.
|
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.
|
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:
|
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.
|
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: []
|