rubocop-rbs_inline 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '00947d7a01908093d8cd62383b06d9b944b5b5f33de6f900c0e1d7397a780156'
|
|
4
|
+
data.tar.gz: 884446ced80f488bcd8397d5b9c9461e8c111564400a0b5fe89024b6d36c41eb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ef3cfff6c721505beb2de6f0f57cdafe776f0bec6dbeb8c175562738879a986e09b08ae0a9d4a11038d9e70beda1a453d426efb8b9566d9a0ffc65e097ac0847
|
|
7
|
+
data.tar.gz: 669626ab0e4a5a08630508ff99bef9c2d7f606a79edcfafd46746b173a2e44e67ac2e51b1a0857ceddb55005dfe66a9acd8741a1ac1737cb101c8a562a88c8ee
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.5.1 (2026-02-24)
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
- **Style/RbsInline/UntypedInstanceVariable**: No longer reports an offense for instance variables that are only read without being assigned in the class. Read-only references are excluded because the variable may be defined in a parent class, making it impossible to determine whether a type annotation is needed.
|
|
8
|
+
|
|
3
9
|
## 1.5.0 (2026-02-24)
|
|
4
10
|
|
|
5
11
|
### New Cops
|
|
@@ -11,11 +11,14 @@ module RuboCop
|
|
|
11
11
|
# Instance variables must either have a `# @rbs @ivar: Type` annotation
|
|
12
12
|
# or be covered by a typed `attr_reader/writer/accessor` declaration.
|
|
13
13
|
#
|
|
14
|
+
# Only instance variables that are **assigned** within the class/module are checked.
|
|
15
|
+
# Read-only references are ignored because the variable may be defined in a parent class.
|
|
16
|
+
#
|
|
14
17
|
# @example
|
|
15
18
|
# # bad
|
|
16
19
|
# class Foo
|
|
17
|
-
# def
|
|
18
|
-
# @baz
|
|
20
|
+
# def initialize
|
|
21
|
+
# @baz = 1
|
|
19
22
|
# end
|
|
20
23
|
# end
|
|
21
24
|
#
|
|
@@ -23,8 +26,8 @@ module RuboCop
|
|
|
23
26
|
# class Foo
|
|
24
27
|
# # @rbs @baz: Integer
|
|
25
28
|
#
|
|
26
|
-
# def
|
|
27
|
-
# @baz
|
|
29
|
+
# def initialize
|
|
30
|
+
# @baz = 1
|
|
28
31
|
# end
|
|
29
32
|
# end
|
|
30
33
|
#
|
|
@@ -32,6 +35,13 @@ module RuboCop
|
|
|
32
35
|
# class Foo
|
|
33
36
|
# attr_reader :baz #: Integer
|
|
34
37
|
#
|
|
38
|
+
# def initialize
|
|
39
|
+
# @baz = 1
|
|
40
|
+
# end
|
|
41
|
+
# end
|
|
42
|
+
#
|
|
43
|
+
# # good (only read, may be defined in parent class)
|
|
44
|
+
# class Foo
|
|
35
45
|
# def bar
|
|
36
46
|
# @baz
|
|
37
47
|
# end
|
|
@@ -46,7 +56,7 @@ module RuboCop
|
|
|
46
56
|
|
|
47
57
|
ATTR_METHODS = %i[attr_reader attr_writer attr_accessor].freeze
|
|
48
58
|
|
|
49
|
-
# @rbs! type scope = { typed_ivars: Set[Symbol],
|
|
59
|
+
# @rbs! type scope = { typed_ivars: Set[Symbol], assigned_ivars: Hash[Symbol, Parser::AST::Node] }
|
|
50
60
|
|
|
51
61
|
attr_reader :scope_stack #: Array[scope]
|
|
52
62
|
attr_reader :ivar_type_annotations #: Hash[Integer, Symbol]
|
|
@@ -81,13 +91,11 @@ module RuboCop
|
|
|
81
91
|
alias after_module after_class
|
|
82
92
|
|
|
83
93
|
# @rbs node: Parser::AST::Node
|
|
84
|
-
def
|
|
94
|
+
def on_ivasgn(node) #: void
|
|
85
95
|
name = node.children.first #: Symbol
|
|
86
|
-
current_scope[:
|
|
96
|
+
current_scope[:assigned_ivars][name] ||= node
|
|
87
97
|
end
|
|
88
98
|
|
|
89
|
-
alias on_ivasgn on_ivar
|
|
90
|
-
|
|
91
99
|
# @rbs node: Parser::AST::Node
|
|
92
100
|
def on_send(node) #: void
|
|
93
101
|
return unless attr_method?(node)
|
|
@@ -112,7 +120,7 @@ module RuboCop
|
|
|
112
120
|
end
|
|
113
121
|
|
|
114
122
|
def push_scope #: void
|
|
115
|
-
scope_stack.push({ typed_ivars: Set.new,
|
|
123
|
+
scope_stack.push({ typed_ivars: Set.new, assigned_ivars: {} })
|
|
116
124
|
end
|
|
117
125
|
|
|
118
126
|
def pop_scope #: void
|
|
@@ -143,7 +151,7 @@ module RuboCop
|
|
|
143
151
|
end
|
|
144
152
|
|
|
145
153
|
def report_offenses #: void
|
|
146
|
-
current_scope[:
|
|
154
|
+
current_scope[:assigned_ivars].each do |name, node|
|
|
147
155
|
next if current_scope[:typed_ivars].include?(name)
|
|
148
156
|
|
|
149
157
|
bare_name = name.to_s.delete_prefix('@')
|
|
@@ -9,11 +9,14 @@ module RuboCop
|
|
|
9
9
|
# Instance variables must either have a `# @rbs @ivar: Type` annotation
|
|
10
10
|
# or be covered by a typed `attr_reader/writer/accessor` declaration.
|
|
11
11
|
#
|
|
12
|
+
# Only instance variables that are **assigned** within the class/module are checked.
|
|
13
|
+
# Read-only references are ignored because the variable may be defined in a parent class.
|
|
14
|
+
#
|
|
12
15
|
# @example
|
|
13
16
|
# # bad
|
|
14
17
|
# class Foo
|
|
15
|
-
# def
|
|
16
|
-
# @baz
|
|
18
|
+
# def initialize
|
|
19
|
+
# @baz = 1
|
|
17
20
|
# end
|
|
18
21
|
# end
|
|
19
22
|
#
|
|
@@ -21,8 +24,8 @@ module RuboCop
|
|
|
21
24
|
# class Foo
|
|
22
25
|
# # @rbs @baz: Integer
|
|
23
26
|
#
|
|
24
|
-
# def
|
|
25
|
-
# @baz
|
|
27
|
+
# def initialize
|
|
28
|
+
# @baz = 1
|
|
26
29
|
# end
|
|
27
30
|
# end
|
|
28
31
|
#
|
|
@@ -30,6 +33,13 @@ module RuboCop
|
|
|
30
33
|
# class Foo
|
|
31
34
|
# attr_reader :baz #: Integer
|
|
32
35
|
#
|
|
36
|
+
# def initialize
|
|
37
|
+
# @baz = 1
|
|
38
|
+
# end
|
|
39
|
+
# end
|
|
40
|
+
#
|
|
41
|
+
# # good (only read, may be defined in parent class)
|
|
42
|
+
# class Foo
|
|
33
43
|
# def bar
|
|
34
44
|
# @baz
|
|
35
45
|
# end
|
|
@@ -43,7 +53,7 @@ module RuboCop
|
|
|
43
53
|
|
|
44
54
|
ATTR_METHODS: untyped
|
|
45
55
|
|
|
46
|
-
type scope = { typed_ivars: Set[Symbol],
|
|
56
|
+
type scope = { typed_ivars: Set[Symbol], assigned_ivars: Hash[Symbol, Parser::AST::Node] }
|
|
47
57
|
|
|
48
58
|
attr_reader scope_stack: Array[scope]
|
|
49
59
|
|
|
@@ -64,9 +74,7 @@ module RuboCop
|
|
|
64
74
|
alias after_module after_class
|
|
65
75
|
|
|
66
76
|
# @rbs node: Parser::AST::Node
|
|
67
|
-
def
|
|
68
|
-
|
|
69
|
-
alias on_ivasgn on_ivar
|
|
77
|
+
def on_ivasgn: (Parser::AST::Node node) -> void
|
|
70
78
|
|
|
71
79
|
# @rbs node: Parser::AST::Node
|
|
72
80
|
def on_send: (Parser::AST::Node node) -> void
|