rubocop-rbs_inline 1.0.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 +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +34 -0
- data/.vscode/extensions.json +6 -0
- data/.vscode/settings.json +5 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +40 -0
- data/Steepfile +11 -0
- data/config/default.yml +24 -0
- data/lib/rubocop/cop/rbs_inline_cops.rb +7 -0
- data/lib/rubocop/cop/style/rbs_inline/invalid_comment.rb +47 -0
- data/lib/rubocop/cop/style/rbs_inline/invalid_types.rb +71 -0
- data/lib/rubocop/cop/style/rbs_inline/keyword_separator.rb +46 -0
- data/lib/rubocop/cop/style/rbs_inline/parameters_separator.rb +47 -0
- data/lib/rubocop/cop/style/rbs_inline/unmatched_annotations.rb +139 -0
- data/lib/rubocop/rbs_inline/inject.rb +20 -0
- data/lib/rubocop/rbs_inline/version.rb +7 -0
- data/lib/rubocop/rbs_inline.rb +15 -0
- data/lib/rubocop-rbs_inline.rb +11 -0
- data/rbs_collection.lock.yaml +140 -0
- data/rbs_collection.yaml +18 -0
- data/sig/gems/parser/parser.rbs +13 -0
- data/sig/gems/rubocop/rubocop.rbs +29 -0
- data/sig/rubocop/cop/rbs_inline_cops.rbs +2 -0
- data/sig/rubocop/cop/style/rbs_inline/invalid_comment.rbs +34 -0
- data/sig/rubocop/cop/style/rbs_inline/invalid_types.rbs +39 -0
- data/sig/rubocop/cop/style/rbs_inline/keyword_separator.rbs +35 -0
- data/sig/rubocop/cop/style/rbs_inline/parameters_separator.rbs +34 -0
- data/sig/rubocop/cop/style/rbs_inline/unmatched_annotations.rbs +54 -0
- data/sig/rubocop/rbs_inline/inject.rbs +13 -0
- data/sig/rubocop/rbs_inline/version.rbs +7 -0
- data/sig/rubocop/rbs_inline.rbs +15 -0
- data/sig/rubocop-rbs_inline.rbs +2 -0
- metadata +109 -0
@@ -0,0 +1,139 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rbs/inline'
|
4
|
+
|
5
|
+
module RuboCop
|
6
|
+
module Cop
|
7
|
+
module Style
|
8
|
+
module RbsInline
|
9
|
+
# IRB::Inline annotations comments for parameters should be matched to the parameters.
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# # bad
|
13
|
+
# # @rbs unknown: String
|
14
|
+
# def method(arg); end
|
15
|
+
#
|
16
|
+
# # good
|
17
|
+
# # @rbs arg: String
|
18
|
+
# def method(arg); end
|
19
|
+
#
|
20
|
+
class UnmatchedAnnotations < Base
|
21
|
+
include RangeHelp
|
22
|
+
|
23
|
+
MSG = 'target parameter not found.'
|
24
|
+
|
25
|
+
attr_reader :result #: Array[RBS::Inline::AnnotationParser::ParsingResult]
|
26
|
+
|
27
|
+
def on_new_investigation #: void
|
28
|
+
super
|
29
|
+
@result = parse_comments
|
30
|
+
end
|
31
|
+
|
32
|
+
# @rbs node: Parser::AST::Node
|
33
|
+
def on_def(node) #: void
|
34
|
+
arguments = arguments_for(node)
|
35
|
+
|
36
|
+
comment = result.find { |r| r.comments.map(&:location).map(&:start_line).include? node.location.line - 1 }
|
37
|
+
return unless comment
|
38
|
+
|
39
|
+
result.delete(comment)
|
40
|
+
comment.each_annotation do |annotation|
|
41
|
+
case annotation
|
42
|
+
when RBS::Inline::AST::Annotations::VarType, RBS::Inline::AST::Annotations::BlockType
|
43
|
+
add_offense_for(annotation) unless arguments.include?(annotation_name(annotation))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def on_investigation_end #: void
|
49
|
+
result.each do |comment|
|
50
|
+
comment.each_annotation do |annotation|
|
51
|
+
case annotation
|
52
|
+
when RBS::Inline::AST::Annotations::VarType
|
53
|
+
add_offense_for(annotation) unless annotation.name.start_with?('@')
|
54
|
+
when RBS::Inline::AST::Annotations::BlockType, RBS::Inline::AST::Annotations::ReturnType
|
55
|
+
add_offense_for(annotation)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
super
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
# @rbs node: Parser::AST::Node
|
66
|
+
def arguments_for(node) #: Array[String] # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
67
|
+
node.children[1].children.flat_map do |argument|
|
68
|
+
name = argument.children[0]&.to_s
|
69
|
+
case argument.type
|
70
|
+
when :arg, :optarg, :kwarg, :kwoptarg
|
71
|
+
[name]
|
72
|
+
when :restarg
|
73
|
+
if name
|
74
|
+
["*#{name}", '*']
|
75
|
+
else
|
76
|
+
['*']
|
77
|
+
end
|
78
|
+
when :kwrestarg
|
79
|
+
if name
|
80
|
+
["**#{name}", '**']
|
81
|
+
else
|
82
|
+
['**']
|
83
|
+
end
|
84
|
+
when :blockarg
|
85
|
+
if name
|
86
|
+
['&', "&#{name}"]
|
87
|
+
else
|
88
|
+
['&', '&block']
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def parse_comments #: Array[RBS::Inline::AnnotationParser::ParsingResult]
|
95
|
+
parsed_result = Prism.parse(processed_source.buffer.source)
|
96
|
+
RBS::Inline::AnnotationParser.parse(parsed_result.comments)
|
97
|
+
end
|
98
|
+
|
99
|
+
# @rbs annotation: RBS::Inline::AST::Annotations::BlockType |
|
100
|
+
# RBS::Inline::AST::Annotations::ReturnType |
|
101
|
+
# RBS::Inline::AST::Annotations::VarType
|
102
|
+
def annotation_name(annotation) #: String
|
103
|
+
case annotation
|
104
|
+
when RBS::Inline::AST::Annotations::BlockType
|
105
|
+
"&#{annotation.name}"
|
106
|
+
when RBS::Inline::AST::Annotations::ReturnType
|
107
|
+
'return'
|
108
|
+
else
|
109
|
+
annotation.name.to_s
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
# @rbs annotation: RBS::Inline::AST::Annotations::BlockType |
|
114
|
+
# RBS::Inline::AST::Annotations::ReturnType |
|
115
|
+
# RBS::Inline::AST::Annotations::VarType
|
116
|
+
def add_offense_for(annotation) #: void # rubocop:disable Metrics/AbcSize
|
117
|
+
name = annotation_name(annotation)
|
118
|
+
loc = annotation.source.comments.first.location
|
119
|
+
source = processed_source.buffer.source.dup.force_encoding('ASCII')
|
120
|
+
text = source[loc.start_offset...loc.end_offset] or raise
|
121
|
+
comment = text.force_encoding(processed_source.buffer.source.encoding)
|
122
|
+
start_offset = loc.start_offset + (comment.index(name) || 0)
|
123
|
+
range = range_between(character_offset(start_offset), character_offset(start_offset + name.size))
|
124
|
+
add_offense(range)
|
125
|
+
end
|
126
|
+
|
127
|
+
# @rbs byte_offset: Integer
|
128
|
+
def character_offset(byte_offset) #: Integer
|
129
|
+
source = processed_source.buffer.source.dup.force_encoding('ASCII')
|
130
|
+
text = source[...byte_offset] or raise
|
131
|
+
text.force_encoding(processed_source.buffer.source.encoding).size
|
132
|
+
rescue StandardError
|
133
|
+
byte_offset
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The original code is from https://github.com/rubocop/rubocop-rspec/blob/master/lib/rubocop/rspec/inject.rb
|
4
|
+
# See https://github.com/rubocop/rubocop-rspec/blob/master/MIT-LICENSE.md
|
5
|
+
module RuboCop
|
6
|
+
module RbsInline
|
7
|
+
# Because RuboCop doesn't yet support plugins, we have to monkey patch in a
|
8
|
+
# bit of our configuration.
|
9
|
+
module Inject
|
10
|
+
def self.defaults!
|
11
|
+
path = CONFIG_DEFAULT.to_s
|
12
|
+
hash = ConfigLoader.send(:load_yaml_configuration, path)
|
13
|
+
config = Config.new(hash, path).tap(&:make_excludes_absolute) # steep:ignore
|
14
|
+
puts "configuration from #{path}" if ConfigLoader.debug?
|
15
|
+
config = ConfigLoader.merge_with_default(config, path)
|
16
|
+
ConfigLoader.instance_variable_set(:@default_configuration, config)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'rbs_inline/version'
|
4
|
+
|
5
|
+
module RuboCop
|
6
|
+
module RbsInline
|
7
|
+
class Error < StandardError; end
|
8
|
+
# Your code goes here...
|
9
|
+
PROJECT_ROOT = Pathname.new(__dir__ || '').parent.parent.expand_path.freeze
|
10
|
+
CONFIG_DEFAULT = PROJECT_ROOT.join('config', 'default.yml').freeze
|
11
|
+
CONFIG = YAML.safe_load(CONFIG_DEFAULT.read).freeze
|
12
|
+
|
13
|
+
private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT)
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rubocop'
|
4
|
+
|
5
|
+
require_relative 'rubocop/rbs_inline'
|
6
|
+
require_relative 'rubocop/rbs_inline/version'
|
7
|
+
require_relative 'rubocop/rbs_inline/inject'
|
8
|
+
|
9
|
+
RuboCop::RbsInline::Inject.defaults!
|
10
|
+
|
11
|
+
require_relative 'rubocop/cop/rbs_inline_cops'
|
@@ -0,0 +1,140 @@
|
|
1
|
+
---
|
2
|
+
path: ".gem_rbs_collection"
|
3
|
+
gems:
|
4
|
+
- name: ast
|
5
|
+
version: '2.4'
|
6
|
+
source:
|
7
|
+
type: git
|
8
|
+
name: ruby/gem_rbs_collection
|
9
|
+
revision: 7ae9e3cf731a9628e0cc39064ed6e2cf51d822da
|
10
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
11
|
+
repo_dir: gems
|
12
|
+
- name: dbm
|
13
|
+
version: '0'
|
14
|
+
source:
|
15
|
+
type: stdlib
|
16
|
+
- name: diff-lcs
|
17
|
+
version: '1.5'
|
18
|
+
source:
|
19
|
+
type: git
|
20
|
+
name: ruby/gem_rbs_collection
|
21
|
+
revision: 7ae9e3cf731a9628e0cc39064ed6e2cf51d822da
|
22
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
23
|
+
repo_dir: gems
|
24
|
+
- name: fileutils
|
25
|
+
version: '0'
|
26
|
+
source:
|
27
|
+
type: stdlib
|
28
|
+
- name: json
|
29
|
+
version: '0'
|
30
|
+
source:
|
31
|
+
type: stdlib
|
32
|
+
- name: logger
|
33
|
+
version: '0'
|
34
|
+
source:
|
35
|
+
type: stdlib
|
36
|
+
- name: monitor
|
37
|
+
version: '0'
|
38
|
+
source:
|
39
|
+
type: stdlib
|
40
|
+
- name: optparse
|
41
|
+
version: '0'
|
42
|
+
source:
|
43
|
+
type: stdlib
|
44
|
+
- name: parallel
|
45
|
+
version: '1.20'
|
46
|
+
source:
|
47
|
+
type: git
|
48
|
+
name: ruby/gem_rbs_collection
|
49
|
+
revision: 7ae9e3cf731a9628e0cc39064ed6e2cf51d822da
|
50
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
51
|
+
repo_dir: gems
|
52
|
+
- name: parser
|
53
|
+
version: '3.2'
|
54
|
+
source:
|
55
|
+
type: git
|
56
|
+
name: ruby/gem_rbs_collection
|
57
|
+
revision: 7ae9e3cf731a9628e0cc39064ed6e2cf51d822da
|
58
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
59
|
+
repo_dir: gems
|
60
|
+
- name: pathname
|
61
|
+
version: '0'
|
62
|
+
source:
|
63
|
+
type: stdlib
|
64
|
+
- name: prism
|
65
|
+
version: 1.0.0
|
66
|
+
source:
|
67
|
+
type: rubygems
|
68
|
+
- name: pstore
|
69
|
+
version: '0'
|
70
|
+
source:
|
71
|
+
type: stdlib
|
72
|
+
- name: psych
|
73
|
+
version: '0'
|
74
|
+
source:
|
75
|
+
type: stdlib
|
76
|
+
- name: rainbow
|
77
|
+
version: '3.0'
|
78
|
+
source:
|
79
|
+
type: git
|
80
|
+
name: ruby/gem_rbs_collection
|
81
|
+
revision: 7ae9e3cf731a9628e0cc39064ed6e2cf51d822da
|
82
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
83
|
+
repo_dir: gems
|
84
|
+
- name: rake
|
85
|
+
version: '13.0'
|
86
|
+
source:
|
87
|
+
type: git
|
88
|
+
name: ruby/gem_rbs_collection
|
89
|
+
revision: 7ae9e3cf731a9628e0cc39064ed6e2cf51d822da
|
90
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
91
|
+
repo_dir: gems
|
92
|
+
- name: rbs
|
93
|
+
version: 3.5.3
|
94
|
+
source:
|
95
|
+
type: rubygems
|
96
|
+
- name: rbs-inline
|
97
|
+
version: 0.8.0
|
98
|
+
source:
|
99
|
+
type: rubygems
|
100
|
+
- name: rdoc
|
101
|
+
version: '0'
|
102
|
+
source:
|
103
|
+
type: stdlib
|
104
|
+
- name: regexp_parser
|
105
|
+
version: '2.8'
|
106
|
+
source:
|
107
|
+
type: git
|
108
|
+
name: ruby/gem_rbs_collection
|
109
|
+
revision: 7ae9e3cf731a9628e0cc39064ed6e2cf51d822da
|
110
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
111
|
+
repo_dir: gems
|
112
|
+
- name: rubocop
|
113
|
+
version: '1.57'
|
114
|
+
source:
|
115
|
+
type: git
|
116
|
+
name: ruby/gem_rbs_collection
|
117
|
+
revision: 7ae9e3cf731a9628e0cc39064ed6e2cf51d822da
|
118
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
119
|
+
repo_dir: gems
|
120
|
+
- name: rubocop-ast
|
121
|
+
version: '1.30'
|
122
|
+
source:
|
123
|
+
type: git
|
124
|
+
name: ruby/gem_rbs_collection
|
125
|
+
revision: 7ae9e3cf731a9628e0cc39064ed6e2cf51d822da
|
126
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
127
|
+
repo_dir: gems
|
128
|
+
- name: strscan
|
129
|
+
version: '0'
|
130
|
+
source:
|
131
|
+
type: stdlib
|
132
|
+
- name: tsort
|
133
|
+
version: '0'
|
134
|
+
source:
|
135
|
+
type: stdlib
|
136
|
+
- name: yaml
|
137
|
+
version: '0'
|
138
|
+
source:
|
139
|
+
type: stdlib
|
140
|
+
gemfile_lock_path: Gemfile.lock
|
data/rbs_collection.yaml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Download sources
|
2
|
+
sources:
|
3
|
+
- type: git
|
4
|
+
name: ruby/gem_rbs_collection
|
5
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
6
|
+
revision: main
|
7
|
+
repo_dir: gems
|
8
|
+
|
9
|
+
# You can specify local directories as sources also.
|
10
|
+
# - type: local
|
11
|
+
# path: path/to/your/local/repository
|
12
|
+
|
13
|
+
# A directory to install the downloaded RBSs
|
14
|
+
path: .gem_rbs_collection
|
15
|
+
|
16
|
+
gems:
|
17
|
+
- name: strscan
|
18
|
+
- name: yaml
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module RuboCop
|
2
|
+
module Cop
|
3
|
+
class Base
|
4
|
+
def on_new_investigation: () -> void
|
5
|
+
def on_investigation_end: () -> void
|
6
|
+
end
|
7
|
+
|
8
|
+
module RangeHelp
|
9
|
+
def range_between: (Integer start_pos, Integer end_pos) -> Parser::Source::Range
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module RuboCop
|
15
|
+
module Ext
|
16
|
+
module Comment
|
17
|
+
def source: () -> String
|
18
|
+
def source_range: () -> Parser::Source::Range
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
module Parser
|
24
|
+
module Source
|
25
|
+
class Comment
|
26
|
+
include RuboCop::Ext::Comment
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Generated from lib/rubocop/cop/style/rbs_inline/invalid_comment.rb with RBS::Inline
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Style
|
6
|
+
module RbsInline
|
7
|
+
# IRB::Inline expects annotations comments to start with `#:` or `# @rbs`.
|
8
|
+
# This cop checks for comments that do not match the expected pattern.
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# # bad
|
12
|
+
# # () -> void
|
13
|
+
# # : () -> void
|
14
|
+
# # rbs param: String
|
15
|
+
#
|
16
|
+
# # good
|
17
|
+
# #: () -> void
|
18
|
+
# # @rbs param: String
|
19
|
+
class InvalidComment < Base
|
20
|
+
MSG: ::String
|
21
|
+
|
22
|
+
ANNOTATION_KEYWORDS: Array[String]
|
23
|
+
|
24
|
+
SIGNATURE_PATTERN: ::String
|
25
|
+
|
26
|
+
# refs: https://github.com/soutaro/rbs-inline/blob/main/lib/rbs/inline/annotation_parser/tokenizer.rb
|
27
|
+
RBS_INLINE_KEYWORDS: Array[String]
|
28
|
+
|
29
|
+
def on_new_investigation: () -> void
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Generated from lib/rubocop/cop/style/rbs_inline/invalid_types.rb with RBS::Inline
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Style
|
6
|
+
module RbsInline
|
7
|
+
# IRB::Inline expects the types of annotation comments are valid syntax.
|
8
|
+
# This cop checks for comments that do not match the expected pattern.
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# # bad
|
12
|
+
# # @rbs arg: Hash[Symbol,
|
13
|
+
# # @rbs &block: String
|
14
|
+
# def method(arg); end
|
15
|
+
#
|
16
|
+
# # good
|
17
|
+
# # @rbs arg: Hash[Symbol, String]
|
18
|
+
# # @rbs &block: () -> void
|
19
|
+
# def method(arg); end
|
20
|
+
class InvalidTypes < Base
|
21
|
+
include RangeHelp
|
22
|
+
|
23
|
+
include RBS::Inline::AST::Annotations
|
24
|
+
|
25
|
+
MSG: ::String
|
26
|
+
|
27
|
+
def on_new_investigation: () -> void
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def parse_comments: () -> Array[RBS::Inline::AnnotationParser::ParsingResult]
|
32
|
+
|
33
|
+
# @rbs byte_offset: Integer
|
34
|
+
def character_offset: (Integer byte_offset) -> Integer
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Generated from lib/rubocop/cop/style/rbs_inline/keyword_separator.rb with RBS::Inline
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Style
|
6
|
+
module RbsInline
|
7
|
+
# IRB::Inline expects annotations comments for keywords are not separeted with `:`.
|
8
|
+
# This cop checks for comments that do not match the expected pattern.
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# # bad
|
12
|
+
# # @rbs module-self: String
|
13
|
+
#
|
14
|
+
# # good
|
15
|
+
# # @rbs module-self String
|
16
|
+
class KeywordSeparator < Base
|
17
|
+
include RangeHelp
|
18
|
+
|
19
|
+
MSG: ::String
|
20
|
+
|
21
|
+
# refs: https://github.com/soutaro/rbs-inline/blob/main/lib/rbs/inline/annotation_parser/tokenizer.rb
|
22
|
+
RBS_INLINE_KEYWORDS: Array[String]
|
23
|
+
|
24
|
+
def on_new_investigation: () -> void
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
# @rbs comment: Parser::Source::Comment
|
29
|
+
# @rbs matched: MatchData
|
30
|
+
def invalid_location_for: (Parser::Source::Comment comment, MatchData matched) -> Parser::Source::Range
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Generated from lib/rubocop/cop/style/rbs_inline/parameters_separator.rb with RBS::Inline
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Style
|
6
|
+
module RbsInline
|
7
|
+
# IRB::Inline expects annotations comments for parameters are separeted with `:`.
|
8
|
+
# This cop checks for comments that do not match the expected pattern.
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# # bad
|
12
|
+
# # @rbs param String
|
13
|
+
#
|
14
|
+
# # good
|
15
|
+
# # @rbs param: String
|
16
|
+
class ParametersSeparator < Base
|
17
|
+
include RangeHelp
|
18
|
+
|
19
|
+
MSG: ::String
|
20
|
+
|
21
|
+
# refs: https://github.com/soutaro/rbs-inline/blob/main/lib/rbs/inline/annotation_parser/tokenizer.rb
|
22
|
+
RBS_INLINE_KEYWORDS: Array[String]
|
23
|
+
|
24
|
+
def on_new_investigation: () -> void
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
# @rbs comment: Parser::Source::Comment
|
29
|
+
def invalid_location_for: (Parser::Source::Comment comment) -> Parser::Source::Range
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Generated from lib/rubocop/cop/style/rbs_inline/unmatched_annotations.rb with RBS::Inline
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Style
|
6
|
+
module RbsInline
|
7
|
+
# IRB::Inline annotations comments for parameters should be matched to the parameters.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# # bad
|
11
|
+
# # @rbs unknown: String
|
12
|
+
# def method(arg); end
|
13
|
+
#
|
14
|
+
# # good
|
15
|
+
# # @rbs arg: String
|
16
|
+
# def method(arg); end
|
17
|
+
class UnmatchedAnnotations < Base
|
18
|
+
include RangeHelp
|
19
|
+
|
20
|
+
MSG: ::String
|
21
|
+
|
22
|
+
attr_reader result: Array[RBS::Inline::AnnotationParser::ParsingResult]
|
23
|
+
|
24
|
+
def on_new_investigation: () -> void
|
25
|
+
|
26
|
+
# @rbs node: Parser::AST::Node
|
27
|
+
def on_def: (Parser::AST::Node node) -> void
|
28
|
+
|
29
|
+
def on_investigation_end: () -> void
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
# @rbs node: Parser::AST::Node
|
34
|
+
def arguments_for: (Parser::AST::Node node) -> Array[String]
|
35
|
+
|
36
|
+
def parse_comments: () -> Array[RBS::Inline::AnnotationParser::ParsingResult]
|
37
|
+
|
38
|
+
# @rbs annotation: RBS::Inline::AST::Annotations::BlockType |
|
39
|
+
# RBS::Inline::AST::Annotations::ReturnType |
|
40
|
+
# RBS::Inline::AST::Annotations::VarType
|
41
|
+
def annotation_name: (RBS::Inline::AST::Annotations::BlockType | RBS::Inline::AST::Annotations::ReturnType | RBS::Inline::AST::Annotations::VarType annotation) -> String
|
42
|
+
|
43
|
+
# @rbs annotation: RBS::Inline::AST::Annotations::BlockType |
|
44
|
+
# RBS::Inline::AST::Annotations::ReturnType |
|
45
|
+
# RBS::Inline::AST::Annotations::VarType
|
46
|
+
def add_offense_for: (RBS::Inline::AST::Annotations::BlockType | RBS::Inline::AST::Annotations::ReturnType | RBS::Inline::AST::Annotations::VarType annotation) -> void
|
47
|
+
|
48
|
+
# @rbs byte_offset: Integer
|
49
|
+
def character_offset: (Integer byte_offset) -> Integer
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Generated from lib/rubocop/rbs_inline/inject.rb with RBS::Inline
|
2
|
+
|
3
|
+
# The original code is from https://github.com/rubocop/rubocop-rspec/blob/master/lib/rubocop/rspec/inject.rb
|
4
|
+
# See https://github.com/rubocop/rubocop-rspec/blob/master/MIT-LICENSE.md
|
5
|
+
module RuboCop
|
6
|
+
module RbsInline
|
7
|
+
# Because RuboCop doesn't yet support plugins, we have to monkey patch in a
|
8
|
+
# bit of our configuration.
|
9
|
+
module Inject
|
10
|
+
def self.defaults!: () -> untyped
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Generated from lib/rubocop/rbs_inline.rb with RBS::Inline
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module RbsInline
|
5
|
+
class Error < StandardError
|
6
|
+
end
|
7
|
+
|
8
|
+
# Your code goes here...
|
9
|
+
PROJECT_ROOT: untyped
|
10
|
+
|
11
|
+
CONFIG_DEFAULT: untyped
|
12
|
+
|
13
|
+
CONFIG: untyped
|
14
|
+
end
|
15
|
+
end
|