rubocop-erb 0.5.3 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -5
- data/config/default.yml +1 -1
- data/gemfiles/ruby_2.7.gemfile.lock +1 -1
- data/lib/rubocop/erb/processed_source_builder.rb +55 -0
- data/lib/rubocop/erb/ruby_extractor.rb +4 -5
- data/lib/rubocop/erb/version.rb +1 -1
- data/lib/rubocop/erb/when_decomposer.rb +7 -6
- data/lib/rubocop/erb.rb +1 -1
- metadata +3 -3
- data/lib/rubocop/erb/processed_source_helper.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49341b04ccc3098029bdd8f9b98b961825328a46623797e1a544e3264f16768b
|
4
|
+
data.tar.gz: eac652e2b1a040701290af19e4cded60a4cd53aa2849bc2aa5d1c9ddfefe7fee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3dd34349dc3eeea3925ad0b0d789e89efabc1ce0120f80ef64298e1b2b8b548936be1f7e4d10b7b2569a36685cc10170af706eeb3d982c08ac1d5638979e90c
|
7
|
+
data.tar.gz: 7705cb8f5537d18855c89e431fe40489f002a2c9a104b5662fa7bf20e967c23ae549507c42649819360180d1ee792b9980432b810ea1e17f4feb73d3b477f747
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rubocop-erb (0.5.
|
4
|
+
rubocop-erb (0.5.5)
|
5
5
|
better_html
|
6
6
|
rubocop (~> 1.45)
|
7
7
|
|
@@ -45,12 +45,12 @@ GEM
|
|
45
45
|
concurrent-ruby (~> 1.0)
|
46
46
|
json (2.7.2)
|
47
47
|
language_server-protocol (3.17.0.3)
|
48
|
-
loofah (2.
|
48
|
+
loofah (2.23.1)
|
49
49
|
crass (~> 1.0.2)
|
50
50
|
nokogiri (>= 1.12.0)
|
51
51
|
minitest (5.24.1)
|
52
52
|
mutex_m (0.2.0)
|
53
|
-
nokogiri (1.16.
|
53
|
+
nokogiri (1.16.8-x86_64-linux)
|
54
54
|
racc (~> 1.4)
|
55
55
|
parallel (1.25.1)
|
56
56
|
parser (3.3.4.0)
|
@@ -62,9 +62,9 @@ GEM
|
|
62
62
|
activesupport (>= 5.0.0)
|
63
63
|
minitest
|
64
64
|
nokogiri (>= 1.6)
|
65
|
-
rails-html-sanitizer (1.6.
|
65
|
+
rails-html-sanitizer (1.6.1)
|
66
66
|
loofah (~> 2.21)
|
67
|
-
nokogiri (
|
67
|
+
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
68
68
|
rainbow (3.1.1)
|
69
69
|
rake (13.2.1)
|
70
70
|
regexp_parser (2.9.2)
|
data/config/default.yml
CHANGED
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Erb
|
5
|
+
class ProcessedSourceBuilder
|
6
|
+
class << self
|
7
|
+
# Creates a new ProcessedSource, inheriting state from a donor.
|
8
|
+
#
|
9
|
+
# @param [String] code
|
10
|
+
# @param [RuboCop::ProcessedSource] processed_source
|
11
|
+
# @return [RuboCop::ProcessedSource]
|
12
|
+
def call(
|
13
|
+
code:,
|
14
|
+
processed_source:
|
15
|
+
)
|
16
|
+
new(
|
17
|
+
code: code,
|
18
|
+
processed_source: processed_source
|
19
|
+
).call
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize(
|
24
|
+
code:,
|
25
|
+
processed_source:
|
26
|
+
)
|
27
|
+
@code = code
|
28
|
+
@processed_source = processed_source
|
29
|
+
end
|
30
|
+
|
31
|
+
def call
|
32
|
+
new_processed_source = ::RuboCop::ProcessedSource.new(
|
33
|
+
@code,
|
34
|
+
@processed_source.ruby_version,
|
35
|
+
@processed_source.path,
|
36
|
+
**keyword_arguments
|
37
|
+
)
|
38
|
+
new_processed_source.config = @processed_source.config
|
39
|
+
new_processed_source.registry = @processed_source.registry
|
40
|
+
new_processed_source
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
# @return [Hash]
|
46
|
+
def keyword_arguments
|
47
|
+
if @processed_source.respond_to?(:parser_engine)
|
48
|
+
{ parser_engine: @processed_source.parser_engine }
|
49
|
+
else
|
50
|
+
{}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -28,10 +28,9 @@ module RuboCop
|
|
28
28
|
ruby_clips.map do |ruby_clip|
|
29
29
|
{
|
30
30
|
offset: ruby_clip.offset,
|
31
|
-
processed_source:
|
32
|
-
|
33
|
-
|
34
|
-
ruby_clip.code
|
31
|
+
processed_source: ProcessedSourceBuilder.call(
|
32
|
+
code: ruby_clip.code,
|
33
|
+
processed_source: @processed_source
|
35
34
|
)
|
36
35
|
}
|
37
36
|
end
|
@@ -63,7 +62,7 @@ module RuboCop
|
|
63
62
|
def root
|
64
63
|
::BetterHtml::Parser.new(
|
65
64
|
::Parser::Source::Buffer.new(
|
66
|
-
|
65
|
+
file_path,
|
67
66
|
source: template_source
|
68
67
|
),
|
69
68
|
template_language: :html
|
data/lib/rubocop/erb/version.rb
CHANGED
@@ -37,13 +37,15 @@ module RuboCop
|
|
37
37
|
if match_data
|
38
38
|
offset = match_data[0].length
|
39
39
|
condition = @ruby_clip.code[offset..].sub(/[ \t]then(?:[ \t].*)?/, '')
|
40
|
-
parse(
|
40
|
+
nodes = parse(
|
41
41
|
<<~RUBY
|
42
42
|
[
|
43
43
|
#{condition}
|
44
44
|
]
|
45
45
|
RUBY
|
46
|
-
)
|
46
|
+
)&.children || []
|
47
|
+
|
48
|
+
nodes.map do |child|
|
47
49
|
RubyClip.new(
|
48
50
|
code: child.location.expression.source,
|
49
51
|
offset: @ruby_clip.offset + offset + child.location.expression.begin_pos - 4
|
@@ -59,10 +61,9 @@ module RuboCop
|
|
59
61
|
# @param [String] source
|
60
62
|
# @return [RuboCop::AST::Node]
|
61
63
|
def parse(source)
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
source
|
64
|
+
ProcessedSourceBuilder.call(
|
65
|
+
code: source,
|
66
|
+
processed_source: @processed_source
|
66
67
|
).ast
|
67
68
|
end
|
68
69
|
end
|
data/lib/rubocop/erb.rb
CHANGED
@@ -4,7 +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 :
|
7
|
+
autoload :ProcessedSourceBuilder, 'rubocop/erb/processed_source_builder'
|
8
8
|
autoload :RubyClip, 'rubocop/erb/ruby_clip'
|
9
9
|
autoload :RubyExtractor, 'rubocop/erb/ruby_extractor'
|
10
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.5
|
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-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: better_html
|
@@ -59,7 +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/
|
62
|
+
- lib/rubocop/erb/processed_source_builder.rb
|
63
63
|
- lib/rubocop/erb/rubocop_extension.rb
|
64
64
|
- lib/rubocop/erb/ruby_clip.rb
|
65
65
|
- lib/rubocop/erb/ruby_extractor.rb
|
@@ -1,33 +0,0 @@
|
|
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
|