rubocop-on-rbs 2.0.0.dev → 2.1.0
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 +4 -4
- data/CHANGELOG.md +53 -0
- data/README.md +1 -4
- data/config/default.yml +6 -4
- data/lib/rubocop/cop/rbs/layout/annotation_indentation.rb +90 -0
- data/lib/rubocop/cop/rbs/layout/comment_indentation.rb +34 -32
- data/lib/rubocop/cop/rbs/layout/empty_lines_around_access_modifier.rb +4 -3
- data/lib/rubocop/cop/rbs/layout/empty_lines_around_body.rb +8 -0
- data/lib/rubocop/cop/rbs/layout/empty_lines_around_overloads.rb +22 -6
- data/lib/rubocop/cop/rbs/layout/end_alignment.rb +2 -1
- data/lib/rubocop/cop/rbs/layout/extra_spacing.rb +1 -0
- data/lib/rubocop/cop/rbs/layout/indentation_width.rb +17 -2
- data/lib/rubocop/cop/rbs/layout/overload_indentation.rb +16 -6
- data/lib/rubocop/cop/rbs/layout/space_after_comma.rb +1 -0
- data/lib/rubocop/cop/rbs/layout/space_around_arrow.rb +4 -2
- data/lib/rubocop/cop/rbs/layout/space_around_braces.rb +6 -3
- data/lib/rubocop/cop/rbs/layout/space_around_operators.rb +19 -1
- data/lib/rubocop/cop/rbs/layout/space_before_colon.rb +1 -1
- data/lib/rubocop/cop/rbs/layout/space_before_overload.rb +27 -13
- data/lib/rubocop/cop/rbs/lint/ambiguous_keyword_argument_key.rb +3 -2
- data/lib/rubocop/cop/rbs/lint/ambiguous_operator_precedence.rb +2 -0
- data/lib/rubocop/cop/rbs/lint/duplicate_annotation.rb +2 -0
- data/lib/rubocop/cop/rbs/lint/duplicate_overload.rb +3 -2
- data/lib/rubocop/cop/rbs/lint/new_returns_void.rb +0 -2
- data/lib/rubocop/cop/rbs/lint/top_level_interface.rb +6 -4
- data/lib/rubocop/cop/rbs/lint/top_level_type_alias.rb +6 -4
- data/lib/rubocop/cop/rbs/lint/useless_access_modifier.rb +3 -3
- data/lib/rubocop/cop/rbs/style/block_return_boolish.rb +1 -0
- data/lib/rubocop/cop/rbs/style/class_with_singleton.rb +1 -1
- data/lib/rubocop/cop/rbs/style/classic_type.rb +6 -5
- data/lib/rubocop/cop/rbs/style/initialize_return_type.rb +1 -0
- data/lib/rubocop/cop/rbs/style/instance_with_instance.rb +1 -1
- data/lib/rubocop/cop/rbs/style/optional_nil.rb +1 -1
- data/lib/rubocop/cop/rbs/style/redundant_parentheses.rb +19 -5
- data/lib/rubocop/cop/rbs/style/true_false.rb +1 -1
- data/lib/rubocop/cop/rbs_cops.rb +1 -1
- data/lib/rubocop/rbs/cop_base.rb +29 -1
- data/lib/rubocop/rbs/on_type_helper.rb +2 -0
- data/lib/rubocop/rbs/processed_rbs_source.rb +10 -5
- data/lib/rubocop/rbs/version.rb +1 -1
- metadata +8 -8
- data/lib/rubocop/cop/rbs/lint/will_syntax_error.rb +0 -228
|
@@ -17,25 +17,39 @@ module RuboCop
|
|
|
17
17
|
|
|
18
18
|
MSG = 'Use one space before overload.'
|
|
19
19
|
|
|
20
|
-
# @
|
|
20
|
+
# @rbs decl: ::RBS::AST::Members::MethodDefinition
|
|
21
21
|
def on_rbs_def(decl)
|
|
22
|
-
source = processed_source.raw_source
|
|
23
22
|
decl.overloads.each_with_index do |overload, i|
|
|
24
|
-
loc = overload.method_type.location
|
|
23
|
+
loc = overload.method_type.location or next
|
|
25
24
|
overload_char = i == 0 ? ':' : '|'
|
|
25
|
+
check(loc, overload_char)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
if decl.overloading?
|
|
29
|
+
loc = decl.location or return
|
|
30
|
+
overloading_loc = loc[:overloading] or return
|
|
31
|
+
overload_char = decl.overloads.length == 0 ? ':' : '|'
|
|
32
|
+
check(overloading_loc, overload_char)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
# @rbs loc: ::RBS::Location[bot, bot]
|
|
39
|
+
def check(loc, overload_char)
|
|
40
|
+
source = processed_source.raw_source
|
|
26
41
|
|
|
27
|
-
|
|
28
|
-
|
|
42
|
+
char_start_pos = source.rindex(overload_char, loc.start_pos)
|
|
43
|
+
return unless char_start_pos
|
|
29
44
|
|
|
30
|
-
|
|
31
|
-
|
|
45
|
+
word_after_char_pos = source.index(/[^\s]/, char_start_pos + 1)
|
|
46
|
+
return unless word_after_char_pos
|
|
32
47
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
end
|
|
48
|
+
if char_start_pos + 2 != word_after_char_pos
|
|
49
|
+
char = range_between(char_start_pos, char_start_pos + 1)
|
|
50
|
+
add_offense(char) do |corrector|
|
|
51
|
+
range = range_between(char_start_pos + 1, word_after_char_pos)
|
|
52
|
+
corrector.replace(range, ' ')
|
|
39
53
|
end
|
|
40
54
|
end
|
|
41
55
|
end
|
|
@@ -20,8 +20,9 @@ module RuboCop
|
|
|
20
20
|
next unless func.kind_of?(::RBS::Types::Function)
|
|
21
21
|
next unless !func.required_keywords.empty? || !func.optional_keywords.empty?
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
location = overload.method_type.location or next
|
|
24
|
+
base_pos = location.start_pos
|
|
25
|
+
lex_result = ::RBS::Parser.lex(location.source)
|
|
25
26
|
buf = []
|
|
26
27
|
lex_result.value.each do |token|
|
|
27
28
|
case token.type
|
|
@@ -23,6 +23,7 @@ module RuboCop
|
|
|
23
23
|
class DuplicateAnnotation < RuboCop::RBS::CopBase
|
|
24
24
|
MSG = 'Duplicate annotation detected.'
|
|
25
25
|
|
|
26
|
+
#: (::RBS::AST::Members::MethodDefinition) -> void
|
|
26
27
|
def on_rbs_def(decl)
|
|
27
28
|
decl.annotations.each_with_index do |annotation, idx|
|
|
28
29
|
next_annotations = decl.annotations[(idx + 1)..] or next
|
|
@@ -41,6 +42,7 @@ module RuboCop
|
|
|
41
42
|
end
|
|
42
43
|
end
|
|
43
44
|
|
|
45
|
+
#: (::RBS::AST::Annotation, Array[::RBS::AST::Annotation]) -> void
|
|
44
46
|
def check_annotations(left_annotation, right_annotations)
|
|
45
47
|
right_annotations.each do |right_annotation|
|
|
46
48
|
next unless left_annotation == right_annotation
|
|
@@ -20,13 +20,14 @@ module RuboCop
|
|
|
20
20
|
overloads.each_with_index do |overload, idx|
|
|
21
21
|
next if idx == overloads.size - 1
|
|
22
22
|
|
|
23
|
-
next_overloads = overloads[(idx + 1)..-1]
|
|
23
|
+
next_overloads = overloads[(idx + 1)..-1] or next
|
|
24
24
|
next_overloads.each do |next_overload|
|
|
25
25
|
a = method_type_with_untyped_return_type(overload.method_type)
|
|
26
26
|
b = method_type_with_untyped_return_type(next_overload.method_type)
|
|
27
27
|
next unless a == b
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
location = next_overload.method_type.location or next
|
|
30
|
+
range = location_to_range(location)
|
|
30
31
|
add_offense(range)
|
|
31
32
|
end
|
|
32
33
|
end
|
|
@@ -27,17 +27,19 @@ module RuboCop
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def on_rbs_class(decl)
|
|
30
|
-
|
|
30
|
+
location = decl.location or return
|
|
31
|
+
return unless @last_end_pos.nil? || (@last_end_pos < location.end_pos)
|
|
31
32
|
|
|
32
|
-
@last_end_pos =
|
|
33
|
+
@last_end_pos = location.end_pos
|
|
33
34
|
end
|
|
34
35
|
alias on_rbs_module on_rbs_class
|
|
35
36
|
|
|
36
37
|
def on_rbs_interface(decl)
|
|
37
|
-
|
|
38
|
+
location = decl.location or return
|
|
39
|
+
return unless @last_end_pos.nil? || (@last_end_pos < location.start_pos)
|
|
38
40
|
return unless decl.name.namespace.path.empty?
|
|
39
41
|
|
|
40
|
-
range = location_to_range(
|
|
42
|
+
range = location_to_range(location)
|
|
41
43
|
add_offense(range)
|
|
42
44
|
end
|
|
43
45
|
end
|
|
@@ -23,18 +23,20 @@ module RuboCop
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def on_rbs_class(decl)
|
|
26
|
-
|
|
26
|
+
location = decl.location or return
|
|
27
|
+
return unless @last_end_pos.nil? || (@last_end_pos < location.end_pos)
|
|
27
28
|
|
|
28
|
-
@last_end_pos =
|
|
29
|
+
@last_end_pos = location.end_pos
|
|
29
30
|
end
|
|
30
31
|
alias on_rbs_module on_rbs_class
|
|
31
32
|
alias on_rbs_interface on_rbs_class
|
|
32
33
|
|
|
33
34
|
def on_rbs_type_alias(decl)
|
|
34
|
-
|
|
35
|
+
location = decl.location or return
|
|
36
|
+
return unless @last_end_pos.nil? || (@last_end_pos < location.start_pos)
|
|
35
37
|
return unless decl.name.namespace.path.empty?
|
|
36
38
|
|
|
37
|
-
range = location_to_range(
|
|
39
|
+
range = location_to_range(location)
|
|
38
40
|
add_offense(range)
|
|
39
41
|
end
|
|
40
42
|
end
|
|
@@ -42,7 +42,7 @@ module RuboCop
|
|
|
42
42
|
MSG = 'Useless `%<current>s` access modifier.'
|
|
43
43
|
|
|
44
44
|
def on_rbs_class(decl)
|
|
45
|
-
current = nil
|
|
45
|
+
current = nil #: ::RBS::AST::Members::Public | ::RBS::AST::Members::Private | nil
|
|
46
46
|
unused = true
|
|
47
47
|
decl.members.each do |member|
|
|
48
48
|
next unless member.location
|
|
@@ -71,8 +71,8 @@ module RuboCop
|
|
|
71
71
|
end
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
-
if unused && current
|
|
75
|
-
range = location_to_range(
|
|
74
|
+
if unused && current && (location = current.location)
|
|
75
|
+
range = location_to_range(location)
|
|
76
76
|
vis = case current
|
|
77
77
|
when ::RBS::AST::Members::Public
|
|
78
78
|
'public'
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# rbs_inline: enabled
|
|
2
1
|
# frozen_string_literal: true
|
|
3
2
|
|
|
4
3
|
module RuboCop
|
|
@@ -16,6 +15,7 @@ module RuboCop
|
|
|
16
15
|
#
|
|
17
16
|
class ClassWithSingleton < RuboCop::RBS::CopBase
|
|
18
17
|
extend AutoCorrector
|
|
18
|
+
|
|
19
19
|
MSG = 'Use `self` instead of `class`.'
|
|
20
20
|
|
|
21
21
|
# @rbs decl: RBS::AST::Members::MethodDefinition
|
|
@@ -20,7 +20,7 @@ module RuboCop
|
|
|
20
20
|
class ClassicType < RuboCop::RBS::CopBase
|
|
21
21
|
extend AutoCorrector
|
|
22
22
|
|
|
23
|
-
Types = ::RBS::Types
|
|
23
|
+
Types = ::RBS::Types #: module-alias
|
|
24
24
|
|
|
25
25
|
def on_rbs_def(decl)
|
|
26
26
|
decl.overloads.each do |overload|
|
|
@@ -38,7 +38,7 @@ module RuboCop
|
|
|
38
38
|
alias on_rbs_attribute on_rbs_constant
|
|
39
39
|
alias on_rbs_var on_rbs_constant
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
#: (::RBS::Types::t type) -> untyped
|
|
42
42
|
def check_type(type)
|
|
43
43
|
find_replacement(type) do |t, replaced|
|
|
44
44
|
range = location_to_range(t.location)
|
|
@@ -48,6 +48,7 @@ module RuboCop
|
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
+
#: (::RBS::Types::t type) ?{ ([::RBS::Types::t, String]) -> untyped } -> untyped
|
|
51
52
|
def find_replacement(type, &block)
|
|
52
53
|
case type
|
|
53
54
|
when Types::Record,
|
|
@@ -64,11 +65,11 @@ module RuboCop
|
|
|
64
65
|
when Types::ClassInstance
|
|
65
66
|
case type.name.to_s
|
|
66
67
|
when 'TrueClass', '::TrueClass'
|
|
67
|
-
block
|
|
68
|
+
block&.call([type, 'true'])
|
|
68
69
|
when 'FalseClass', '::FalseClass'
|
|
69
|
-
block
|
|
70
|
+
block&.call([type, 'false'])
|
|
70
71
|
when 'NilClass', '::NilClass'
|
|
71
|
-
block
|
|
72
|
+
block&.call([type, 'nil'])
|
|
72
73
|
end
|
|
73
74
|
type.each_type do |arg|
|
|
74
75
|
find_replacement(arg, &block)
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# rbs_inline: enabled
|
|
2
1
|
# frozen_string_literal: true
|
|
3
2
|
|
|
4
3
|
module RuboCop
|
|
@@ -16,6 +15,7 @@ module RuboCop
|
|
|
16
15
|
#
|
|
17
16
|
class InstanceWithInstance < RuboCop::RBS::CopBase
|
|
18
17
|
extend AutoCorrector
|
|
18
|
+
|
|
19
19
|
MSG = 'Use `self` instead of `instance`.'
|
|
20
20
|
|
|
21
21
|
# @rbs decl: RBS::AST::Declarations::Class
|
|
@@ -46,7 +46,7 @@ module RuboCop
|
|
|
46
46
|
when ::RBS::Types::Optional
|
|
47
47
|
case type.type
|
|
48
48
|
when ::RBS::Types::Bases::Nil
|
|
49
|
-
block
|
|
49
|
+
block&.call([type, ::RBS::Types::Bases::Nil.new(location: nil)])
|
|
50
50
|
else
|
|
51
51
|
find_replacement(type.type, &block)
|
|
52
52
|
end
|
|
@@ -49,8 +49,16 @@ module RuboCop
|
|
|
49
49
|
class ParenChecker
|
|
50
50
|
include BeforeTokenIfLparen
|
|
51
51
|
include RangeHelp
|
|
52
|
+
|
|
52
53
|
attr_reader :processed_source
|
|
53
54
|
|
|
55
|
+
# @rbs processed_source: RuboCop::AST::ProcessedSource
|
|
56
|
+
# @rbs base: Integer
|
|
57
|
+
# @rbs tokens: Array[::RBS::Parser::Token]
|
|
58
|
+
# @rbs type: ::RBS::Types::t
|
|
59
|
+
# @rbs skip: Set[Integer]
|
|
60
|
+
# @rbs cop: RuboCop::RBS::CopBase
|
|
61
|
+
# @rbs return: void
|
|
54
62
|
def initialize(processed_source:, base:, tokens:, type:, skip:, cop:)
|
|
55
63
|
@processed_source = processed_source
|
|
56
64
|
@base = base
|
|
@@ -62,6 +70,8 @@ module RuboCop
|
|
|
62
70
|
|
|
63
71
|
def check
|
|
64
72
|
@cop.on_type([::RBS::Types::Proc], @type) do |proc_type|
|
|
73
|
+
next unless proc_type.is_a?(::RBS::Types::Proc)
|
|
74
|
+
|
|
65
75
|
before_token_if_lparen(@tokens, @base, proc_type.type) do |b|
|
|
66
76
|
@skip << (b.location.start_pos + @base)
|
|
67
77
|
end
|
|
@@ -85,7 +95,9 @@ module RuboCop
|
|
|
85
95
|
case type.type.literal
|
|
86
96
|
when Symbol
|
|
87
97
|
# Skip optional with symbol literal (e.g. `(:sym)?`)
|
|
88
|
-
|
|
98
|
+
if (location = type.location)
|
|
99
|
+
@skip << location.start_pos
|
|
100
|
+
end
|
|
89
101
|
end
|
|
90
102
|
end
|
|
91
103
|
end
|
|
@@ -121,8 +133,9 @@ module RuboCop
|
|
|
121
133
|
extend AutoCorrector
|
|
122
134
|
|
|
123
135
|
def on_rbs_def(decl)
|
|
124
|
-
|
|
125
|
-
|
|
136
|
+
location = decl.location or return
|
|
137
|
+
base = location.start_pos
|
|
138
|
+
tokens = tokenize(location.source)
|
|
126
139
|
skip = Set.new
|
|
127
140
|
decl.overloads.each do |overload|
|
|
128
141
|
before_token_if_lparen(tokens, base, overload.method_type.type) do |b|
|
|
@@ -151,9 +164,10 @@ module RuboCop
|
|
|
151
164
|
end
|
|
152
165
|
|
|
153
166
|
def on_rbs_constant(const)
|
|
154
|
-
|
|
167
|
+
location = const.location or return
|
|
168
|
+
tokens = tokenize(location.source)
|
|
155
169
|
type = const.type
|
|
156
|
-
base =
|
|
170
|
+
base = location.start_pos
|
|
157
171
|
check_type(tokens:, type:, base:)
|
|
158
172
|
end
|
|
159
173
|
alias on_rbs_global on_rbs_constant
|
|
@@ -82,7 +82,7 @@ module RuboCop
|
|
|
82
82
|
end
|
|
83
83
|
end
|
|
84
84
|
replaced.insert(first_index || 0, ::RBS::Types::Bases::Bool.new(location: nil))
|
|
85
|
-
block
|
|
85
|
+
block&.call([type, ::RBS::Types::Union.new(types: replaced, location: nil)])
|
|
86
86
|
end
|
|
87
87
|
else
|
|
88
88
|
type.each_type do |type|
|
data/lib/rubocop/cop/rbs_cops.rb
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require 'rbs'
|
|
4
4
|
|
|
5
|
+
require_relative 'rbs/layout/annotation_indentation'
|
|
5
6
|
require_relative 'rbs/layout/comment_indentation'
|
|
6
7
|
require_relative 'rbs/layout/empty_line_between_declarations'
|
|
7
8
|
require_relative 'rbs/layout/empty_lines_around_access_modifier'
|
|
@@ -37,7 +38,6 @@ require_relative 'rbs/lint/top_level_type_alias'
|
|
|
37
38
|
require_relative 'rbs/lint/unused_overload_type_params'
|
|
38
39
|
require_relative 'rbs/lint/unused_type_alias_type_params'
|
|
39
40
|
require_relative 'rbs/lint/useless_access_modifier'
|
|
40
|
-
require_relative 'rbs/lint/will_syntax_error'
|
|
41
41
|
|
|
42
42
|
require_relative 'rbs/style/block_return_boolish'
|
|
43
43
|
require_relative 'rbs/style/class_with_singleton'
|
data/lib/rubocop/rbs/cop_base.rb
CHANGED
|
@@ -9,7 +9,7 @@ module RuboCop
|
|
|
9
9
|
include RuboCop::Cop::RangeHelp
|
|
10
10
|
include RuboCop::RBS::OnTypeHelper
|
|
11
11
|
|
|
12
|
-
attr_reader :processed_rbs_source
|
|
12
|
+
attr_reader :processed_rbs_source #: RuboCop::RBS::ProcessedRBSSource
|
|
13
13
|
|
|
14
14
|
exclude_from_registry
|
|
15
15
|
|
|
@@ -34,6 +34,7 @@ module RuboCop
|
|
|
34
34
|
@processed_rbs_source = RuboCop::RBS::ProcessedRBSSource.new(buffer)
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
#: () -> void
|
|
37
38
|
def investigation_rbs
|
|
38
39
|
return unless processed_source.buffer.name.then { |n| n.end_with?(".rbs") || n == "(string)" }
|
|
39
40
|
|
|
@@ -65,22 +66,47 @@ module RuboCop
|
|
|
65
66
|
end
|
|
66
67
|
end
|
|
67
68
|
|
|
69
|
+
#: () -> void
|
|
68
70
|
def on_rbs_new_investigation; end
|
|
71
|
+
|
|
72
|
+
#: () -> void
|
|
69
73
|
def on_rbs_parsing_error; end
|
|
70
74
|
|
|
71
75
|
# other on_* methods should sync with `#walk` method
|
|
76
|
+
#: (::RBS::AST::Declarations::Class) -> void
|
|
72
77
|
def on_rbs_class(member); end
|
|
78
|
+
|
|
79
|
+
#: (::RBS::AST::Declarations::Module) -> void
|
|
73
80
|
def on_rbs_module(member); end
|
|
81
|
+
|
|
82
|
+
#: (::RBS::AST::Declarations::Interface) -> void
|
|
74
83
|
def on_rbs_interface(member); end
|
|
84
|
+
|
|
85
|
+
#: (::RBS::AST::Declarations::Constant) -> void
|
|
75
86
|
def on_rbs_constant(const); end
|
|
87
|
+
|
|
88
|
+
#: (::RBS::AST::Declarations::Global) -> void
|
|
76
89
|
def on_rbs_global(global); end
|
|
90
|
+
|
|
91
|
+
#: (::RBS::AST::Declarations::TypeAlias) -> void
|
|
77
92
|
def on_rbs_type_alias(decl); end
|
|
93
|
+
|
|
94
|
+
#: (::RBS::AST::Members::MethodDefinition) -> void
|
|
78
95
|
def on_rbs_def(member); end
|
|
96
|
+
|
|
97
|
+
#: (::RBS::AST::Members::Attribute) -> void
|
|
79
98
|
def on_rbs_attribute(member); end
|
|
99
|
+
|
|
100
|
+
#: (::RBS::AST::Members::Public) -> void
|
|
80
101
|
def on_rbs_public(member); end
|
|
102
|
+
|
|
103
|
+
#: (::RBS::AST::Members::Private) -> void
|
|
81
104
|
def on_rbs_private(member); end
|
|
105
|
+
|
|
106
|
+
#: (::RBS::AST::Members::Var) -> void
|
|
82
107
|
def on_rbs_var(member); end
|
|
83
108
|
|
|
109
|
+
#: (untyped) -> void
|
|
84
110
|
def walk(decl)
|
|
85
111
|
case decl
|
|
86
112
|
when ::RBS::AST::Declarations::Module
|
|
@@ -111,6 +137,7 @@ module RuboCop
|
|
|
111
137
|
end
|
|
112
138
|
end
|
|
113
139
|
|
|
140
|
+
#: () -> ::RBS::Buffer
|
|
114
141
|
def rbs_buffer
|
|
115
142
|
::RBS::Buffer.new(
|
|
116
143
|
name: processed_source.buffer.name,
|
|
@@ -118,6 +145,7 @@ module RuboCop
|
|
|
118
145
|
)
|
|
119
146
|
end
|
|
120
147
|
|
|
148
|
+
#: (::RBS::Location[untyped, untyped]) -> Parser::Source::Range
|
|
121
149
|
def location_to_range(location)
|
|
122
150
|
range_between(location.start_pos, location.end_pos)
|
|
123
151
|
end
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
module RuboCop
|
|
4
4
|
module RBS
|
|
5
5
|
module OnTypeHelper
|
|
6
|
+
#: (Array[Class] types, ::RBS::Types::t type) { (::RBS::Types::t t) -> void } -> void
|
|
6
7
|
def on_type(types, type, &block)
|
|
7
8
|
case type
|
|
8
9
|
when *types
|
|
@@ -13,6 +14,7 @@ module RuboCop
|
|
|
13
14
|
end
|
|
14
15
|
end
|
|
15
16
|
|
|
17
|
+
#: (Array[Class] types, ::RBS::Types::t type) { (::RBS::Types::t t) -> void } -> void
|
|
16
18
|
def on_not_type(types, type, &block)
|
|
17
19
|
case type
|
|
18
20
|
when *types
|
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
module RuboCop
|
|
4
4
|
module RBS
|
|
5
|
+
# Fake for RuboCop::ProcessedSource
|
|
5
6
|
class ProcessedRBSSource
|
|
6
|
-
|
|
7
|
+
# @rbs @tokens: ::Array[::RBS::Parser::Token]?
|
|
8
|
+
|
|
9
|
+
attr_reader :raw_source #: String
|
|
7
10
|
attr_reader :source
|
|
8
|
-
attr_reader :buffer
|
|
9
|
-
attr_reader :directives
|
|
10
|
-
attr_reader :decls
|
|
11
|
-
attr_reader :error
|
|
11
|
+
attr_reader :buffer #: ::RBS::Buffer
|
|
12
|
+
attr_reader :directives #: ::Array[::RBS::AST::Directives::t]
|
|
13
|
+
attr_reader :decls #: ::Array[::RBS::AST::Declarations::t]
|
|
14
|
+
attr_reader :error #: ::RBS::ParsingError?
|
|
12
15
|
|
|
16
|
+
#: (::RBS::Buffer source) -> void
|
|
13
17
|
def initialize(source)
|
|
14
18
|
@raw_source = source.content
|
|
15
19
|
@buffer, @directives, @decls = ::RBS::Parser.parse_signature(source)
|
|
@@ -23,6 +27,7 @@ module RuboCop
|
|
|
23
27
|
@error.nil?
|
|
24
28
|
end
|
|
25
29
|
|
|
30
|
+
#: () -> ::Array[::RBS::Parser::Token]
|
|
26
31
|
def tokens
|
|
27
32
|
@tokens ||= ::RBS::Parser.lex(buffer).value
|
|
28
33
|
end
|
data/lib/rubocop/rbs/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubocop-on-rbs
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ksss
|
|
@@ -27,16 +27,16 @@ dependencies:
|
|
|
27
27
|
name: rbs
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
|
-
- -
|
|
30
|
+
- - "~>"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 4.0
|
|
32
|
+
version: '4.0'
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
|
-
- -
|
|
37
|
+
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: 4.0
|
|
39
|
+
version: '4.0'
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: rubocop
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -84,6 +84,7 @@ files:
|
|
|
84
84
|
- README.md
|
|
85
85
|
- config/default.yml
|
|
86
86
|
- lib/rubocop-on-rbs.rb
|
|
87
|
+
- lib/rubocop/cop/rbs/layout/annotation_indentation.rb
|
|
87
88
|
- lib/rubocop/cop/rbs/layout/comment_indentation.rb
|
|
88
89
|
- lib/rubocop/cop/rbs/layout/empty_line_between_declarations.rb
|
|
89
90
|
- lib/rubocop/cop/rbs/layout/empty_lines.rb
|
|
@@ -118,7 +119,6 @@ files:
|
|
|
118
119
|
- lib/rubocop/cop/rbs/lint/unused_overload_type_params.rb
|
|
119
120
|
- lib/rubocop/cop/rbs/lint/unused_type_alias_type_params.rb
|
|
120
121
|
- lib/rubocop/cop/rbs/lint/useless_access_modifier.rb
|
|
121
|
-
- lib/rubocop/cop/rbs/lint/will_syntax_error.rb
|
|
122
122
|
- lib/rubocop/cop/rbs/style/block_return_boolish.rb
|
|
123
123
|
- lib/rubocop/cop/rbs/style/class_with_singleton.rb
|
|
124
124
|
- lib/rubocop/cop/rbs/style/classic_type.rb
|
|
@@ -152,14 +152,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
152
152
|
requirements:
|
|
153
153
|
- - ">="
|
|
154
154
|
- !ruby/object:Gem::Version
|
|
155
|
-
version: 3.
|
|
155
|
+
version: 3.3.0
|
|
156
156
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
157
|
requirements:
|
|
158
158
|
- - ">="
|
|
159
159
|
- !ruby/object:Gem::Version
|
|
160
160
|
version: '0'
|
|
161
161
|
requirements: []
|
|
162
|
-
rubygems_version:
|
|
162
|
+
rubygems_version: 4.0.10
|
|
163
163
|
specification_version: 4
|
|
164
164
|
summary: RuboCop extension for RBS file.
|
|
165
165
|
test_files: []
|