rubocop-slim 0.2.5 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/rubocop/slim/keyword_remover.rb +1 -1
- data/lib/rubocop/slim/processed_source_builder.rb +55 -0
- data/lib/rubocop/slim/ruby_extractor.rb +5 -9
- data/lib/rubocop/slim/version.rb +1 -1
- data/lib/rubocop/slim/when_decomposer.rb +19 -14
- data/lib/rubocop/slim.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: 9947f37c94fc6e24e579dc86a7803631a5634f84de00542747d7704705567233
|
4
|
+
data.tar.gz: e807279fde8021198b37d5964903892aa3106d47b594a03bb1ed8a3ad7ce1c2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: deae8bef3a1c84680ad008c42b5bf7ae299c0b1a21b7527eb6710b4c6bdd1e36d91f70ce30b053e510c0a4dfbe9e68e271e69f962da4a12288c0b2c026707984
|
7
|
+
data.tar.gz: eb7293ff3fc3954ad085af8687f642e7a60349bcb11ff2754af46d77e76083efd4025712a2234ec68d7ca3a8ff280dcf521b713e9a90d336094d9f2536568efb
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Slim
|
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
|
@@ -25,16 +25,12 @@ module RuboCop
|
|
25
25
|
return unless supported_file_path_pattern?
|
26
26
|
|
27
27
|
ruby_clips.map do |ruby_clip|
|
28
|
-
processed_source = ::RuboCop::ProcessedSource.new(
|
29
|
-
ruby_clip.code,
|
30
|
-
@processed_source.ruby_version,
|
31
|
-
file_path
|
32
|
-
)
|
33
|
-
processed_source.config = @processed_source.config
|
34
|
-
processed_source.registry = @processed_source.registry
|
35
28
|
{
|
36
29
|
offset: ruby_clip.offset,
|
37
|
-
processed_source:
|
30
|
+
processed_source: ProcessedSourceBuilder.call(
|
31
|
+
code: ruby_clip.code,
|
32
|
+
processed_source: @processed_source
|
33
|
+
)
|
38
34
|
}
|
39
35
|
end
|
40
36
|
end
|
@@ -61,7 +57,7 @@ module RuboCop
|
|
61
57
|
offset: begin_
|
62
58
|
)
|
63
59
|
end.flat_map do |ruby_clip|
|
64
|
-
WhenDecomposer.call(ruby_clip)
|
60
|
+
WhenDecomposer.call(@processed_source, ruby_clip)
|
65
61
|
end.map do |ruby_clip|
|
66
62
|
KeywordRemover.call(ruby_clip)
|
67
63
|
end
|
data/lib/rubocop/slim/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 Slim
|
8
5
|
class WhenDecomposer
|
@@ -13,15 +10,27 @@ module RuboCop
|
|
13
10
|
/x.freeze
|
14
11
|
|
15
12
|
class << self
|
13
|
+
# @param [RuboCop::ProcessedSource] processed_source
|
16
14
|
# @param [RuboCop::Slim::RubyClip] ruby_clip
|
17
15
|
# @return [Array<RuboCop::Slim::RubyClip>]
|
18
|
-
def call(
|
19
|
-
|
16
|
+
def call(
|
17
|
+
processed_source,
|
18
|
+
ruby_clip
|
19
|
+
)
|
20
|
+
new(
|
21
|
+
processed_source,
|
22
|
+
ruby_clip
|
23
|
+
).call
|
20
24
|
end
|
21
25
|
end
|
22
26
|
|
27
|
+
# @param [RuboCop::ProcessedSource] processed_source
|
23
28
|
# @param [RuboCop::Slim::RubyClip] ruby_clip
|
24
|
-
def initialize(
|
29
|
+
def initialize(
|
30
|
+
processed_source,
|
31
|
+
ruby_clip
|
32
|
+
)
|
33
|
+
@processed_source = processed_source
|
25
34
|
@ruby_clip = ruby_clip
|
26
35
|
end
|
27
36
|
|
@@ -53,14 +62,10 @@ module RuboCop
|
|
53
62
|
# @param [String] source
|
54
63
|
# @return [RuboCop::AST::Node]
|
55
64
|
def parse(source)
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
'(string)',
|
61
|
-
source: source
|
62
|
-
)
|
63
|
-
)
|
65
|
+
ProcessedSourceBuilder.call(
|
66
|
+
code: source,
|
67
|
+
processed_source: @processed_source
|
68
|
+
).ast
|
64
69
|
end
|
65
70
|
end
|
66
71
|
end
|
data/lib/rubocop/slim.rb
CHANGED
@@ -4,6 +4,7 @@ module RuboCop
|
|
4
4
|
module Slim
|
5
5
|
autoload :ConfigLoader, 'rubocop/slim/config_loader'
|
6
6
|
autoload :KeywordRemover, 'rubocop/slim/keyword_remover'
|
7
|
+
autoload :ProcessedSourceBuilder, 'rubocop/slim/processed_source_builder'
|
7
8
|
autoload :RubyClip, 'rubocop/slim/ruby_clip'
|
8
9
|
autoload :RubyExtractor, 'rubocop/slim/ruby_extractor'
|
9
10
|
autoload :WhenDecomposer, 'rubocop/slim/when_decomposer'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-slim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
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: rubocop
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- lib/rubocop/slim.rb
|
59
59
|
- lib/rubocop/slim/config_loader.rb
|
60
60
|
- lib/rubocop/slim/keyword_remover.rb
|
61
|
+
- lib/rubocop/slim/processed_source_builder.rb
|
61
62
|
- lib/rubocop/slim/rubocop_extension.rb
|
62
63
|
- lib/rubocop/slim/ruby_clip.rb
|
63
64
|
- lib/rubocop/slim/ruby_extractor.rb
|