reek 4.8.0 → 4.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +3 -1
- data/CHANGELOG.md +3 -1
- data/Gemfile +2 -2
- data/docs/Unused-Private-Method.md +1 -1
- data/lib/reek/cli/command/todo_list_command.rb +5 -7
- data/lib/reek/context_builder.rb +2 -2
- data/lib/reek/report/code_climate/code_climate_configuration.rb +1 -1
- data/lib/reek/smell_detectors/base_detector.rb +1 -1
- data/lib/reek/source/source_code.rb +40 -33
- data/lib/reek/version.rb +1 -1
- data/reek.gemspec +1 -1
- metadata +13 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2d66c9a36e561c26a8a5cd27af9780ded54de1fdfe9b00b289701027403330b3
|
4
|
+
data.tar.gz: 592050ff0e9af5744467c2299cb085246059fbdc96358dbadbad68a0f2e36763
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 431ee00e3a0021baa1c752d0a2393b84bdf873d7be702c428f57b1b538ff9dceb11957551674be4031ddd26d9ddb7aa9a01a00b84aa53cd1650f76f045243370
|
7
|
+
data.tar.gz: 58c93de891eec497652eda081101a7b77a93eee296c4824b379beb4982de4064c9488d67fa9dd9fe2cfe822f428be305befd65a80b77fe5ec3eb2a4d428a3b5a
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -12,11 +12,11 @@ group :development do
|
|
12
12
|
gem 'factory_bot', '~> 4.0'
|
13
13
|
gem 'rake', '~> 12.0'
|
14
14
|
gem 'rspec', '~> 3.0'
|
15
|
-
gem 'simplecov', '~> 0.
|
15
|
+
gem 'simplecov', '~> 0.16.1'
|
16
16
|
gem 'yard', '~> 0.9.5'
|
17
17
|
|
18
18
|
if RUBY_VERSION >= '2.3'
|
19
|
-
gem 'rubocop', '~> 0.
|
19
|
+
gem 'rubocop', '~> 0.53.0'
|
20
20
|
gem 'rubocop-rspec', '~> 1.20'
|
21
21
|
end
|
22
22
|
|
@@ -14,12 +14,11 @@ module Reek
|
|
14
14
|
FILE_NAME = '.todo.reek'.freeze
|
15
15
|
|
16
16
|
def execute
|
17
|
-
smells = scan_for_smells
|
18
17
|
if smells.empty?
|
19
18
|
puts "\n'.todo.reek' not generated because "\
|
20
19
|
'there were no smells found!'
|
21
20
|
else
|
22
|
-
File.write FILE_NAME,
|
21
|
+
File.write FILE_NAME, groups.to_yaml
|
23
22
|
puts "\n'.todo.reek' generated! You can now use "\
|
24
23
|
'this as a starting point for your configuration.'
|
25
24
|
end
|
@@ -28,14 +27,13 @@ module Reek
|
|
28
27
|
|
29
28
|
private
|
30
29
|
|
31
|
-
def
|
32
|
-
sources.map do |source|
|
33
|
-
Examiner.new(source,
|
34
|
-
filter_by_smells: smell_names)
|
30
|
+
def smells
|
31
|
+
@smells ||= sources.map do |source|
|
32
|
+
Examiner.new(source, filter_by_smells: smell_names)
|
35
33
|
end.map(&:smells).flatten
|
36
34
|
end
|
37
35
|
|
38
|
-
def
|
36
|
+
def groups
|
39
37
|
@groups ||=
|
40
38
|
begin
|
41
39
|
todos = smells.group_by(&:smell_class).map do |smell_class, smells_for_class|
|
data/lib/reek/context_builder.rb
CHANGED
@@ -206,7 +206,7 @@ module Reek
|
|
206
206
|
#
|
207
207
|
# def self.foo; end
|
208
208
|
#
|
209
|
-
def process_self(
|
209
|
+
def process_self(_exp, _parent)
|
210
210
|
current_context.record_use_of_self
|
211
211
|
end
|
212
212
|
|
@@ -226,7 +226,7 @@ module Reek
|
|
226
226
|
#
|
227
227
|
# We record one reference to `self`.
|
228
228
|
#
|
229
|
-
def process_zsuper(
|
229
|
+
def process_zsuper(_exp, _parent)
|
230
230
|
current_context.record_use_of_self
|
231
231
|
end
|
232
232
|
|
@@ -5,7 +5,7 @@ module Reek
|
|
5
5
|
# loads the smell type metadata to present in Code Climate
|
6
6
|
module CodeClimateConfiguration
|
7
7
|
def self.load
|
8
|
-
config_file = File.expand_path('
|
8
|
+
config_file = File.expand_path('code_climate_configuration.yml', __dir__)
|
9
9
|
YAML.load_file config_file
|
10
10
|
end
|
11
11
|
end
|
@@ -17,6 +17,21 @@ module Reek
|
|
17
17
|
# A +Source+ object represents a chunk of Ruby source code.
|
18
18
|
#
|
19
19
|
class SourceCode
|
20
|
+
# Consume and store parser diagnostics
|
21
|
+
class DiagnosticsConsumer
|
22
|
+
def initialize
|
23
|
+
@diagnostics = []
|
24
|
+
end
|
25
|
+
|
26
|
+
def call(item)
|
27
|
+
@diagnostics << item
|
28
|
+
end
|
29
|
+
|
30
|
+
def result
|
31
|
+
@diagnostics
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
20
35
|
IO_IDENTIFIER = 'STDIN'.freeze
|
21
36
|
STRING_IDENTIFIER = 'string'.freeze
|
22
37
|
|
@@ -26,11 +41,11 @@ module Reek
|
|
26
41
|
#
|
27
42
|
# code - Ruby code as String
|
28
43
|
# origin - 'STDIN', 'string' or a filepath as String
|
29
|
-
# parser - the parser to use for generating AST's out of the given
|
30
|
-
def initialize(code:, origin:, parser: default_parser)
|
44
|
+
# parser - the parser to use for generating AST's out of the given code
|
45
|
+
def initialize(code:, origin:, parser: self.class.default_parser)
|
31
46
|
@origin = origin
|
32
|
-
@diagnostics = []
|
33
47
|
@parser = parser
|
48
|
+
code.force_encoding(Encoding::UTF_8)
|
34
49
|
@code = code
|
35
50
|
end
|
36
51
|
|
@@ -54,23 +69,32 @@ module Reek
|
|
54
69
|
end
|
55
70
|
|
56
71
|
def diagnostics
|
57
|
-
|
58
|
-
@diagnostics
|
72
|
+
parse_result.last
|
59
73
|
end
|
60
74
|
|
61
75
|
def syntax_tree
|
62
|
-
|
76
|
+
parse_result.first
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.default_parser
|
80
|
+
Parser::Ruby25.new(AST::Builder.new).tap do |parser|
|
81
|
+
diagnostics = parser.diagnostics
|
82
|
+
diagnostics.all_errors_are_fatal = false
|
83
|
+
diagnostics.ignore_warnings = false
|
84
|
+
diagnostics.consumer = DiagnosticsConsumer.new
|
85
|
+
end
|
63
86
|
end
|
64
87
|
|
65
88
|
private
|
66
89
|
|
67
|
-
def
|
68
|
-
@
|
90
|
+
def parse_result
|
91
|
+
@parse_result ||= parse
|
69
92
|
end
|
70
93
|
|
71
|
-
attr_reader :
|
94
|
+
attr_reader :code
|
95
|
+
attr_reader :parser
|
72
96
|
|
73
|
-
# Parses the given
|
97
|
+
# Parses the given code into an AST and associates the source code comments with it.
|
74
98
|
# This AST is then traversed by a TreeDresser which adorns the nodes in the AST
|
75
99
|
# with our SexpExtensions.
|
76
100
|
# Finally this AST is returned where each node is an anonymous subclass of Reek::AST::Node
|
@@ -78,7 +102,7 @@ module Reek
|
|
78
102
|
# Important to note is that Reek will not fail on unparseable files but rather register a
|
79
103
|
# parse error to @diagnostics and then just continue.
|
80
104
|
#
|
81
|
-
# Given this @
|
105
|
+
# Given this @code:
|
82
106
|
#
|
83
107
|
# # comment about C
|
84
108
|
# class C
|
@@ -99,33 +123,16 @@ module Reek
|
|
99
123
|
# where each node is possibly adorned with our SexpExtensions (see ast/ast_node_class_map
|
100
124
|
# and ast/sexp_extensions for details).
|
101
125
|
#
|
102
|
-
# @
|
103
|
-
#
|
104
|
-
|
105
|
-
# for the given source
|
106
|
-
# :reek:TooManyStatements { max_statements: 6 }
|
107
|
-
def parse(parser, source)
|
126
|
+
# @return [Anonymous subclass of Reek::AST::Node, Array] the AST presentation
|
127
|
+
# for the given code, List of diagnostics messages
|
128
|
+
def parse
|
108
129
|
buffer = Parser::Source::Buffer.new(origin, 1)
|
109
|
-
source
|
110
|
-
buffer.source = source
|
130
|
+
buffer.source = code
|
111
131
|
ast, comments = parser.parse_with_comments(buffer)
|
112
132
|
|
113
133
|
# See https://whitequark.github.io/parser/Parser/Source/Comment/Associator.html
|
114
134
|
comment_map = Parser::Source::Comment.associate(ast, comments)
|
115
|
-
TreeDresser.new.dress(ast, comment_map)
|
116
|
-
end
|
117
|
-
|
118
|
-
# :reek:TooManyStatements: { max_statements: 6 }
|
119
|
-
# :reek:FeatureEnvy
|
120
|
-
def default_parser
|
121
|
-
Parser::Ruby25.new(AST::Builder.new).tap do |parser|
|
122
|
-
diagnostics = parser.diagnostics
|
123
|
-
diagnostics.all_errors_are_fatal = false
|
124
|
-
diagnostics.ignore_warnings = false
|
125
|
-
diagnostics.consumer = lambda do |diagnostic|
|
126
|
-
@diagnostics << diagnostic
|
127
|
-
end
|
128
|
-
end
|
135
|
+
[TreeDresser.new.dress(ast, comment_map), parser.diagnostics.consumer.result]
|
129
136
|
end
|
130
137
|
end
|
131
138
|
end
|
data/lib/reek/version.rb
CHANGED
data/reek.gemspec
CHANGED
@@ -22,5 +22,5 @@ Gem::Specification.new do |s|
|
|
22
22
|
|
23
23
|
s.add_runtime_dependency 'codeclimate-engine-rb', '~> 0.4.0'
|
24
24
|
s.add_runtime_dependency 'parser', '< 2.6', '>= 2.5.0.0'
|
25
|
-
s.add_runtime_dependency 'rainbow', '
|
25
|
+
s.add_runtime_dependency 'rainbow', '>= 2.0', '< 4.0'
|
26
26
|
end
|
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: 4.8.
|
4
|
+
version: 4.8.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: 2018-
|
14
|
+
date: 2018-04-12 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: codeclimate-engine-rb
|
@@ -51,16 +51,22 @@ dependencies:
|
|
51
51
|
name: rainbow
|
52
52
|
requirement: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- - "
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '2.0'
|
57
|
+
- - "<"
|
55
58
|
- !ruby/object:Gem::Version
|
56
|
-
version: '
|
59
|
+
version: '4.0'
|
57
60
|
type: :runtime
|
58
61
|
prerelease: false
|
59
62
|
version_requirements: !ruby/object:Gem::Requirement
|
60
63
|
requirements:
|
61
|
-
- - "
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '2.0'
|
67
|
+
- - "<"
|
62
68
|
- !ruby/object:Gem::Version
|
63
|
-
version: '
|
69
|
+
version: '4.0'
|
64
70
|
description: Reek is a tool that examines Ruby classes, modules and methods and reports
|
65
71
|
any code smells it finds.
|
66
72
|
email:
|
@@ -447,7 +453,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
447
453
|
version: '0'
|
448
454
|
requirements: []
|
449
455
|
rubyforge_project:
|
450
|
-
rubygems_version: 2.
|
456
|
+
rubygems_version: 2.7.6
|
451
457
|
signing_key:
|
452
458
|
specification_version: 4
|
453
459
|
summary: Code smell detector for Ruby
|