rubocop-rbs_inline 1.7.0 → 1.8.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/.claude/hooks/self-review.sh +89 -0
- data/.claude/settings.json +8 -0
- data/.rubocop.yml +9 -3
- data/CHANGELOG.md +19 -0
- data/CLAUDE.md +9 -14
- data/README.md +54 -6
- data/config/default.yml +3 -4
- data/lib/rubocop/cop/rbs_inline_cops.rb +15 -7
- data/lib/rubocop/cop/style/rbs_inline/data_class_comment_alignment.rb +2 -9
- data/lib/rubocop/cop/style/rbs_inline/data_define_with_block.rb +3 -9
- data/lib/rubocop/cop/style/rbs_inline/embedded_rbs_spacing.rb +3 -2
- data/lib/rubocop/cop/style/rbs_inline/invalid_comment.rb +2 -2
- data/lib/rubocop/cop/style/rbs_inline/invalid_types.rb +1 -0
- data/lib/rubocop/cop/style/rbs_inline/keyword_separator.rb +2 -2
- data/lib/rubocop/cop/style/rbs_inline/method_comment_spacing.rb +3 -2
- data/lib/rubocop/cop/style/rbs_inline/missing_data_class_annotation.rb +2 -9
- data/lib/rubocop/cop/style/rbs_inline/missing_struct_class_annotation.rb +2 -16
- data/lib/rubocop/cop/style/rbs_inline/missing_type_annotation.rb +3 -16
- data/lib/rubocop/cop/style/rbs_inline/mixin/annotation_keywords.rb +16 -0
- data/lib/rubocop/cop/style/rbs_inline/{ast_utils.rb → mixin/ast_utils.rb} +16 -0
- data/lib/rubocop/cop/style/rbs_inline/{comment_parser.rb → mixin/comment_parser.rb} +8 -0
- data/lib/rubocop/cop/style/rbs_inline/mixin/data_class_matcher.rb +22 -0
- data/lib/rubocop/cop/style/rbs_inline/{data_struct_helper.rb → mixin/data_struct_helper.rb} +14 -5
- data/lib/rubocop/cop/style/rbs_inline/mixin/file_filter.rb +110 -0
- data/lib/rubocop/cop/style/rbs_inline/{source_code_helper.rb → mixin/source_code_helper.rb} +3 -5
- data/lib/rubocop/cop/style/rbs_inline/mixin/struct_class_matcher.rb +32 -0
- data/lib/rubocop/cop/style/rbs_inline/parameters_separator.rb +2 -2
- data/lib/rubocop/cop/style/rbs_inline/redundant_annotation_with_skip.rb +2 -11
- data/lib/rubocop/cop/style/rbs_inline/redundant_instance_variable_annotation.rb +1 -0
- data/lib/rubocop/cop/style/rbs_inline/redundant_type_annotation.rb +6 -15
- data/lib/rubocop/cop/style/rbs_inline/require_rbs_inline_comment.rb +74 -23
- data/lib/rubocop/cop/style/rbs_inline/struct_class_comment_alignment.rb +2 -16
- data/lib/rubocop/cop/style/rbs_inline/struct_new_with_block.rb +3 -9
- data/lib/rubocop/cop/style/rbs_inline/unmatched_annotations.rb +31 -6
- data/lib/rubocop/cop/style/rbs_inline/untyped_instance_variable.rb +16 -6
- data/lib/rubocop/cop/style/rbs_inline/variable_comment_spacing.rb +3 -2
- data/lib/rubocop/rbs_inline/version.rb +1 -1
- data/sig/gems/rubocop/rubocop.rbs +8 -0
- data/sig/rubocop/cop/style/rbs_inline/data_class_comment_alignment.rbs +4 -5
- data/sig/rubocop/cop/style/rbs_inline/data_define_with_block.rbs +4 -5
- data/sig/rubocop/cop/style/rbs_inline/embedded_rbs_spacing.rbs +2 -0
- data/sig/rubocop/cop/style/rbs_inline/invalid_comment.rbs +4 -3
- data/sig/rubocop/cop/style/rbs_inline/invalid_types.rbs +2 -0
- data/sig/rubocop/cop/style/rbs_inline/keyword_separator.rbs +4 -3
- data/sig/rubocop/cop/style/rbs_inline/method_comment_spacing.rbs +2 -0
- data/sig/rubocop/cop/style/rbs_inline/missing_data_class_annotation.rbs +4 -5
- data/sig/rubocop/cop/style/rbs_inline/missing_struct_class_annotation.rbs +4 -10
- data/sig/rubocop/cop/style/rbs_inline/missing_type_annotation.rbs +4 -8
- data/sig/rubocop/cop/style/rbs_inline/mixin/annotation_keywords.rbs +16 -0
- data/sig/rubocop/cop/style/rbs_inline/{ast_utils.rbs → mixin/ast_utils.rbs} +9 -1
- data/sig/rubocop/cop/style/rbs_inline/{class_comment_alignment.rbs → mixin/class_comment_alignment.rbs} +1 -1
- data/sig/rubocop/cop/style/rbs_inline/{comment_parser.rbs → mixin/comment_parser.rbs} +5 -1
- data/sig/rubocop/cop/style/rbs_inline/mixin/data_class_matcher.rbs +18 -0
- data/sig/rubocop/cop/style/rbs_inline/{data_struct_helper.rbs → mixin/data_struct_helper.rbs} +6 -1
- data/sig/rubocop/cop/style/rbs_inline/mixin/file_filter.rbs +63 -0
- data/sig/rubocop/cop/style/rbs_inline/{missing_class_annotation.rbs → mixin/missing_class_annotation.rbs} +1 -1
- data/sig/rubocop/cop/style/rbs_inline/{source_code_helper.rbs → mixin/source_code_helper.rbs} +1 -1
- data/sig/rubocop/cop/style/rbs_inline/mixin/struct_class_matcher.rbs +26 -0
- data/sig/rubocop/cop/style/rbs_inline/parameters_separator.rbs +4 -3
- data/sig/rubocop/cop/style/rbs_inline/redundant_annotation_with_skip.rbs +4 -4
- data/sig/rubocop/cop/style/rbs_inline/redundant_instance_variable_annotation.rbs +2 -0
- data/sig/rubocop/cop/style/rbs_inline/redundant_type_annotation.rbs +4 -4
- data/sig/rubocop/cop/style/rbs_inline/require_rbs_inline_comment.rbs +30 -5
- data/sig/rubocop/cop/style/rbs_inline/struct_class_comment_alignment.rbs +4 -10
- data/sig/rubocop/cop/style/rbs_inline/struct_new_with_block.rbs +4 -5
- data/sig/rubocop/cop/style/rbs_inline/unmatched_annotations.rbs +13 -0
- data/sig/rubocop/cop/style/rbs_inline/untyped_instance_variable.rbs +10 -0
- data/sig/rubocop/cop/style/rbs_inline/variable_comment_spacing.rbs +2 -0
- metadata +24 -17
- data/sig/rubocop/cop/style/rbs_inline/redundant_argument_type.rbs +0 -85
- data/sig/rubocop/cop/style/rbs_inline/redundant_return_type.rbs +0 -109
- /data/lib/rubocop/cop/style/rbs_inline/{class_comment_alignment.rb → mixin/class_comment_alignment.rb} +0 -0
- /data/lib/rubocop/cop/style/rbs_inline/{missing_class_annotation.rb → mixin/missing_class_annotation.rb} +0 -0
|
@@ -23,24 +23,18 @@ module RuboCop
|
|
|
23
23
|
# :y #: Integer
|
|
24
24
|
# )
|
|
25
25
|
class StructClassCommentAlignment < Base
|
|
26
|
+
prepend FileFilter
|
|
27
|
+
|
|
26
28
|
include ClassCommentAlignment
|
|
27
29
|
|
|
30
|
+
include StructClassMatcher
|
|
31
|
+
|
|
28
32
|
extend AutoCorrector
|
|
29
33
|
|
|
30
34
|
MSG: ::String
|
|
31
35
|
|
|
32
36
|
# @rbs node: RuboCop::AST::SendNode
|
|
33
37
|
def on_send: (RuboCop::AST::SendNode node) -> void
|
|
34
|
-
|
|
35
|
-
private
|
|
36
|
-
|
|
37
|
-
# @rbs node: RuboCop::AST::SendNode
|
|
38
|
-
def struct_like_class?: (RuboCop::AST::SendNode node) -> bool
|
|
39
|
-
|
|
40
|
-
# `Struct.new` treats a leading string argument as the struct name, so only
|
|
41
|
-
# symbol arguments are attributes.
|
|
42
|
-
# @rbs arg: RuboCop::AST::Node
|
|
43
|
-
def attr_argument?: (RuboCop::AST::Node arg) -> bool
|
|
44
38
|
end
|
|
45
39
|
end
|
|
46
40
|
end
|
|
@@ -24,15 +24,14 @@ module RuboCop
|
|
|
24
24
|
# def admin? = role == :admin #: bool
|
|
25
25
|
# end
|
|
26
26
|
class StructNewWithBlock < Base
|
|
27
|
-
|
|
27
|
+
prepend FileFilter
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
def on_send: (RuboCop::AST::SendNode node) -> void
|
|
29
|
+
include StructClassMatcher
|
|
31
30
|
|
|
32
|
-
|
|
31
|
+
MSG: ::String
|
|
33
32
|
|
|
34
33
|
# @rbs node: RuboCop::AST::SendNode
|
|
35
|
-
def
|
|
34
|
+
def on_send: (RuboCop::AST::SendNode node) -> void
|
|
36
35
|
end
|
|
37
36
|
end
|
|
38
37
|
end
|
|
@@ -15,6 +15,8 @@ module RuboCop
|
|
|
15
15
|
# # @rbs arg: String
|
|
16
16
|
# def method(arg); end
|
|
17
17
|
class UnmatchedAnnotations < Base
|
|
18
|
+
prepend FileFilter
|
|
19
|
+
|
|
18
20
|
include CommentParser
|
|
19
21
|
|
|
20
22
|
include RangeHelp
|
|
@@ -23,6 +25,8 @@ module RuboCop
|
|
|
23
25
|
|
|
24
26
|
MSG: ::String
|
|
25
27
|
|
|
28
|
+
attr_reader processed_comments: Set[RBS::Inline::AnnotationParser::ParsingResult]
|
|
29
|
+
|
|
26
30
|
def on_new_investigation: () -> void
|
|
27
31
|
|
|
28
32
|
# @rbs node: RuboCop::AST::DefNode
|
|
@@ -38,6 +42,15 @@ module RuboCop
|
|
|
38
42
|
# @rbs node: RuboCop::AST::DefNode
|
|
39
43
|
def process: (RuboCop::AST::DefNode node) -> void
|
|
40
44
|
|
|
45
|
+
# @rbs node: RuboCop::AST::DefNode
|
|
46
|
+
def leading_comment_for: (RuboCop::AST::DefNode node) -> RBS::Inline::AnnotationParser::ParsingResult?
|
|
47
|
+
|
|
48
|
+
# @rbs comment: RBS::Inline::AnnotationParser::ParsingResult
|
|
49
|
+
def mark_processed: (RBS::Inline::AnnotationParser::ParsingResult comment) -> void
|
|
50
|
+
|
|
51
|
+
# @rbs comment: RBS::Inline::AnnotationParser::ParsingResult
|
|
52
|
+
def processed?: (RBS::Inline::AnnotationParser::ParsingResult comment) -> bool
|
|
53
|
+
|
|
41
54
|
# @rbs node: RuboCop::AST::DefNode
|
|
42
55
|
def arguments_for: (RuboCop::AST::DefNode node) -> Array[String]
|
|
43
56
|
|
|
@@ -56,6 +56,8 @@ module RuboCop
|
|
|
56
56
|
# end
|
|
57
57
|
# end
|
|
58
58
|
class UntypedInstanceVariable < Base
|
|
59
|
+
prepend FileFilter
|
|
60
|
+
|
|
59
61
|
include ASTUtils
|
|
60
62
|
|
|
61
63
|
include CommentParser
|
|
@@ -125,6 +127,14 @@ module RuboCop
|
|
|
125
127
|
# @rbs node: RuboCop::AST::Node
|
|
126
128
|
def collect_typed_ivars_for_scope: (RuboCop::AST::Node node) -> void
|
|
127
129
|
|
|
130
|
+
# Moves the annotations placed within +lines+ from +annotations+ into +typed+
|
|
131
|
+
# so that outer scopes no longer see them.
|
|
132
|
+
#
|
|
133
|
+
# @rbs annotations: Hash[Integer, Symbol]
|
|
134
|
+
# @rbs typed: Set[Symbol]
|
|
135
|
+
# @rbs lines: Range[Integer]
|
|
136
|
+
def move_annotations: (Hash[Integer, Symbol] annotations, Set[Symbol] typed, Range[Integer] lines) -> void
|
|
137
|
+
|
|
128
138
|
def collect_ivar_type_annotations: () -> [ Hash[Integer, Symbol], Hash[Integer, Symbol] ]
|
|
129
139
|
|
|
130
140
|
# @rbs ann: RBS::Inline::AST::Annotations::IvarType
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubocop-rbs_inline
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Takeshi KOMIYA
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-07-
|
|
11
|
+
date: 2026-07-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: lint_roller
|
|
@@ -67,6 +67,7 @@ extra_rdoc_files: []
|
|
|
67
67
|
files:
|
|
68
68
|
- ".claude/hooks/pre-commit-check.sh"
|
|
69
69
|
- ".claude/hooks/rbs-inline.sh"
|
|
70
|
+
- ".claude/hooks/self-review.sh"
|
|
70
71
|
- ".claude/hooks/setup.sh"
|
|
71
72
|
- ".claude/settings.json"
|
|
72
73
|
- ".rspec"
|
|
@@ -83,27 +84,31 @@ files:
|
|
|
83
84
|
- config/default.yml
|
|
84
85
|
- lib/rubocop-rbs_inline.rb
|
|
85
86
|
- lib/rubocop/cop/rbs_inline_cops.rb
|
|
86
|
-
- lib/rubocop/cop/style/rbs_inline/ast_utils.rb
|
|
87
|
-
- lib/rubocop/cop/style/rbs_inline/class_comment_alignment.rb
|
|
88
|
-
- lib/rubocop/cop/style/rbs_inline/comment_parser.rb
|
|
89
87
|
- lib/rubocop/cop/style/rbs_inline/data_class_comment_alignment.rb
|
|
90
88
|
- lib/rubocop/cop/style/rbs_inline/data_define_with_block.rb
|
|
91
|
-
- lib/rubocop/cop/style/rbs_inline/data_struct_helper.rb
|
|
92
89
|
- lib/rubocop/cop/style/rbs_inline/embedded_rbs_spacing.rb
|
|
93
90
|
- lib/rubocop/cop/style/rbs_inline/invalid_comment.rb
|
|
94
91
|
- lib/rubocop/cop/style/rbs_inline/invalid_types.rb
|
|
95
92
|
- lib/rubocop/cop/style/rbs_inline/keyword_separator.rb
|
|
96
93
|
- lib/rubocop/cop/style/rbs_inline/method_comment_spacing.rb
|
|
97
|
-
- lib/rubocop/cop/style/rbs_inline/missing_class_annotation.rb
|
|
98
94
|
- lib/rubocop/cop/style/rbs_inline/missing_data_class_annotation.rb
|
|
99
95
|
- lib/rubocop/cop/style/rbs_inline/missing_struct_class_annotation.rb
|
|
100
96
|
- lib/rubocop/cop/style/rbs_inline/missing_type_annotation.rb
|
|
97
|
+
- lib/rubocop/cop/style/rbs_inline/mixin/annotation_keywords.rb
|
|
98
|
+
- lib/rubocop/cop/style/rbs_inline/mixin/ast_utils.rb
|
|
99
|
+
- lib/rubocop/cop/style/rbs_inline/mixin/class_comment_alignment.rb
|
|
100
|
+
- lib/rubocop/cop/style/rbs_inline/mixin/comment_parser.rb
|
|
101
|
+
- lib/rubocop/cop/style/rbs_inline/mixin/data_class_matcher.rb
|
|
102
|
+
- lib/rubocop/cop/style/rbs_inline/mixin/data_struct_helper.rb
|
|
103
|
+
- lib/rubocop/cop/style/rbs_inline/mixin/file_filter.rb
|
|
104
|
+
- lib/rubocop/cop/style/rbs_inline/mixin/missing_class_annotation.rb
|
|
105
|
+
- lib/rubocop/cop/style/rbs_inline/mixin/source_code_helper.rb
|
|
106
|
+
- lib/rubocop/cop/style/rbs_inline/mixin/struct_class_matcher.rb
|
|
101
107
|
- lib/rubocop/cop/style/rbs_inline/parameters_separator.rb
|
|
102
108
|
- lib/rubocop/cop/style/rbs_inline/redundant_annotation_with_skip.rb
|
|
103
109
|
- lib/rubocop/cop/style/rbs_inline/redundant_instance_variable_annotation.rb
|
|
104
110
|
- lib/rubocop/cop/style/rbs_inline/redundant_type_annotation.rb
|
|
105
111
|
- lib/rubocop/cop/style/rbs_inline/require_rbs_inline_comment.rb
|
|
106
|
-
- lib/rubocop/cop/style/rbs_inline/source_code_helper.rb
|
|
107
112
|
- lib/rubocop/cop/style/rbs_inline/struct_class_comment_alignment.rb
|
|
108
113
|
- lib/rubocop/cop/style/rbs_inline/struct_new_with_block.rb
|
|
109
114
|
- lib/rubocop/cop/style/rbs_inline/unmatched_annotations.rb
|
|
@@ -117,29 +122,31 @@ files:
|
|
|
117
122
|
- sig/gems/rubocop/rubocop.rbs
|
|
118
123
|
- sig/rubocop-rbs_inline.rbs
|
|
119
124
|
- sig/rubocop/cop/rbs_inline_cops.rbs
|
|
120
|
-
- sig/rubocop/cop/style/rbs_inline/ast_utils.rbs
|
|
121
|
-
- sig/rubocop/cop/style/rbs_inline/class_comment_alignment.rbs
|
|
122
|
-
- sig/rubocop/cop/style/rbs_inline/comment_parser.rbs
|
|
123
125
|
- sig/rubocop/cop/style/rbs_inline/data_class_comment_alignment.rbs
|
|
124
126
|
- sig/rubocop/cop/style/rbs_inline/data_define_with_block.rbs
|
|
125
|
-
- sig/rubocop/cop/style/rbs_inline/data_struct_helper.rbs
|
|
126
127
|
- sig/rubocop/cop/style/rbs_inline/embedded_rbs_spacing.rbs
|
|
127
128
|
- sig/rubocop/cop/style/rbs_inline/invalid_comment.rbs
|
|
128
129
|
- sig/rubocop/cop/style/rbs_inline/invalid_types.rbs
|
|
129
130
|
- sig/rubocop/cop/style/rbs_inline/keyword_separator.rbs
|
|
130
131
|
- sig/rubocop/cop/style/rbs_inline/method_comment_spacing.rbs
|
|
131
|
-
- sig/rubocop/cop/style/rbs_inline/missing_class_annotation.rbs
|
|
132
132
|
- sig/rubocop/cop/style/rbs_inline/missing_data_class_annotation.rbs
|
|
133
133
|
- sig/rubocop/cop/style/rbs_inline/missing_struct_class_annotation.rbs
|
|
134
134
|
- sig/rubocop/cop/style/rbs_inline/missing_type_annotation.rbs
|
|
135
|
+
- sig/rubocop/cop/style/rbs_inline/mixin/annotation_keywords.rbs
|
|
136
|
+
- sig/rubocop/cop/style/rbs_inline/mixin/ast_utils.rbs
|
|
137
|
+
- sig/rubocop/cop/style/rbs_inline/mixin/class_comment_alignment.rbs
|
|
138
|
+
- sig/rubocop/cop/style/rbs_inline/mixin/comment_parser.rbs
|
|
139
|
+
- sig/rubocop/cop/style/rbs_inline/mixin/data_class_matcher.rbs
|
|
140
|
+
- sig/rubocop/cop/style/rbs_inline/mixin/data_struct_helper.rbs
|
|
141
|
+
- sig/rubocop/cop/style/rbs_inline/mixin/file_filter.rbs
|
|
142
|
+
- sig/rubocop/cop/style/rbs_inline/mixin/missing_class_annotation.rbs
|
|
143
|
+
- sig/rubocop/cop/style/rbs_inline/mixin/source_code_helper.rbs
|
|
144
|
+
- sig/rubocop/cop/style/rbs_inline/mixin/struct_class_matcher.rbs
|
|
135
145
|
- sig/rubocop/cop/style/rbs_inline/parameters_separator.rbs
|
|
136
146
|
- sig/rubocop/cop/style/rbs_inline/redundant_annotation_with_skip.rbs
|
|
137
|
-
- sig/rubocop/cop/style/rbs_inline/redundant_argument_type.rbs
|
|
138
147
|
- sig/rubocop/cop/style/rbs_inline/redundant_instance_variable_annotation.rbs
|
|
139
|
-
- sig/rubocop/cop/style/rbs_inline/redundant_return_type.rbs
|
|
140
148
|
- sig/rubocop/cop/style/rbs_inline/redundant_type_annotation.rbs
|
|
141
149
|
- sig/rubocop/cop/style/rbs_inline/require_rbs_inline_comment.rbs
|
|
142
|
-
- sig/rubocop/cop/style/rbs_inline/source_code_helper.rbs
|
|
143
150
|
- sig/rubocop/cop/style/rbs_inline/struct_class_comment_alignment.rbs
|
|
144
151
|
- sig/rubocop/cop/style/rbs_inline/struct_new_with_block.rbs
|
|
145
152
|
- sig/rubocop/cop/style/rbs_inline/unmatched_annotations.rbs
|
|
@@ -154,7 +161,7 @@ licenses:
|
|
|
154
161
|
metadata:
|
|
155
162
|
homepage_uri: https://github.com/tk0miya/rubocop-rbs_inline
|
|
156
163
|
source_code_uri: https://github.com/tk0miya/rubocop-rbs_inline
|
|
157
|
-
changelog_uri: https://github.com/tk0miya/rubocop-rbs_inline
|
|
164
|
+
changelog_uri: https://github.com/tk0miya/rubocop-rbs_inline/blob/main/CHANGELOG.md
|
|
158
165
|
rubygems_mfa_required: 'true'
|
|
159
166
|
default_lint_roller_plugin: RuboCop::RbsInline::Plugin
|
|
160
167
|
post_install_message:
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
# Generated from lib/rubocop/cop/style/rbs_inline/redundant_argument_type.rb with RBS::Inline
|
|
2
|
-
|
|
3
|
-
module RuboCop
|
|
4
|
-
module Cop
|
|
5
|
-
module Style
|
|
6
|
-
module RbsInline
|
|
7
|
-
# Checks for redundant argument type annotations when both
|
|
8
|
-
# annotation comments (`#:`) and `@rbs` parameter comments
|
|
9
|
-
# specify argument types for the same method.
|
|
10
|
-
#
|
|
11
|
-
# Supports two styles:
|
|
12
|
-
# - `method_type_signature`: Prefers `#:` annotation comments with parameter types
|
|
13
|
-
# - `doc_style`: Prefers `# @rbs param:` annotations for parameter types
|
|
14
|
-
#
|
|
15
|
-
# @example EnforcedStyle: method_type_signature
|
|
16
|
-
# # bad
|
|
17
|
-
# # @rbs a: Integer
|
|
18
|
-
# #: (Integer) -> void
|
|
19
|
-
# def method(a)
|
|
20
|
-
# end
|
|
21
|
-
#
|
|
22
|
-
# # good
|
|
23
|
-
# #: (Integer) -> void
|
|
24
|
-
# def method(a)
|
|
25
|
-
# end
|
|
26
|
-
#
|
|
27
|
-
# # good
|
|
28
|
-
# # @rbs a: Integer
|
|
29
|
-
# def method(a) #: void
|
|
30
|
-
# end
|
|
31
|
-
#
|
|
32
|
-
# @example EnforcedStyle: doc_style (default)
|
|
33
|
-
# # bad
|
|
34
|
-
# # @rbs a: Integer
|
|
35
|
-
# #: (Integer) -> void
|
|
36
|
-
# def method(a)
|
|
37
|
-
# end
|
|
38
|
-
#
|
|
39
|
-
# # good
|
|
40
|
-
# # @rbs a: Integer
|
|
41
|
-
# def method(a) #: void
|
|
42
|
-
# end
|
|
43
|
-
#
|
|
44
|
-
# # good
|
|
45
|
-
# #: (Integer) -> void
|
|
46
|
-
# def method(a)
|
|
47
|
-
# end
|
|
48
|
-
class RedundantArgumentType < Base
|
|
49
|
-
extend AutoCorrector
|
|
50
|
-
|
|
51
|
-
include CommentParser
|
|
52
|
-
|
|
53
|
-
include ConfigurableEnforcedStyle
|
|
54
|
-
|
|
55
|
-
include RangeHelp
|
|
56
|
-
|
|
57
|
-
MSG_RBS_PARAM: ::String
|
|
58
|
-
|
|
59
|
-
MSG_ANNOTATION: ::String
|
|
60
|
-
|
|
61
|
-
def on_new_investigation: () -> void
|
|
62
|
-
|
|
63
|
-
# @rbs node: RuboCop::AST::DefNode
|
|
64
|
-
def on_def: (RuboCop::AST::DefNode node) -> void
|
|
65
|
-
|
|
66
|
-
alias on_defs on_def
|
|
67
|
-
|
|
68
|
-
private
|
|
69
|
-
|
|
70
|
-
# @rbs node: RuboCop::AST::DefNode
|
|
71
|
-
def process: (RuboCop::AST::DefNode node) -> void
|
|
72
|
-
|
|
73
|
-
# @rbs comments: Array[Parser::Source::Comment]
|
|
74
|
-
def add_offense_for_annotation: (Array[Parser::Source::Comment] comments) -> void
|
|
75
|
-
|
|
76
|
-
# @rbs annotation: RBS::Inline::AST::Annotations::VarType | RBS::Inline::AST::Annotations::BlockType
|
|
77
|
-
def add_offense_for_rbs_param: (RBS::Inline::AST::Annotations::VarType | RBS::Inline::AST::Annotations::BlockType annotation) -> void
|
|
78
|
-
|
|
79
|
-
# @rbs def_line: Integer
|
|
80
|
-
def find_param_annotations: (Integer def_line) -> Array[RBS::Inline::AST::Annotations::VarType | RBS::Inline::AST::Annotations::BlockType]?
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
# Generated from lib/rubocop/cop/style/rbs_inline/redundant_return_type.rb with RBS::Inline
|
|
2
|
-
|
|
3
|
-
module RuboCop
|
|
4
|
-
module Cop
|
|
5
|
-
module Style
|
|
6
|
-
module RbsInline
|
|
7
|
-
# Checks for redundant return type annotations when multiple
|
|
8
|
-
# return type specifications exist on the same method definition.
|
|
9
|
-
#
|
|
10
|
-
# Supports three styles:
|
|
11
|
-
# - `method_type_signature`: Prefers `#:` annotation comments before the method
|
|
12
|
-
# - `return_type_annotation`: Prefers inline `#:` return type on the def line
|
|
13
|
-
# - `doc_style`: Prefers `# @rbs return` annotations
|
|
14
|
-
#
|
|
15
|
-
# @example EnforcedStyle: method_type_signature
|
|
16
|
-
# # bad
|
|
17
|
-
# #: () -> String
|
|
18
|
-
# def method(arg) #: String
|
|
19
|
-
# end
|
|
20
|
-
#
|
|
21
|
-
# # bad
|
|
22
|
-
# # @rbs return: String
|
|
23
|
-
# #: () -> String
|
|
24
|
-
# def method(arg)
|
|
25
|
-
# end
|
|
26
|
-
#
|
|
27
|
-
# # good
|
|
28
|
-
# #: () -> String
|
|
29
|
-
# def method(arg)
|
|
30
|
-
# end
|
|
31
|
-
#
|
|
32
|
-
# @example EnforcedStyle: return_type_annotation (default)
|
|
33
|
-
# # bad
|
|
34
|
-
# # @rbs return: String
|
|
35
|
-
# def method(arg) #: String
|
|
36
|
-
# end
|
|
37
|
-
#
|
|
38
|
-
# # bad
|
|
39
|
-
# #: () -> String
|
|
40
|
-
# def method(arg) #: String
|
|
41
|
-
# end
|
|
42
|
-
#
|
|
43
|
-
# # good
|
|
44
|
-
# def method(arg) #: String
|
|
45
|
-
# end
|
|
46
|
-
#
|
|
47
|
-
# @example EnforcedStyle: doc_style
|
|
48
|
-
# # bad
|
|
49
|
-
# # @rbs return: String
|
|
50
|
-
# def method(arg) #: String
|
|
51
|
-
# end
|
|
52
|
-
#
|
|
53
|
-
# # bad
|
|
54
|
-
# # @rbs return: String
|
|
55
|
-
# #: () -> String
|
|
56
|
-
# def method(arg)
|
|
57
|
-
# end
|
|
58
|
-
#
|
|
59
|
-
# # good
|
|
60
|
-
# # @rbs return: String
|
|
61
|
-
# def method(arg)
|
|
62
|
-
# end
|
|
63
|
-
class RedundantReturnType < Base
|
|
64
|
-
extend AutoCorrector
|
|
65
|
-
|
|
66
|
-
include CommentParser
|
|
67
|
-
|
|
68
|
-
include ConfigurableEnforcedStyle
|
|
69
|
-
|
|
70
|
-
include RangeHelp
|
|
71
|
-
|
|
72
|
-
MSG_RBS_RETURN: ::String
|
|
73
|
-
|
|
74
|
-
MSG_INLINE: ::String
|
|
75
|
-
|
|
76
|
-
MSG_ANNOTATION: ::String
|
|
77
|
-
|
|
78
|
-
def on_new_investigation: () -> void
|
|
79
|
-
|
|
80
|
-
# @rbs node: RuboCop::AST::DefNode
|
|
81
|
-
def on_def: (RuboCop::AST::DefNode node) -> void
|
|
82
|
-
|
|
83
|
-
alias on_defs on_def
|
|
84
|
-
|
|
85
|
-
private
|
|
86
|
-
|
|
87
|
-
# @rbs node: RuboCop::AST::DefNode
|
|
88
|
-
def process: (RuboCop::AST::DefNode node) -> void
|
|
89
|
-
|
|
90
|
-
# @rbs type: Symbol
|
|
91
|
-
# @rbs value: Object
|
|
92
|
-
# @rbs correctable: bool
|
|
93
|
-
def add_offense_for: (Symbol type, Object value, correctable: bool) -> void
|
|
94
|
-
|
|
95
|
-
# @rbs comments: Array[Parser::Source::Comment]
|
|
96
|
-
def add_offense_for_annotation: (Array[Parser::Source::Comment] comments) -> void
|
|
97
|
-
|
|
98
|
-
# @rbs comment: Parser::Source::Comment
|
|
99
|
-
# @rbs correctable: bool
|
|
100
|
-
def add_offense_for_inline: (Parser::Source::Comment comment, correctable: bool) -> void
|
|
101
|
-
|
|
102
|
-
# @rbs annotation: RBS::Inline::AST::Annotations::ReturnType
|
|
103
|
-
# @rbs correctable: bool
|
|
104
|
-
def add_offense_for_rbs_return: (RBS::Inline::AST::Annotations::ReturnType annotation, correctable: bool) -> void
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
end
|
|
File without changes
|
|
File without changes
|