rubocop-erb 0.5.1 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +28 -32
- data/gemfiles/ruby_2.7.gemfile.lock +1 -1
- data/lib/rubocop/erb/keyword_remover.rb +1 -1
- data/lib/rubocop/erb/processed_source_helper.rb +33 -0
- data/lib/rubocop/erb/ruby_extractor.rb +6 -24
- data/lib/rubocop/erb/version.rb +1 -1
- data/lib/rubocop/erb/when_decomposer.rb +17 -14
- data/lib/rubocop/erb.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1650bd31cfedf2d62fc05f8979e290bf33b04b8b42a6988fbab36ddef75a113f
|
4
|
+
data.tar.gz: 44de0adbdc72ac2abb1cb49778989bb6266f6c91a5cfeffd428c2c83df9ec764
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '059b029c8a15edf705991b6e0acf4e7b31dbae52afd4c109afc04902cb4e3db353b0dc3cc2c6fdc0118a361be190b755b73dfa54472a0d85097e70192e0f4203'
|
7
|
+
data.tar.gz: 1d69a7428f7caee5cbcfad7d987ac49f0f38b28b16cb11888fe1aa66a6a827bf8528b178f86e3b395b195f24dd588d67dbea48121448d2d23952a443e3f398f3
|
data/Gemfile.lock
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rubocop-erb (0.5.
|
4
|
+
rubocop-erb (0.5.3)
|
5
5
|
better_html
|
6
6
|
rubocop (~> 1.45)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
actionview (7.1.3.
|
12
|
-
activesupport (= 7.1.3.
|
11
|
+
actionview (7.1.3.4)
|
12
|
+
activesupport (= 7.1.3.4)
|
13
13
|
builder (~> 3.1)
|
14
14
|
erubi (~> 1.11)
|
15
15
|
rails-dom-testing (~> 2.2)
|
16
16
|
rails-html-sanitizer (~> 1.6)
|
17
|
-
activesupport (7.1.3.
|
17
|
+
activesupport (7.1.3.4)
|
18
18
|
base64
|
19
19
|
bigdecimal
|
20
20
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
@@ -33,31 +33,31 @@ GEM
|
|
33
33
|
erubi (~> 1.4)
|
34
34
|
parser (>= 2.4)
|
35
35
|
smart_properties
|
36
|
-
bigdecimal (3.1.
|
36
|
+
bigdecimal (3.1.8)
|
37
37
|
builder (3.3.0)
|
38
|
-
concurrent-ruby (1.
|
38
|
+
concurrent-ruby (1.3.3)
|
39
39
|
connection_pool (2.4.1)
|
40
40
|
crass (1.0.6)
|
41
41
|
diff-lcs (1.5.1)
|
42
42
|
drb (2.2.1)
|
43
43
|
erubi (1.13.0)
|
44
|
-
i18n (1.14.
|
44
|
+
i18n (1.14.5)
|
45
45
|
concurrent-ruby (~> 1.0)
|
46
|
-
json (2.7.
|
46
|
+
json (2.7.2)
|
47
47
|
language_server-protocol (3.17.0.3)
|
48
48
|
loofah (2.22.0)
|
49
49
|
crass (~> 1.0.2)
|
50
50
|
nokogiri (>= 1.12.0)
|
51
|
-
minitest (5.
|
51
|
+
minitest (5.24.1)
|
52
52
|
mutex_m (0.2.0)
|
53
|
-
nokogiri (1.16.
|
53
|
+
nokogiri (1.16.7-x86_64-linux)
|
54
54
|
racc (~> 1.4)
|
55
|
-
parallel (1.
|
56
|
-
parser (3.3.0
|
55
|
+
parallel (1.25.1)
|
56
|
+
parser (3.3.4.0)
|
57
57
|
ast (~> 2.4.1)
|
58
58
|
racc
|
59
|
-
prism (0.
|
60
|
-
racc (1.
|
59
|
+
prism (0.30.0)
|
60
|
+
racc (1.8.1)
|
61
61
|
rails-dom-testing (2.2.0)
|
62
62
|
activesupport (>= 5.0.0)
|
63
63
|
minitest
|
@@ -66,50 +66,46 @@ GEM
|
|
66
66
|
loofah (~> 2.21)
|
67
67
|
nokogiri (~> 1.14)
|
68
68
|
rainbow (3.1.1)
|
69
|
-
rake (13.1
|
70
|
-
regexp_parser (2.9.
|
71
|
-
rexml (3.
|
69
|
+
rake (13.2.1)
|
70
|
+
regexp_parser (2.9.2)
|
71
|
+
rexml (3.3.4)
|
72
|
+
strscan
|
72
73
|
rspec (3.13.0)
|
73
74
|
rspec-core (~> 3.13.0)
|
74
75
|
rspec-expectations (~> 3.13.0)
|
75
76
|
rspec-mocks (~> 3.13.0)
|
76
77
|
rspec-core (3.13.0)
|
77
78
|
rspec-support (~> 3.13.0)
|
78
|
-
rspec-expectations (3.13.
|
79
|
+
rspec-expectations (3.13.1)
|
79
80
|
diff-lcs (>= 1.2.0, < 2.0)
|
80
81
|
rspec-support (~> 3.13.0)
|
81
|
-
rspec-mocks (3.13.
|
82
|
+
rspec-mocks (3.13.1)
|
82
83
|
diff-lcs (>= 1.2.0, < 2.0)
|
83
84
|
rspec-support (~> 3.13.0)
|
84
85
|
rspec-support (3.13.1)
|
85
|
-
rubocop (1.
|
86
|
+
rubocop (1.65.1)
|
86
87
|
json (~> 2.3)
|
87
88
|
language_server-protocol (>= 3.17.0)
|
88
89
|
parallel (~> 1.10)
|
89
90
|
parser (>= 3.3.0.2)
|
90
91
|
rainbow (>= 2.2.2, < 4.0)
|
91
|
-
regexp_parser (>=
|
92
|
+
regexp_parser (>= 2.4, < 3.0)
|
92
93
|
rexml (>= 3.2.5, < 4.0)
|
93
94
|
rubocop-ast (>= 1.31.1, < 2.0)
|
94
95
|
ruby-progressbar (~> 1.7)
|
95
96
|
unicode-display_width (>= 2.4.0, < 3.0)
|
96
|
-
rubocop-ast (1.
|
97
|
-
parser (>= 3.3.0
|
98
|
-
rubocop-capybara (2.20.0)
|
99
|
-
rubocop (~> 1.41)
|
100
|
-
rubocop-factory_bot (2.25.1)
|
101
|
-
rubocop (~> 1.41)
|
97
|
+
rubocop-ast (1.32.0)
|
98
|
+
parser (>= 3.3.1.0)
|
102
99
|
rubocop-rake (0.6.0)
|
103
100
|
rubocop (~> 1.0)
|
104
|
-
rubocop-rspec (
|
105
|
-
rubocop (~> 1.
|
106
|
-
rubocop-capybara (~> 2.17)
|
107
|
-
rubocop-factory_bot (~> 2.22)
|
101
|
+
rubocop-rspec (3.0.4)
|
102
|
+
rubocop (~> 1.61)
|
108
103
|
ruby-progressbar (1.13.0)
|
109
|
-
sevencop (0.
|
104
|
+
sevencop (0.43.1)
|
110
105
|
activesupport
|
111
106
|
rubocop
|
112
107
|
smart_properties (1.17.0)
|
108
|
+
strscan (3.1.0)
|
113
109
|
tzinfo (2.0.6)
|
114
110
|
concurrent-ruby (~> 1.0)
|
115
111
|
unicode-display_width (2.5.0)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Erb
|
5
|
+
module ProcessedSourceHelper
|
6
|
+
# Creates a new ProcessedSource, inheriting state from a donor
|
7
|
+
#
|
8
|
+
# @param [RuboCop::ProcessedSource] input_processed_source
|
9
|
+
# @param [String] code
|
10
|
+
# @return [RuboCop::ProcessedSource]
|
11
|
+
def self.code_to_processed_source(input_processed_source, path, code)
|
12
|
+
supports_prism = input_processed_source.respond_to?(:parser_engine)
|
13
|
+
processed_source = if supports_prism
|
14
|
+
::RuboCop::ProcessedSource.new(
|
15
|
+
code,
|
16
|
+
input_processed_source.ruby_version,
|
17
|
+
path,
|
18
|
+
parser_engine: input_processed_source.parser_engine
|
19
|
+
)
|
20
|
+
else
|
21
|
+
::RuboCop::ProcessedSource.new(
|
22
|
+
code,
|
23
|
+
input_processed_source.ruby_version,
|
24
|
+
path
|
25
|
+
)
|
26
|
+
end
|
27
|
+
processed_source.config = input_processed_source.config
|
28
|
+
processed_source.registry = input_processed_source.registry
|
29
|
+
processed_source
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -28,7 +28,11 @@ module RuboCop
|
|
28
28
|
ruby_clips.map do |ruby_clip|
|
29
29
|
{
|
30
30
|
offset: ruby_clip.offset,
|
31
|
-
processed_source:
|
31
|
+
processed_source: ProcessedSourceHelper.code_to_processed_source(
|
32
|
+
@processed_source,
|
33
|
+
file_path,
|
34
|
+
ruby_clip.code
|
35
|
+
)
|
32
36
|
}
|
33
37
|
end
|
34
38
|
end
|
@@ -66,28 +70,6 @@ module RuboCop
|
|
66
70
|
).ast
|
67
71
|
end
|
68
72
|
|
69
|
-
# @return [RuboCop::ProcessedSource]
|
70
|
-
def ruby_clip_to_processed_source(ruby_clip)
|
71
|
-
supports_prism = @processed_source.respond_to?(:parser_engine)
|
72
|
-
processed_source = if supports_prism
|
73
|
-
::RuboCop::ProcessedSource.new(
|
74
|
-
ruby_clip.code,
|
75
|
-
@processed_source.ruby_version,
|
76
|
-
file_path,
|
77
|
-
parser_engine: @processed_source.parser_engine
|
78
|
-
)
|
79
|
-
else
|
80
|
-
::RuboCop::ProcessedSource.new(
|
81
|
-
ruby_clip.code,
|
82
|
-
@processed_source.ruby_version,
|
83
|
-
file_path
|
84
|
-
)
|
85
|
-
end
|
86
|
-
processed_source.config = @processed_source.config
|
87
|
-
processed_source.registry = @processed_source.registry
|
88
|
-
processed_source
|
89
|
-
end
|
90
|
-
|
91
73
|
# @return [Array<RuboCop::Erb::RubyClip>]
|
92
74
|
def ruby_clips
|
93
75
|
nodes.map do |node|
|
@@ -96,7 +78,7 @@ module RuboCop
|
|
96
78
|
offset: node.location.begin_pos
|
97
79
|
)
|
98
80
|
end.flat_map do |ruby_clip|
|
99
|
-
WhenDecomposer.call(ruby_clip)
|
81
|
+
WhenDecomposer.call(@processed_source, ruby_clip)
|
100
82
|
end.map do |ruby_clip|
|
101
83
|
KeywordRemover.call(ruby_clip)
|
102
84
|
end.reject do |ruby_clip|
|
data/lib/rubocop/erb/version.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'parser/current'
|
4
|
-
require 'rubocop/ast/builder'
|
5
|
-
|
6
3
|
module RuboCop
|
7
4
|
module Erb
|
8
5
|
class WhenDecomposer
|
@@ -13,15 +10,24 @@ module RuboCop
|
|
13
10
|
/x.freeze
|
14
11
|
|
15
12
|
class << self
|
13
|
+
# @param [RuboCop::ProcessedSource] processed_source
|
16
14
|
# @param [RuboCop::Erb::RubyClip] ruby_clip
|
17
15
|
# @return [Array<RuboCop::Erb::RubyClip>]
|
18
|
-
def call(
|
19
|
-
|
16
|
+
def call(
|
17
|
+
processed_source,
|
18
|
+
ruby_clip
|
19
|
+
)
|
20
|
+
new(processed_source, ruby_clip).call
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
24
|
+
# @param [RuboCop::ProcessedSource] processed_source
|
23
25
|
# @param [RuboCop::Erb::RubyClip] ruby_clip
|
24
|
-
def initialize(
|
26
|
+
def initialize(
|
27
|
+
processed_source,
|
28
|
+
ruby_clip
|
29
|
+
)
|
30
|
+
@processed_source = processed_source
|
25
31
|
@ruby_clip = ruby_clip
|
26
32
|
end
|
27
33
|
|
@@ -53,14 +59,11 @@ module RuboCop
|
|
53
59
|
# @param [String] source
|
54
60
|
# @return [RuboCop::AST::Node]
|
55
61
|
def parse(source)
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
source: source
|
62
|
-
)
|
63
|
-
)
|
62
|
+
ProcessedSourceHelper.code_to_processed_source(
|
63
|
+
@processed_source,
|
64
|
+
'(string)',
|
65
|
+
source
|
66
|
+
).ast
|
64
67
|
end
|
65
68
|
end
|
66
69
|
end
|
data/lib/rubocop/erb.rb
CHANGED
@@ -4,6 +4,7 @@ module RuboCop
|
|
4
4
|
module Erb
|
5
5
|
autoload :ConfigLoader, 'rubocop/erb/config_loader'
|
6
6
|
autoload :KeywordRemover, 'rubocop/erb/keyword_remover'
|
7
|
+
autoload :ProcessedSourceHelper, 'rubocop/erb/processed_source_helper'
|
7
8
|
autoload :RubyClip, 'rubocop/erb/ruby_clip'
|
8
9
|
autoload :RubyExtractor, 'rubocop/erb/ruby_extractor'
|
9
10
|
autoload :WhenDecomposer, 'rubocop/erb/when_decomposer'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-erb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: better_html
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- lib/rubocop/erb.rb
|
60
60
|
- lib/rubocop/erb/config_loader.rb
|
61
61
|
- lib/rubocop/erb/keyword_remover.rb
|
62
|
+
- lib/rubocop/erb/processed_source_helper.rb
|
62
63
|
- lib/rubocop/erb/rubocop_extension.rb
|
63
64
|
- lib/rubocop/erb/ruby_clip.rb
|
64
65
|
- lib/rubocop/erb/ruby_extractor.rb
|