rubocop-on-rbs 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/config/default.yml +21 -1
- data/lib/rubocop/cop/rbs/layout/comment_indentation.rb +0 -4
- data/lib/rubocop/cop/rbs/layout/space_after_comma.rb +35 -0
- data/lib/rubocop/cop/rbs/layout/space_around_arrow.rb +9 -0
- data/lib/rubocop/cop/rbs/layout/space_around_operators.rb +11 -3
- data/lib/rubocop/cop/rbs/lint/ambiguous_keyword_argument_key.rb +62 -0
- data/lib/rubocop/cop/rbs/lint/ambiguous_operator_precedence.rb +1 -0
- data/lib/rubocop/cop/rbs/lint/literal_intersection.rb +1 -0
- data/lib/rubocop/cop/rbs/lint/top_level_interface.rb +1 -0
- data/lib/rubocop/cop/rbs/lint/top_level_type_alias.rb +1 -0
- data/lib/rubocop/cop/rbs/lint/{useless_overload_type_params.rb → unused_overload_type_params.rb} +3 -3
- data/lib/rubocop/cop/rbs/lint/unused_type_alias_type_params.rb +59 -0
- data/lib/rubocop/cop/rbs/style/class_with_singleton.rb +48 -0
- data/lib/rubocop/cop/rbs/style/classic_type.rb +8 -0
- data/lib/rubocop/cop/rbs/style/empty_argument.rb +1 -0
- data/lib/rubocop/cop/rbs/style/instance_with_instance.rb +57 -0
- data/lib/rubocop/cop/rbs/style/redundant_parentheses.rb +1 -0
- data/lib/rubocop/cop/rbs_cops.rb +6 -1
- data/lib/rubocop/rbs/cop_base.rb +3 -0
- data/lib/rubocop/rbs/processed_rbs_source.rb +2 -6
- data/lib/rubocop/rbs/version.rb +1 -1
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79ae2335c1cd8ea94cf1e5003b058c1c7d00966f3cc790a0410b3494e7c94ee4
|
4
|
+
data.tar.gz: 4c6697e0dc3ee2b0724bfe34505539608adfb76ae4733781a3d5195dfbc0917e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0530b33a2394b966e88784add6936f79631ee8b9f9d81019c265273c73d33719d1e65553e75b2c320f45a8a8c40d8d01b225cbe0f94096bdd0700ae3a281dfc3
|
7
|
+
data.tar.gz: f20537912b6b4fcd8fff9d24da715c6abfae186957c3464fa7989bbc9ae2565d9478cb410436e59e1da3ee1c9a1b50b7070602b82f9dda88abb0f1b99b01731c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [1.2.0] - 2024-11-18
|
4
|
+
|
5
|
+
* Fix false positive when oneline class by @ksss in https://github.com/ksss/rubocop-on-rbs/pull/41
|
6
|
+
* Add RBS/Lint/TopLevelTypeAlias by @ksss in https://github.com/ksss/rubocop-on-rbs/pull/46
|
7
|
+
* Add RBS/Lint/TopLevelInterface by @ksss in https://github.com/ksss/rubocop-on-rbs/pull/47
|
8
|
+
* [RBS/Lint/TopLevelTypeAlias] Fix false positive by @ksss in https://github.com/ksss/rubocop-on-rbs/pull/48
|
9
|
+
* Bundle update by @ksss in https://github.com/ksss/rubocop-on-rbs/pull/49
|
10
|
+
|
3
11
|
## [1.1.0] - 2024-10-01
|
4
12
|
|
5
13
|
* Add RBS/Layout/EmptyLinesAroundAccessModifier by @ksss in https://github.com/ksss/rubocop-on-rbs/pull/39
|
data/config/default.yml
CHANGED
@@ -71,6 +71,10 @@ RBS/Layout/OverloadIndentation:
|
|
71
71
|
Description: 'Indent overload method'
|
72
72
|
Enabled: true
|
73
73
|
|
74
|
+
RBS/Layout/SpaceAfterComma:
|
75
|
+
Description: 'Use space after `,`'
|
76
|
+
Enabled: true
|
77
|
+
|
74
78
|
RBS/Layout/SpaceAroundArrow:
|
75
79
|
Description: 'Use space around `->`'
|
76
80
|
Enabled: true
|
@@ -101,6 +105,10 @@ RBS/Lint:
|
|
101
105
|
Severity: warning
|
102
106
|
Enabled: true
|
103
107
|
|
108
|
+
RBS/Lint/AmbiguousKeywordArgumentKey:
|
109
|
+
Description: 'Check ambiguous keyword argument key'
|
110
|
+
Enabled: true
|
111
|
+
|
104
112
|
RBS/Lint/AmbiguousOperatorPrecedence:
|
105
113
|
Description: 'Check ambiguous operator precedence'
|
106
114
|
Enabled: true
|
@@ -133,10 +141,14 @@ RBS/Lint/UselessAccessModifier:
|
|
133
141
|
Description: 'Check useless access modifier'
|
134
142
|
Enabled: true
|
135
143
|
|
136
|
-
RBS/Lint/
|
144
|
+
RBS/Lint/UnusedOverloadTypeParams:
|
137
145
|
Description: 'Check redundant overload type params'
|
138
146
|
Enabled: true
|
139
147
|
|
148
|
+
RBS/Lint/UnusedTypeAliasTypeParams:
|
149
|
+
Description: 'Check redundant type alias type params'
|
150
|
+
Enabled: true
|
151
|
+
|
140
152
|
RBS/Lint/WillSyntaxError:
|
141
153
|
Description: 'Check RBS will syntax error'
|
142
154
|
Enabled: true
|
@@ -150,6 +162,10 @@ RBS/Style/BlockReturnBoolish:
|
|
150
162
|
Description: 'Use `bool` for block return type'
|
151
163
|
Enabled: true
|
152
164
|
|
165
|
+
RBS/Style/ClassWithSingleton:
|
166
|
+
Description: 'Check `class` with singleton context'
|
167
|
+
Enabled: pending
|
168
|
+
|
153
169
|
RBS/Style/ClassicType:
|
154
170
|
Description: 'Use simple type'
|
155
171
|
Enabled: true
|
@@ -166,6 +182,10 @@ RBS/Style/InitializeReturnType:
|
|
166
182
|
Description: 'Use `void` for initialize method'
|
167
183
|
Enabled: true
|
168
184
|
|
185
|
+
RBS/Style/InstanceWithInstance:
|
186
|
+
Description: 'Check `instance` with instance context'
|
187
|
+
Enabled: pending
|
188
|
+
|
169
189
|
RBS/Style/OptionalNil:
|
170
190
|
Description: 'Use nil instead of nil?'
|
171
191
|
Enabled: true
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module RBS
|
6
|
+
module Layout
|
7
|
+
# @example default
|
8
|
+
# # bad
|
9
|
+
# def foo: (Integer,String) -> void
|
10
|
+
#
|
11
|
+
# # good
|
12
|
+
# def foo: (Integer, String) -> void
|
13
|
+
class SpaceAfterComma < RuboCop::RBS::CopBase
|
14
|
+
extend AutoCorrector
|
15
|
+
|
16
|
+
MSG = 'Space missing after comma.'
|
17
|
+
|
18
|
+
def on_rbs_new_investigation
|
19
|
+
processed_rbs_source.tokens.each_cons(2) do |comma, after|
|
20
|
+
next unless comma.type == :pCOMMA
|
21
|
+
next unless comma.location
|
22
|
+
next unless comma.location.end_line == after.location.start_line
|
23
|
+
next unless after.type != :tTRIVIA
|
24
|
+
|
25
|
+
range = location_to_range(comma.location)
|
26
|
+
add_offense(range) do |corrector|
|
27
|
+
corrector.insert_after(range, ' ')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -33,6 +33,8 @@ module RuboCop
|
|
33
33
|
next unless loc
|
34
34
|
|
35
35
|
if before && (before.location.end_pos + 1 != loc.start_pos)
|
36
|
+
next unless before.location.end_line == loc.start_line
|
37
|
+
|
36
38
|
arrow = location_to_range(loc).adjust(begin_pos: base, end_pos: base)
|
37
39
|
add_offense(arrow, message: MSG_BEFORE) do |corrector|
|
38
40
|
range = range_between(before.location.end_pos, loc.start_pos)
|
@@ -41,6 +43,8 @@ module RuboCop
|
|
41
43
|
end
|
42
44
|
|
43
45
|
if loc.end_pos + 1 != after.location.start_pos
|
46
|
+
next unless loc.end_line == after.location.start_line
|
47
|
+
|
44
48
|
arrow = location_to_range(loc).adjust(begin_pos: base, end_pos: base)
|
45
49
|
add_offense(arrow, message: MSG_AFTER) do |corrector|
|
46
50
|
range = range_between(loc.end_pos, after.location.start_pos)
|
@@ -49,6 +53,11 @@ module RuboCop
|
|
49
53
|
end
|
50
54
|
end
|
51
55
|
end
|
56
|
+
alias on_rbs_constant on_rbs_def
|
57
|
+
alias on_rbs_global on_rbs_def
|
58
|
+
alias on_rbs_type_alias on_rbs_def
|
59
|
+
alias on_rbs_attribute on_rbs_def
|
60
|
+
alias on_rbs_var on_rbs_def
|
52
61
|
end
|
53
62
|
end
|
54
63
|
end
|
@@ -16,12 +16,20 @@ module RuboCop
|
|
16
16
|
def on_rbs_def(decl)
|
17
17
|
decl.overloads.each do |overload|
|
18
18
|
overload.method_type.each_type do |type|
|
19
|
-
|
19
|
+
check_type(type)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
24
|
+
def on_rbs_constant(decl)
|
25
|
+
check_type(decl.type)
|
26
|
+
end
|
27
|
+
alias on_rbs_global on_rbs_constant
|
28
|
+
alias on_rbs_type_alias on_rbs_constant
|
29
|
+
alias on_rbs_attribute on_rbs_constant
|
30
|
+
alias on_rbs_var on_rbs_constant
|
31
|
+
|
32
|
+
def check_type(type)
|
25
33
|
case type
|
26
34
|
when ::RBS::Types::Union
|
27
35
|
check_operator(type, '|')
|
@@ -29,7 +37,7 @@ module RuboCop
|
|
29
37
|
check_operator(type, '&')
|
30
38
|
end
|
31
39
|
type.each_type do |t|
|
32
|
-
|
40
|
+
check_type(t)
|
33
41
|
end
|
34
42
|
end
|
35
43
|
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module RBS
|
6
|
+
module Lint
|
7
|
+
# Checks keyword argument keys that are not local variable names.
|
8
|
+
#
|
9
|
+
# @example default
|
10
|
+
# # bad
|
11
|
+
# def foo: (option?: bool, option!: bool, Option: bool) -> void
|
12
|
+
#
|
13
|
+
class AmbiguousKeywordArgumentKey < RuboCop::RBS::CopBase
|
14
|
+
extend AutoCorrector
|
15
|
+
|
16
|
+
# @rbs decl: ::RBS::AST::Members::MethodDefinition
|
17
|
+
def on_rbs_def(decl)
|
18
|
+
decl.overloads.each do |overload|
|
19
|
+
func = overload.method_type.type
|
20
|
+
next unless func.kind_of?(::RBS::Types::Function)
|
21
|
+
next unless !func.required_keywords.empty? || !func.optional_keywords.empty?
|
22
|
+
|
23
|
+
base_pos = overload.method_type.location.start_pos
|
24
|
+
lex_result = ::RBS::Parser.lex(overload.method_type.location.source)
|
25
|
+
buf = []
|
26
|
+
lex_result.value.each do |token|
|
27
|
+
case token.type
|
28
|
+
when :pLPAREN, :pRPAREN, :tTRIVIA
|
29
|
+
# skip
|
30
|
+
when :pCOLON
|
31
|
+
next if buf.empty?
|
32
|
+
|
33
|
+
case buf.last.type
|
34
|
+
when :pQUESTION
|
35
|
+
buf.shift if buf.first.type == :pQUESTION
|
36
|
+
actual = buf.map { |t| t.location.source }.join
|
37
|
+
did_you_mean = buf.reject { |t| t.location.source == '?' }.map { |t| t.location.source }.join
|
38
|
+
message = +"`#{actual}` is not local variable name."
|
39
|
+
if did_you_mean.length > 0
|
40
|
+
message << " Did you mean `?#{did_you_mean}` for optional keyword argument?"
|
41
|
+
end
|
42
|
+
range = range_between(buf.first.location.start_pos + base_pos, buf.last.location.end_pos + base_pos)
|
43
|
+
add_offense(range, message: message)
|
44
|
+
when :tBANGIDENT, :tUIDENT
|
45
|
+
buf.shift if buf.first.type == :pQUESTION
|
46
|
+
actual = buf.map { |t| t.location.source }.join
|
47
|
+
range = range_between(buf.first.location.start_pos + base_pos, buf.last.location.end_pos + base_pos)
|
48
|
+
add_offense(range, message: "`#{actual}` is not local variable name.")
|
49
|
+
end
|
50
|
+
when :pCOMMA
|
51
|
+
buf.clear
|
52
|
+
else
|
53
|
+
buf << token
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/rubocop/cop/rbs/lint/{useless_overload_type_params.rb → unused_overload_type_params.rb}
RENAMED
@@ -4,7 +4,7 @@ module RuboCop
|
|
4
4
|
module Cop
|
5
5
|
module RBS
|
6
6
|
module Lint
|
7
|
-
# Notice
|
7
|
+
# Notice unused overload type parameters.
|
8
8
|
#
|
9
9
|
# @example default
|
10
10
|
# # bad
|
@@ -12,8 +12,8 @@ module RuboCop
|
|
12
12
|
#
|
13
13
|
# # good
|
14
14
|
# def foo: [T] (T) -> T
|
15
|
-
class
|
16
|
-
MSG = '
|
15
|
+
class UnusedOverloadTypeParams < RuboCop::RBS::CopBase
|
16
|
+
MSG = 'Unused overload type variable - `%<variable>s`.'
|
17
17
|
|
18
18
|
def on_rbs_def(decl)
|
19
19
|
decl.overloads.each do |overload|
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module RBS
|
6
|
+
module Lint
|
7
|
+
# Notice unused type parameters.
|
8
|
+
#
|
9
|
+
# @example default
|
10
|
+
# # bad
|
11
|
+
# type ary[T] = Array[Integer]
|
12
|
+
#
|
13
|
+
# # good
|
14
|
+
# type ary[T] = Array[T]
|
15
|
+
class UnusedTypeAliasTypeParams < RuboCop::RBS::CopBase
|
16
|
+
MSG = 'Unused type variable - `%<variable>s`.'
|
17
|
+
|
18
|
+
def on_rbs_type_alias(decl)
|
19
|
+
return if decl.type_params.empty?
|
20
|
+
|
21
|
+
type_params = decl.type_params.dup
|
22
|
+
|
23
|
+
map = type_params.to_h { |param| [param.name, param] }
|
24
|
+
type_params.each do |type_param|
|
25
|
+
if type_param.upper_bound
|
26
|
+
used_variable_in_type(type_param.upper_bound) do |var|
|
27
|
+
map.delete(var.name)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
used_variable_in_type(decl.type) do |var|
|
33
|
+
map.delete(var.name)
|
34
|
+
end
|
35
|
+
return if map.empty?
|
36
|
+
|
37
|
+
map.each do |name, type_param|
|
38
|
+
next unless type_param.location
|
39
|
+
|
40
|
+
t = location_to_range(type_param.location[:name])
|
41
|
+
add_offense(t, message: format(MSG, variable: name))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def used_variable_in_type(type, &block)
|
46
|
+
case type
|
47
|
+
when ::RBS::Types::Variable
|
48
|
+
yield type
|
49
|
+
else
|
50
|
+
type.each_type do |t|
|
51
|
+
used_variable_in_type(t, &block)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# rbs_inline: enabled
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module RuboCop
|
5
|
+
module Cop
|
6
|
+
module RBS
|
7
|
+
module Style
|
8
|
+
# Checks that `class` in singleton context.
|
9
|
+
#
|
10
|
+
# @example (default)
|
11
|
+
# # bad
|
12
|
+
# def self.foo: (class) -> class
|
13
|
+
#
|
14
|
+
# # good
|
15
|
+
# def self.foo: (self) -> self
|
16
|
+
#
|
17
|
+
class ClassWithSingleton < RuboCop::RBS::CopBase
|
18
|
+
extend AutoCorrector
|
19
|
+
MSG = 'Use `self` instead of `class`.'
|
20
|
+
|
21
|
+
# @rbs decl: RBS::AST::Members::MethodDefinition
|
22
|
+
def on_rbs_def(decl)
|
23
|
+
return unless decl.kind == :singleton
|
24
|
+
|
25
|
+
decl.overloads.each do |overload|
|
26
|
+
overload.method_type.each_type do |type|
|
27
|
+
check_type(type)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# @rbs type: RBS::Types::t
|
33
|
+
def check_type(type)
|
34
|
+
case type
|
35
|
+
when ::RBS::Types::Bases::Class
|
36
|
+
return unless type.location
|
37
|
+
|
38
|
+
range = location_to_range(type.location)
|
39
|
+
add_offense(range) do |corrector|
|
40
|
+
corrector.replace(range, 'self')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -29,6 +29,14 @@ module RuboCop
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
def on_rbs_constant(decl)
|
33
|
+
check_type(decl.type)
|
34
|
+
end
|
35
|
+
alias on_rbs_global on_rbs_constant
|
36
|
+
alias on_rbs_type_alias on_rbs_constant
|
37
|
+
alias on_rbs_attribute on_rbs_constant
|
38
|
+
alias on_rbs_var on_rbs_constant
|
39
|
+
|
32
40
|
# @rbs type: ::RBS::Types::t
|
33
41
|
def check_type(type)
|
34
42
|
find_replacement(type) do |t, replaced|
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# rbs_inline: enabled
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module RuboCop
|
5
|
+
module Cop
|
6
|
+
module RBS
|
7
|
+
module Style
|
8
|
+
# Checks that `instance` in instance context.
|
9
|
+
#
|
10
|
+
# @example (default)
|
11
|
+
# # bad
|
12
|
+
# def foo: (instance) -> instance
|
13
|
+
#
|
14
|
+
# # good
|
15
|
+
# def foo: (self) -> self
|
16
|
+
#
|
17
|
+
class InstanceWithInstance < RuboCop::RBS::CopBase
|
18
|
+
extend AutoCorrector
|
19
|
+
MSG = 'Use `self` instead of `instance`.'
|
20
|
+
|
21
|
+
# @rbs decl: RBS::AST::Declarations::Class
|
22
|
+
def on_rbs_class(decl)
|
23
|
+
# The meaning of `self` and `instance` changes in generic class.
|
24
|
+
return unless decl.type_params.empty?
|
25
|
+
|
26
|
+
decl.members.each do |member|
|
27
|
+
case member
|
28
|
+
when ::RBS::AST::Members::MethodDefinition
|
29
|
+
next unless member.kind == :instance
|
30
|
+
|
31
|
+
member.overloads.each do |overload|
|
32
|
+
overload.method_type.each_type do |type|
|
33
|
+
check_type(type)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
when ::RBS::AST::Members::InstanceVariable
|
37
|
+
check_type(member.type)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def check_type(type)
|
43
|
+
case type
|
44
|
+
when ::RBS::Types::Bases::Instance
|
45
|
+
return unless type.location
|
46
|
+
|
47
|
+
range = location_to_range(type.location)
|
48
|
+
add_offense(range) do |corrector|
|
49
|
+
corrector.replace(range, 'self')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/rubocop/cop/rbs_cops.rb
CHANGED
@@ -14,6 +14,7 @@ require_relative 'rbs/layout/end_alignment'
|
|
14
14
|
require_relative 'rbs/layout/extra_spacing'
|
15
15
|
require_relative 'rbs/layout/indentation_width'
|
16
16
|
require_relative 'rbs/layout/overload_indentation'
|
17
|
+
require_relative 'rbs/layout/space_after_comma'
|
17
18
|
require_relative 'rbs/layout/space_around_arrow'
|
18
19
|
require_relative 'rbs/layout/space_around_braces'
|
19
20
|
require_relative 'rbs/layout/space_around_operators'
|
@@ -21,21 +22,25 @@ require_relative 'rbs/layout/space_before_colon'
|
|
21
22
|
require_relative 'rbs/layout/space_before_overload'
|
22
23
|
require_relative 'rbs/layout/trailing_whitespace'
|
23
24
|
|
25
|
+
require_relative 'rbs/lint/ambiguous_keyword_argument_key'
|
24
26
|
require_relative 'rbs/lint/ambiguous_operator_precedence'
|
25
27
|
require_relative 'rbs/lint/duplicate_overload'
|
26
28
|
require_relative 'rbs/lint/literal_intersection'
|
27
29
|
require_relative 'rbs/lint/syntax'
|
28
30
|
require_relative 'rbs/lint/top_level_interface'
|
29
31
|
require_relative 'rbs/lint/top_level_type_alias'
|
32
|
+
require_relative 'rbs/lint/unused_overload_type_params'
|
33
|
+
require_relative 'rbs/lint/unused_type_alias_type_params'
|
30
34
|
require_relative 'rbs/lint/useless_access_modifier'
|
31
|
-
require_relative 'rbs/lint/useless_overload_type_params'
|
32
35
|
require_relative 'rbs/lint/will_syntax_error'
|
33
36
|
|
34
37
|
require_relative 'rbs/style/block_return_boolish'
|
38
|
+
require_relative 'rbs/style/class_with_singleton'
|
35
39
|
require_relative 'rbs/style/classic_type'
|
36
40
|
require_relative 'rbs/style/duplicated_type'
|
37
41
|
require_relative 'rbs/style/empty_argument'
|
38
42
|
require_relative 'rbs/style/initialize_return_type'
|
43
|
+
require_relative 'rbs/style/instance_with_instance'
|
39
44
|
require_relative 'rbs/style/optional_nil'
|
40
45
|
require_relative 'rbs/style/redundant_parentheses'
|
41
46
|
require_relative 'rbs/style/true_false'
|
data/lib/rubocop/rbs/cop_base.rb
CHANGED
@@ -73,6 +73,7 @@ module RuboCop
|
|
73
73
|
def on_rbs_attribute(member); end
|
74
74
|
def on_rbs_public(member); end
|
75
75
|
def on_rbs_private(member); end
|
76
|
+
def on_rbs_var(member); end
|
76
77
|
|
77
78
|
def walk(decl)
|
78
79
|
case decl
|
@@ -99,6 +100,8 @@ module RuboCop
|
|
99
100
|
on_rbs_public(decl)
|
100
101
|
when ::RBS::AST::Members::Private
|
101
102
|
on_rbs_private(decl)
|
103
|
+
when ::RBS::AST::Members::Var
|
104
|
+
on_rbs_var(decl)
|
102
105
|
end
|
103
106
|
end
|
104
107
|
|
@@ -23,12 +23,8 @@ module RuboCop
|
|
23
23
|
@error.nil?
|
24
24
|
end
|
25
25
|
|
26
|
-
def tokens
|
27
|
-
@tokens ||=
|
28
|
-
tokens = ::RBS::Parser.lex(buffer).value
|
29
|
-
tokens.reject! { |token| token.type == :tTRIVIA } unless with_trivia
|
30
|
-
tokens
|
31
|
-
end
|
26
|
+
def tokens
|
27
|
+
@tokens ||= ::RBS::Parser.lex(buffer).value
|
32
28
|
end
|
33
29
|
end
|
34
30
|
end
|
data/lib/rubocop/rbs/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-on-rbs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ksss
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date: 2024-
|
10
|
+
date: 2024-12-24 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rbs
|
@@ -77,26 +76,31 @@ files:
|
|
77
76
|
- lib/rubocop/cop/rbs/layout/extra_spacing.rb
|
78
77
|
- lib/rubocop/cop/rbs/layout/indentation_width.rb
|
79
78
|
- lib/rubocop/cop/rbs/layout/overload_indentation.rb
|
79
|
+
- lib/rubocop/cop/rbs/layout/space_after_comma.rb
|
80
80
|
- lib/rubocop/cop/rbs/layout/space_around_arrow.rb
|
81
81
|
- lib/rubocop/cop/rbs/layout/space_around_braces.rb
|
82
82
|
- lib/rubocop/cop/rbs/layout/space_around_operators.rb
|
83
83
|
- lib/rubocop/cop/rbs/layout/space_before_colon.rb
|
84
84
|
- lib/rubocop/cop/rbs/layout/space_before_overload.rb
|
85
85
|
- lib/rubocop/cop/rbs/layout/trailing_whitespace.rb
|
86
|
+
- lib/rubocop/cop/rbs/lint/ambiguous_keyword_argument_key.rb
|
86
87
|
- lib/rubocop/cop/rbs/lint/ambiguous_operator_precedence.rb
|
87
88
|
- lib/rubocop/cop/rbs/lint/duplicate_overload.rb
|
88
89
|
- lib/rubocop/cop/rbs/lint/literal_intersection.rb
|
89
90
|
- lib/rubocop/cop/rbs/lint/syntax.rb
|
90
91
|
- lib/rubocop/cop/rbs/lint/top_level_interface.rb
|
91
92
|
- lib/rubocop/cop/rbs/lint/top_level_type_alias.rb
|
93
|
+
- lib/rubocop/cop/rbs/lint/unused_overload_type_params.rb
|
94
|
+
- lib/rubocop/cop/rbs/lint/unused_type_alias_type_params.rb
|
92
95
|
- lib/rubocop/cop/rbs/lint/useless_access_modifier.rb
|
93
|
-
- lib/rubocop/cop/rbs/lint/useless_overload_type_params.rb
|
94
96
|
- lib/rubocop/cop/rbs/lint/will_syntax_error.rb
|
95
97
|
- lib/rubocop/cop/rbs/style/block_return_boolish.rb
|
98
|
+
- lib/rubocop/cop/rbs/style/class_with_singleton.rb
|
96
99
|
- lib/rubocop/cop/rbs/style/classic_type.rb
|
97
100
|
- lib/rubocop/cop/rbs/style/duplicated_type.rb
|
98
101
|
- lib/rubocop/cop/rbs/style/empty_argument.rb
|
99
102
|
- lib/rubocop/cop/rbs/style/initialize_return_type.rb
|
103
|
+
- lib/rubocop/cop/rbs/style/instance_with_instance.rb
|
100
104
|
- lib/rubocop/cop/rbs/style/optional_nil.rb
|
101
105
|
- lib/rubocop/cop/rbs/style/redundant_parentheses.rb
|
102
106
|
- lib/rubocop/cop/rbs/style/true_false.rb
|
@@ -115,7 +119,6 @@ metadata:
|
|
115
119
|
source_code_uri: https://github.com/ksss/rubocop-on-rbs
|
116
120
|
changelog_uri: https://github.com/ksss/rubocop-on-rbs
|
117
121
|
rubygems_mfa_required: 'true'
|
118
|
-
post_install_message:
|
119
122
|
rdoc_options: []
|
120
123
|
require_paths:
|
121
124
|
- lib
|
@@ -130,8 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
133
|
- !ruby/object:Gem::Version
|
131
134
|
version: '0'
|
132
135
|
requirements: []
|
133
|
-
rubygems_version: 3.
|
134
|
-
signing_key:
|
136
|
+
rubygems_version: 3.6.2
|
135
137
|
specification_version: 4
|
136
138
|
summary: RuboCop extension for RBS file.
|
137
139
|
test_files: []
|