rubocop-slim 0.2.6 → 0.2.8
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/config/default.yml +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: 6cc13d20db409e4be47e6572f26316aa1f769a2075e3e467aea4da80264376c0
|
4
|
+
data.tar.gz: e8c6412e4601f6959723ffb5aaecc00cb54a5ab57af01245a0b5009aec652e1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ccaa0d63a42c0b5dc73ce7d91b43c56793300c913c1b45a9534a6caba6b08912abc6fb2e677ac9b5eb97c0231d737141970df7a5ab91b17164d1bec067318fa
|
7
|
+
data.tar.gz: 894a0ddcda52e388bb88a5d7c29dfbf142fd94900e73ef3bd4ff79d72baae87c9689a6de41690482214ab4868f9d05429f966994541a882ed29b1bbca714892d
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rubocop-slim (0.2.
|
4
|
+
rubocop-slim (0.2.8)
|
5
5
|
rubocop (~> 1.45)
|
6
6
|
slimi (~> 0.7)
|
7
7
|
|
@@ -81,7 +81,7 @@ GEM
|
|
81
81
|
tilt
|
82
82
|
strscan (3.1.0)
|
83
83
|
temple (0.10.3)
|
84
|
-
thor (1.3.
|
84
|
+
thor (1.3.2)
|
85
85
|
tilt (2.4.0)
|
86
86
|
tzinfo (2.0.6)
|
87
87
|
concurrent-ruby (~> 1.0)
|
data/config/default.yml
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.8
|
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-10-01 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
|