rubocop-rbs_inline 1.7.0 → 2.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 +4 -4
- data/.claude/hooks/pre-commit-check.sh +42 -2
- data/.claude/hooks/protect-sig-files.sh +45 -0
- data/.claude/hooks/self-review.sh +89 -0
- data/.claude/settings.json +16 -1
- data/.rubocop.yml +17 -12
- data/CHANGELOG.md +30 -0
- data/CLAUDE.md +11 -14
- data/README.md +51 -6
- data/Rakefile +12 -3
- data/config/default.yml +2 -4
- data/lib/rubocop/cop/rbs_inline_cops.rb +16 -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 +13 -7
- 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/mixin/ast_utils.rb +75 -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 +72 -0
- data/lib/rubocop/cop/style/rbs_inline/mixin/mode_config.rb +39 -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 +35 -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 +13 -7
- 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/rbs_collection.lock.yaml +11 -11
- data/sig/gems/rubocop/rubocop.rbs +14 -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 +9 -2
- 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} +14 -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 +53 -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/mixin/mode_config.rbs +27 -0
- 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 +22 -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 +9 -2
- 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 +28 -18
- data/lib/rubocop/cop/style/rbs_inline/ast_utils.rb +0 -46
- 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/.claude/hooks/{setup.sh → claude-code-web-session-start.sh} +0 -0
- /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
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module RuboCop
|
|
4
|
-
module Cop
|
|
5
|
-
module Style
|
|
6
|
-
module RbsInline
|
|
7
|
-
module ASTUtils
|
|
8
|
-
# @rbs node: RuboCop::AST::Node
|
|
9
|
-
# @rbs default: Integer
|
|
10
|
-
def end_line(node, default:) #: Integer
|
|
11
|
-
location = node.location #: untyped
|
|
12
|
-
location.end&.line || default
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# @rbs node: RuboCop::AST::Node
|
|
16
|
-
def name_location(node) #: untyped
|
|
17
|
-
location = node.location #: untyped
|
|
18
|
-
location.name
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# @rbs node: RuboCop::AST::Node
|
|
22
|
-
def source!(node) #: String
|
|
23
|
-
node.source || raise
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
#: (RuboCop::AST::SymbolNode) -> Symbol
|
|
27
|
-
#: (RuboCop::AST::StrNode) -> Symbol
|
|
28
|
-
#: (RuboCop::AST::Node) -> Symbol?
|
|
29
|
-
def value_to_sym(node)
|
|
30
|
-
case node
|
|
31
|
-
when RuboCop::AST::SymbolNode
|
|
32
|
-
node.value
|
|
33
|
-
when RuboCop::AST::StrNode
|
|
34
|
-
case (v = node.value)
|
|
35
|
-
when String
|
|
36
|
-
v.to_sym
|
|
37
|
-
else
|
|
38
|
-
value_to_sym(v)
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
@@ -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
|
|
File without changes
|