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.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.claude/hooks/pre-commit-check.sh +42 -2
  3. data/.claude/hooks/protect-sig-files.sh +45 -0
  4. data/.claude/hooks/self-review.sh +89 -0
  5. data/.claude/settings.json +16 -1
  6. data/.rubocop.yml +17 -12
  7. data/CHANGELOG.md +30 -0
  8. data/CLAUDE.md +11 -14
  9. data/README.md +51 -6
  10. data/Rakefile +12 -3
  11. data/config/default.yml +2 -4
  12. data/lib/rubocop/cop/rbs_inline_cops.rb +16 -7
  13. data/lib/rubocop/cop/style/rbs_inline/data_class_comment_alignment.rb +2 -9
  14. data/lib/rubocop/cop/style/rbs_inline/data_define_with_block.rb +13 -7
  15. data/lib/rubocop/cop/style/rbs_inline/embedded_rbs_spacing.rb +3 -2
  16. data/lib/rubocop/cop/style/rbs_inline/invalid_comment.rb +2 -2
  17. data/lib/rubocop/cop/style/rbs_inline/invalid_types.rb +1 -0
  18. data/lib/rubocop/cop/style/rbs_inline/keyword_separator.rb +2 -2
  19. data/lib/rubocop/cop/style/rbs_inline/method_comment_spacing.rb +3 -2
  20. data/lib/rubocop/cop/style/rbs_inline/missing_data_class_annotation.rb +2 -9
  21. data/lib/rubocop/cop/style/rbs_inline/missing_struct_class_annotation.rb +2 -16
  22. data/lib/rubocop/cop/style/rbs_inline/missing_type_annotation.rb +3 -16
  23. data/lib/rubocop/cop/style/rbs_inline/mixin/annotation_keywords.rb +16 -0
  24. data/lib/rubocop/cop/style/rbs_inline/mixin/ast_utils.rb +75 -0
  25. data/lib/rubocop/cop/style/rbs_inline/{comment_parser.rb → mixin/comment_parser.rb} +8 -0
  26. data/lib/rubocop/cop/style/rbs_inline/mixin/data_class_matcher.rb +22 -0
  27. data/lib/rubocop/cop/style/rbs_inline/{data_struct_helper.rb → mixin/data_struct_helper.rb} +14 -5
  28. data/lib/rubocop/cop/style/rbs_inline/mixin/file_filter.rb +72 -0
  29. data/lib/rubocop/cop/style/rbs_inline/mixin/mode_config.rb +39 -0
  30. data/lib/rubocop/cop/style/rbs_inline/{source_code_helper.rb → mixin/source_code_helper.rb} +3 -5
  31. data/lib/rubocop/cop/style/rbs_inline/mixin/struct_class_matcher.rb +32 -0
  32. data/lib/rubocop/cop/style/rbs_inline/parameters_separator.rb +2 -2
  33. data/lib/rubocop/cop/style/rbs_inline/redundant_annotation_with_skip.rb +2 -11
  34. data/lib/rubocop/cop/style/rbs_inline/redundant_instance_variable_annotation.rb +1 -0
  35. data/lib/rubocop/cop/style/rbs_inline/redundant_type_annotation.rb +6 -15
  36. data/lib/rubocop/cop/style/rbs_inline/require_rbs_inline_comment.rb +35 -23
  37. data/lib/rubocop/cop/style/rbs_inline/struct_class_comment_alignment.rb +2 -16
  38. data/lib/rubocop/cop/style/rbs_inline/struct_new_with_block.rb +13 -7
  39. data/lib/rubocop/cop/style/rbs_inline/unmatched_annotations.rb +31 -6
  40. data/lib/rubocop/cop/style/rbs_inline/untyped_instance_variable.rb +16 -6
  41. data/lib/rubocop/cop/style/rbs_inline/variable_comment_spacing.rb +3 -2
  42. data/lib/rubocop/rbs_inline/version.rb +1 -1
  43. data/rbs_collection.lock.yaml +11 -11
  44. data/sig/gems/rubocop/rubocop.rbs +14 -0
  45. data/sig/rubocop/cop/style/rbs_inline/data_class_comment_alignment.rbs +4 -5
  46. data/sig/rubocop/cop/style/rbs_inline/data_define_with_block.rbs +9 -2
  47. data/sig/rubocop/cop/style/rbs_inline/embedded_rbs_spacing.rbs +2 -0
  48. data/sig/rubocop/cop/style/rbs_inline/invalid_comment.rbs +4 -3
  49. data/sig/rubocop/cop/style/rbs_inline/invalid_types.rbs +2 -0
  50. data/sig/rubocop/cop/style/rbs_inline/keyword_separator.rbs +4 -3
  51. data/sig/rubocop/cop/style/rbs_inline/method_comment_spacing.rbs +2 -0
  52. data/sig/rubocop/cop/style/rbs_inline/missing_data_class_annotation.rbs +4 -5
  53. data/sig/rubocop/cop/style/rbs_inline/missing_struct_class_annotation.rbs +4 -10
  54. data/sig/rubocop/cop/style/rbs_inline/missing_type_annotation.rbs +4 -8
  55. data/sig/rubocop/cop/style/rbs_inline/mixin/annotation_keywords.rbs +16 -0
  56. data/sig/rubocop/cop/style/rbs_inline/{ast_utils.rbs → mixin/ast_utils.rbs} +14 -1
  57. data/sig/rubocop/cop/style/rbs_inline/{class_comment_alignment.rbs → mixin/class_comment_alignment.rbs} +1 -1
  58. data/sig/rubocop/cop/style/rbs_inline/{comment_parser.rbs → mixin/comment_parser.rbs} +5 -1
  59. data/sig/rubocop/cop/style/rbs_inline/mixin/data_class_matcher.rbs +18 -0
  60. data/sig/rubocop/cop/style/rbs_inline/{data_struct_helper.rbs → mixin/data_struct_helper.rbs} +6 -1
  61. data/sig/rubocop/cop/style/rbs_inline/mixin/file_filter.rbs +53 -0
  62. data/sig/rubocop/cop/style/rbs_inline/{missing_class_annotation.rbs → mixin/missing_class_annotation.rbs} +1 -1
  63. data/sig/rubocop/cop/style/rbs_inline/mixin/mode_config.rbs +27 -0
  64. data/sig/rubocop/cop/style/rbs_inline/{source_code_helper.rbs → mixin/source_code_helper.rbs} +1 -1
  65. data/sig/rubocop/cop/style/rbs_inline/mixin/struct_class_matcher.rbs +26 -0
  66. data/sig/rubocop/cop/style/rbs_inline/parameters_separator.rbs +4 -3
  67. data/sig/rubocop/cop/style/rbs_inline/redundant_annotation_with_skip.rbs +4 -4
  68. data/sig/rubocop/cop/style/rbs_inline/redundant_instance_variable_annotation.rbs +2 -0
  69. data/sig/rubocop/cop/style/rbs_inline/redundant_type_annotation.rbs +4 -4
  70. data/sig/rubocop/cop/style/rbs_inline/require_rbs_inline_comment.rbs +22 -5
  71. data/sig/rubocop/cop/style/rbs_inline/struct_class_comment_alignment.rbs +4 -10
  72. data/sig/rubocop/cop/style/rbs_inline/struct_new_with_block.rbs +9 -2
  73. data/sig/rubocop/cop/style/rbs_inline/unmatched_annotations.rbs +13 -0
  74. data/sig/rubocop/cop/style/rbs_inline/untyped_instance_variable.rbs +10 -0
  75. data/sig/rubocop/cop/style/rbs_inline/variable_comment_spacing.rbs +2 -0
  76. metadata +28 -18
  77. data/lib/rubocop/cop/style/rbs_inline/ast_utils.rb +0 -46
  78. data/sig/rubocop/cop/style/rbs_inline/redundant_argument_type.rbs +0 -85
  79. data/sig/rubocop/cop/style/rbs_inline/redundant_return_type.rbs +0 -109
  80. /data/.claude/hooks/{setup.sh → claude-code-web-session-start.sh} +0 -0
  81. /data/lib/rubocop/cop/style/rbs_inline/{class_comment_alignment.rb → mixin/class_comment_alignment.rb} +0 -0
  82. /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