rubocop-sorbet 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b73993245df905cf40d9e0dbc440d613315e5b32d89e9b61ee123994fee53e73
|
4
|
+
data.tar.gz: '019d4212c2c204492aa38f928ddfc31cceac5d79fe6ee09927c889e3b245f999'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d491ed5a48d75c2f5151329fc0018ca56ed57504d6d1e338befe0c9395bf85824b65f68164538667b4720eca216eeb15c29c6ed379524ae9ed1a8215cf6daf84
|
7
|
+
data.tar.gz: 7944aa4817f48ca0bb43c47dabcf197ced656674ab59ce261705b946045a2e3c0de813200187829cf9936a2144a5203ed625c8cdd89a33b7e80876229f7f2748
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rubocop-sorbet (0.4.
|
4
|
+
rubocop-sorbet (0.4.1)
|
5
5
|
rubocop
|
6
6
|
|
7
7
|
GEM
|
@@ -25,7 +25,7 @@ GEM
|
|
25
25
|
ast (~> 2.4.0)
|
26
26
|
procto (0.0.3)
|
27
27
|
rainbow (3.0.0)
|
28
|
-
rake (
|
28
|
+
rake (13.0.1)
|
29
29
|
regexp_parser (1.7.0)
|
30
30
|
rexml (3.2.4)
|
31
31
|
rspec (3.8.0)
|
@@ -71,7 +71,7 @@ PLATFORMS
|
|
71
71
|
ruby
|
72
72
|
|
73
73
|
DEPENDENCIES
|
74
|
-
rake (
|
74
|
+
rake (>= 12.3.3)
|
75
75
|
rspec
|
76
76
|
rubocop-shopify
|
77
77
|
rubocop-sorbet!
|
@@ -17,7 +17,7 @@ module RuboCop
|
|
17
17
|
# FooOrBar = T.type_alias { T.any(Foo, Bar) }
|
18
18
|
class BindingConstantWithoutTypeAlias < RuboCop::Cop::Cop
|
19
19
|
def_node_matcher(:binding_unaliased_type?, <<-PATTERN)
|
20
|
-
(casgn _ _ [#not_nil? #not_t_let? #method_needing_aliasing_on_t?])
|
20
|
+
(casgn _ _ [#not_nil? #not_t_let? #not_generic_parameter_decl? #method_needing_aliasing_on_t?])
|
21
21
|
PATTERN
|
22
22
|
|
23
23
|
def_node_matcher(:using_type_alias?, <<-PATTERN)
|
@@ -48,6 +48,12 @@ module RuboCop
|
|
48
48
|
)
|
49
49
|
PATTERN
|
50
50
|
|
51
|
+
def_node_matcher(:generic_parameter_decl?, <<-PATTERN)
|
52
|
+
(
|
53
|
+
send nil? {:type_template :type_member} ...
|
54
|
+
)
|
55
|
+
PATTERN
|
56
|
+
|
51
57
|
def_node_search(:method_needing_aliasing_on_t?, <<-PATTERN)
|
52
58
|
(
|
53
59
|
send
|
@@ -61,6 +67,10 @@ module RuboCop
|
|
61
67
|
!t_let?(node)
|
62
68
|
end
|
63
69
|
|
70
|
+
def not_generic_parameter_decl?(node)
|
71
|
+
!generic_parameter_decl?(node)
|
72
|
+
end
|
73
|
+
|
64
74
|
def not_nil?(node)
|
65
75
|
!node.nil?
|
66
76
|
end
|
@@ -55,9 +55,9 @@ module RuboCop
|
|
55
55
|
return nil unless can_autocorrect?
|
56
56
|
|
57
57
|
lambda do |corrector|
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
tree = call_chain(node_with_index_sends(node))
|
59
|
+
.sort_by { |call| ORDER[call.method_name] }
|
60
|
+
.reduce(nil) do |receiver, caller|
|
61
61
|
caller.updated(nil, [receiver] + caller.children.drop(1))
|
62
62
|
end
|
63
63
|
|
@@ -70,6 +70,16 @@ module RuboCop
|
|
70
70
|
|
71
71
|
private
|
72
72
|
|
73
|
+
def node_with_index_sends(node)
|
74
|
+
# This is really dirty hack to reparse the current node with index send
|
75
|
+
# emitting enabled, which is necessary to unparse them back as index accessors.
|
76
|
+
emit_index_value = RuboCop::AST::Builder.emit_index
|
77
|
+
RuboCop::AST::Builder.emit_index = true
|
78
|
+
RuboCop::AST::ProcessedSource.new(node.source, target_ruby_version, processed_source.path).ast
|
79
|
+
ensure
|
80
|
+
RuboCop::AST::Builder.emit_index = emit_index_value
|
81
|
+
end
|
82
|
+
|
73
83
|
def can_autocorrect?
|
74
84
|
defined?(::Unparser)
|
75
85
|
end
|
data/service.yml
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-sorbet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ufuk Kayserilioglu
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date: 2020-
|
14
|
+
date: 2020-08-20 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rspec
|