rubocop-rbs_inline 1.6.0 → 1.7.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/.rubocop.yml +48 -19
- data/CHANGELOG.md +14 -0
- data/README.md +70 -0
- data/Rakefile +19 -19
- data/Steepfile +2 -2
- data/config/default.yml +23 -51
- data/lib/rubocop/cop/rbs_inline_cops.rb +26 -20
- data/lib/rubocop/cop/style/rbs_inline/class_comment_alignment.rb +66 -0
- data/lib/rubocop/cop/style/rbs_inline/comment_parser.rb +5 -5
- data/lib/rubocop/cop/style/rbs_inline/data_class_comment_alignment.rb +6 -87
- data/lib/rubocop/cop/style/rbs_inline/data_define_with_block.rb +6 -7
- data/lib/rubocop/cop/style/rbs_inline/data_struct_helper.rb +97 -0
- data/lib/rubocop/cop/style/rbs_inline/embedded_rbs_spacing.rb +3 -3
- data/lib/rubocop/cop/style/rbs_inline/invalid_comment.rb +7 -7
- data/lib/rubocop/cop/style/rbs_inline/invalid_types.rb +2 -2
- data/lib/rubocop/cop/style/rbs_inline/keyword_separator.rb +3 -3
- data/lib/rubocop/cop/style/rbs_inline/method_comment_spacing.rb +6 -6
- data/lib/rubocop/cop/style/rbs_inline/missing_class_annotation.rb +85 -0
- data/lib/rubocop/cop/style/rbs_inline/missing_data_class_annotation.rb +7 -137
- data/lib/rubocop/cop/style/rbs_inline/missing_struct_class_annotation.rb +56 -0
- data/lib/rubocop/cop/style/rbs_inline/missing_type_annotation.rb +16 -16
- data/lib/rubocop/cop/style/rbs_inline/parameters_separator.rb +5 -5
- data/lib/rubocop/cop/style/rbs_inline/redundant_annotation_with_skip.rb +11 -11
- data/lib/rubocop/cop/style/rbs_inline/redundant_instance_variable_annotation.rb +2 -2
- data/lib/rubocop/cop/style/rbs_inline/redundant_type_annotation.rb +5 -5
- data/lib/rubocop/cop/style/rbs_inline/require_rbs_inline_comment.rb +3 -3
- data/lib/rubocop/cop/style/rbs_inline/source_code_helper.rb +2 -2
- data/lib/rubocop/cop/style/rbs_inline/struct_class_comment_alignment.rb +58 -0
- data/lib/rubocop/cop/style/rbs_inline/struct_new_with_block.rb +54 -0
- data/lib/rubocop/cop/style/rbs_inline/unmatched_annotations.rb +13 -13
- data/lib/rubocop/cop/style/rbs_inline/untyped_instance_variable.rb +10 -10
- data/lib/rubocop/cop/style/rbs_inline/variable_comment_spacing.rb +4 -4
- data/lib/rubocop/rbs_inline/plugin.rb +7 -7
- data/lib/rubocop/rbs_inline/version.rb +1 -1
- data/lib/rubocop/rbs_inline.rb +1 -1
- data/lib/rubocop-rbs_inline.rb +5 -5
- data/rbs_collection.lock.yaml +19 -11
- data/sig/rubocop/cop/style/rbs_inline/class_comment_alignment.rbs +34 -0
- data/sig/rubocop/cop/style/rbs_inline/data_class_comment_alignment.rbs +2 -30
- data/sig/rubocop/cop/style/rbs_inline/data_define_with_block.rbs +1 -1
- data/sig/rubocop/cop/style/rbs_inline/data_struct_helper.rbs +55 -0
- data/sig/rubocop/cop/style/rbs_inline/missing_class_annotation.rbs +41 -0
- data/sig/rubocop/cop/style/rbs_inline/missing_data_class_annotation.rbs +2 -46
- data/sig/rubocop/cop/style/rbs_inline/missing_struct_class_annotation.rbs +46 -0
- data/sig/rubocop/cop/style/rbs_inline/struct_class_comment_alignment.rbs +48 -0
- data/sig/rubocop/cop/style/rbs_inline/struct_new_with_block.rbs +40 -0
- metadata +14 -2
data/rbs_collection.lock.yaml
CHANGED
|
@@ -6,7 +6,7 @@ gems:
|
|
|
6
6
|
source:
|
|
7
7
|
type: git
|
|
8
8
|
name: ruby/gem_rbs_collection
|
|
9
|
-
revision:
|
|
9
|
+
revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
|
|
10
10
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
11
11
|
repo_dir: gems
|
|
12
12
|
- name: diff-lcs
|
|
@@ -14,7 +14,7 @@ gems:
|
|
|
14
14
|
source:
|
|
15
15
|
type: git
|
|
16
16
|
name: ruby/gem_rbs_collection
|
|
17
|
-
revision:
|
|
17
|
+
revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
|
|
18
18
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
19
19
|
repo_dir: gems
|
|
20
20
|
- name: fileutils
|
|
@@ -25,12 +25,16 @@ gems:
|
|
|
25
25
|
version: '0'
|
|
26
26
|
source:
|
|
27
27
|
type: stdlib
|
|
28
|
+
- name: language_server-protocol
|
|
29
|
+
version: 3.17.0.6
|
|
30
|
+
source:
|
|
31
|
+
type: rubygems
|
|
28
32
|
- name: lint_roller
|
|
29
33
|
version: '1.1'
|
|
30
34
|
source:
|
|
31
35
|
type: git
|
|
32
36
|
name: ruby/gem_rbs_collection
|
|
33
|
-
revision:
|
|
37
|
+
revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
|
|
34
38
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
35
39
|
repo_dir: gems
|
|
36
40
|
- name: logger
|
|
@@ -38,7 +42,7 @@ gems:
|
|
|
38
42
|
source:
|
|
39
43
|
type: git
|
|
40
44
|
name: ruby/gem_rbs_collection
|
|
41
|
-
revision:
|
|
45
|
+
revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
|
|
42
46
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
43
47
|
repo_dir: gems
|
|
44
48
|
- name: monitor
|
|
@@ -54,7 +58,7 @@ gems:
|
|
|
54
58
|
source:
|
|
55
59
|
type: git
|
|
56
60
|
name: ruby/gem_rbs_collection
|
|
57
|
-
revision:
|
|
61
|
+
revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
|
|
58
62
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
59
63
|
repo_dir: gems
|
|
60
64
|
- name: parser
|
|
@@ -62,7 +66,7 @@ gems:
|
|
|
62
66
|
source:
|
|
63
67
|
type: git
|
|
64
68
|
name: ruby/gem_rbs_collection
|
|
65
|
-
revision:
|
|
69
|
+
revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
|
|
66
70
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
67
71
|
repo_dir: gems
|
|
68
72
|
- name: prism
|
|
@@ -74,7 +78,7 @@ gems:
|
|
|
74
78
|
source:
|
|
75
79
|
type: git
|
|
76
80
|
name: ruby/gem_rbs_collection
|
|
77
|
-
revision:
|
|
81
|
+
revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
|
|
78
82
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
79
83
|
repo_dir: gems
|
|
80
84
|
- name: rake
|
|
@@ -82,7 +86,7 @@ gems:
|
|
|
82
86
|
source:
|
|
83
87
|
type: git
|
|
84
88
|
name: ruby/gem_rbs_collection
|
|
85
|
-
revision:
|
|
89
|
+
revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
|
|
86
90
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
87
91
|
repo_dir: gems
|
|
88
92
|
- name: rbs
|
|
@@ -102,7 +106,7 @@ gems:
|
|
|
102
106
|
source:
|
|
103
107
|
type: git
|
|
104
108
|
name: ruby/gem_rbs_collection
|
|
105
|
-
revision:
|
|
109
|
+
revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
|
|
106
110
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
107
111
|
repo_dir: gems
|
|
108
112
|
- name: rubocop
|
|
@@ -110,7 +114,7 @@ gems:
|
|
|
110
114
|
source:
|
|
111
115
|
type: git
|
|
112
116
|
name: ruby/gem_rbs_collection
|
|
113
|
-
revision:
|
|
117
|
+
revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
|
|
114
118
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
115
119
|
repo_dir: gems
|
|
116
120
|
- name: rubocop-ast
|
|
@@ -118,9 +122,13 @@ gems:
|
|
|
118
122
|
source:
|
|
119
123
|
type: git
|
|
120
124
|
name: ruby/gem_rbs_collection
|
|
121
|
-
revision:
|
|
125
|
+
revision: ea56a88d1c0ac98e79f8ea5bb19a139da768ba10
|
|
122
126
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
123
127
|
repo_dir: gems
|
|
128
|
+
- name: rubocop-numbered-params
|
|
129
|
+
version: 1.0.1
|
|
130
|
+
source:
|
|
131
|
+
type: rubygems
|
|
124
132
|
- name: strscan
|
|
125
133
|
version: '0'
|
|
126
134
|
source:
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Generated from lib/rubocop/cop/style/rbs_inline/class_comment_alignment.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
module Style
|
|
6
|
+
module RbsInline
|
|
7
|
+
# Shared behavior for cops that ensure `#:` inline type annotations on
|
|
8
|
+
# struct-like class attributes (`Data.define` / `Struct.new`) are aligned.
|
|
9
|
+
#
|
|
10
|
+
# The including cop matches the definition node (e.g. via `struct_like_class?`)
|
|
11
|
+
# and calls {#check_comment_alignment}.
|
|
12
|
+
#
|
|
13
|
+
# @rbs module-self RuboCop::Cop::Base
|
|
14
|
+
module ClassCommentAlignment : RuboCop::Cop::Base
|
|
15
|
+
include DataStructHelper
|
|
16
|
+
|
|
17
|
+
# @rbs node: RuboCop::AST::SendNode
|
|
18
|
+
def check_comment_alignment: (RuboCop::AST::SendNode node) -> void
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
# @rbs node: RuboCop::AST::SendNode
|
|
23
|
+
def check_annotation_alignment: (RuboCop::AST::SendNode node) -> void
|
|
24
|
+
|
|
25
|
+
# @rbs corrector: RuboCop::Cop::Corrector
|
|
26
|
+
# @rbs arg: RuboCop::AST::Node
|
|
27
|
+
# @rbs comment: Parser::Source::Comment
|
|
28
|
+
# @rbs expected_col: Integer
|
|
29
|
+
def correct_alignment: (RuboCop::Cop::Corrector corrector, RuboCop::AST::Node arg, Parser::Source::Comment comment, Integer expected_col) -> void
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -25,11 +25,7 @@ module RuboCop
|
|
|
25
25
|
# :visibility #: Symbol
|
|
26
26
|
# )
|
|
27
27
|
class DataClassCommentAlignment < Base
|
|
28
|
-
include
|
|
29
|
-
|
|
30
|
-
include RangeHelp
|
|
31
|
-
|
|
32
|
-
include SourceCodeHelper
|
|
28
|
+
include ClassCommentAlignment
|
|
33
29
|
|
|
34
30
|
extend AutoCorrector
|
|
35
31
|
|
|
@@ -41,31 +37,7 @@ module RuboCop
|
|
|
41
37
|
private
|
|
42
38
|
|
|
43
39
|
# @rbs node: RuboCop::AST::SendNode
|
|
44
|
-
def
|
|
45
|
-
|
|
46
|
-
# @rbs arg: RuboCop::AST::Node
|
|
47
|
-
def data_attribute?: (RuboCop::AST::Node arg) -> bool
|
|
48
|
-
|
|
49
|
-
# @rbs node: RuboCop::AST::SendNode
|
|
50
|
-
def data_attributes: (RuboCop::AST::SendNode node) -> Array[RuboCop::AST::Node]
|
|
51
|
-
|
|
52
|
-
# @rbs node: RuboCop::AST::SendNode
|
|
53
|
-
def folded_data_class?: (RuboCop::AST::SendNode node) -> bool
|
|
54
|
-
|
|
55
|
-
# @rbs node: RuboCop::AST::SendNode
|
|
56
|
-
def check_annotation_alignment: (RuboCop::AST::SendNode node) -> void
|
|
57
|
-
|
|
58
|
-
# @rbs line: Integer
|
|
59
|
-
def inline_type_comment: (Integer line) -> Parser::Source::Comment?
|
|
60
|
-
|
|
61
|
-
# @rbs node: RuboCop::AST::SendNode
|
|
62
|
-
def annotation_column: (RuboCop::AST::SendNode node) -> Integer
|
|
63
|
-
|
|
64
|
-
# @rbs corrector: RuboCop::Cop::Corrector
|
|
65
|
-
# @rbs arg: RuboCop::AST::Node
|
|
66
|
-
# @rbs comment: Parser::Source::Comment
|
|
67
|
-
# @rbs expected_col: Integer
|
|
68
|
-
def correct_alignment: (RuboCop::Cop::Corrector corrector, RuboCop::AST::Node arg, Parser::Source::Comment comment, Integer expected_col) -> void
|
|
40
|
+
def struct_like_class?: (RuboCop::AST::SendNode node) -> bool
|
|
69
41
|
end
|
|
70
42
|
end
|
|
71
43
|
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Generated from lib/rubocop/cop/style/rbs_inline/data_struct_helper.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
module Style
|
|
6
|
+
module RbsInline
|
|
7
|
+
# Shared logic for cops that check inline type annotations on struct-like
|
|
8
|
+
# class definitions such as `Data.define` and `Struct.new`.
|
|
9
|
+
#
|
|
10
|
+
# Including cops decide which nodes to check by defining their own matcher
|
|
11
|
+
# (e.g. `struct_like_class?`); this module only provides helpers that operate
|
|
12
|
+
# on an already-matched definition node. Cops may override {#attr_argument?}
|
|
13
|
+
# when the set of attribute arguments differs from the default (e.g.
|
|
14
|
+
# `Struct.new` treats a leading string argument as the struct name rather than
|
|
15
|
+
# an attribute).
|
|
16
|
+
#
|
|
17
|
+
# @rbs module-self RuboCop::Cop::Base
|
|
18
|
+
module DataStructHelper : RuboCop::Cop::Base
|
|
19
|
+
include ASTUtils
|
|
20
|
+
|
|
21
|
+
include SourceCodeHelper
|
|
22
|
+
|
|
23
|
+
include RangeHelp
|
|
24
|
+
|
|
25
|
+
# @rbs arg: RuboCop::AST::Node
|
|
26
|
+
def attr_argument?: (RuboCop::AST::Node arg) -> bool
|
|
27
|
+
|
|
28
|
+
# @rbs node: RuboCop::AST::SendNode
|
|
29
|
+
def attr_arguments: (RuboCop::AST::SendNode node) -> Array[RuboCop::AST::Node]
|
|
30
|
+
|
|
31
|
+
# @rbs node: RuboCop::AST::SendNode
|
|
32
|
+
def folded?: (RuboCop::AST::SendNode node) -> bool
|
|
33
|
+
|
|
34
|
+
# @rbs line: Integer
|
|
35
|
+
def inline_type_annotation?: (Integer line) -> boolish
|
|
36
|
+
|
|
37
|
+
# @rbs line: Integer
|
|
38
|
+
def inline_type_comment: (Integer line) -> Parser::Source::Comment?
|
|
39
|
+
|
|
40
|
+
# @rbs line: Integer
|
|
41
|
+
def find_regular_comment: (Integer line) -> Parser::Source::Comment?
|
|
42
|
+
|
|
43
|
+
# @rbs node: RuboCop::AST::SendNode
|
|
44
|
+
def annotation_column: (RuboCop::AST::SendNode node) -> Integer
|
|
45
|
+
|
|
46
|
+
# @rbs node: RuboCop::AST::SendNode
|
|
47
|
+
def longest_argname: (RuboCop::AST::SendNode node) -> String
|
|
48
|
+
|
|
49
|
+
# @rbs node: RuboCop::AST::SendNode
|
|
50
|
+
def build_multiline_replacement: (RuboCop::AST::SendNode node) -> String
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Generated from lib/rubocop/cop/style/rbs_inline/missing_class_annotation.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
module Style
|
|
6
|
+
module RbsInline
|
|
7
|
+
# Shared behavior for cops that ensure struct-like class attributes have
|
|
8
|
+
# inline type annotations (`Data.define` / `Struct.new`).
|
|
9
|
+
#
|
|
10
|
+
# The including cop matches the definition node (e.g. via `struct_like_class?`)
|
|
11
|
+
# and calls {#check_missing_annotations}.
|
|
12
|
+
#
|
|
13
|
+
# @rbs module-self RuboCop::Cop::Base
|
|
14
|
+
module MissingClassAnnotation : RuboCop::Cop::Base
|
|
15
|
+
include DataStructHelper
|
|
16
|
+
|
|
17
|
+
# @rbs node: RuboCop::AST::SendNode
|
|
18
|
+
def check_missing_annotations: (RuboCop::AST::SendNode node) -> void
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
# @rbs node: RuboCop::AST::SendNode
|
|
23
|
+
def add_offenses_for_folded: (RuboCop::AST::SendNode node) -> void
|
|
24
|
+
|
|
25
|
+
# @rbs node: RuboCop::AST::SendNode
|
|
26
|
+
def check_multiline: (RuboCop::AST::SendNode node) -> void
|
|
27
|
+
|
|
28
|
+
# @rbs corrector: RuboCop::Cop::Corrector
|
|
29
|
+
# @rbs node: RuboCop::AST::SendNode
|
|
30
|
+
# @rbs arg: RuboCop::AST::Node
|
|
31
|
+
def correct_multiline: (RuboCop::Cop::Corrector corrector, RuboCop::AST::SendNode node, RuboCop::AST::Node arg) -> void
|
|
32
|
+
|
|
33
|
+
# @rbs corrector: RuboCop::Cop::Corrector
|
|
34
|
+
# @rbs node: RuboCop::AST::SendNode
|
|
35
|
+
# @rbs arg: RuboCop::AST::Node
|
|
36
|
+
def insert_annotation: (RuboCop::Cop::Corrector corrector, RuboCop::AST::SendNode node, RuboCop::AST::Node arg) -> void
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -20,11 +20,7 @@ module RuboCop
|
|
|
20
20
|
# :visibility #: Symbol
|
|
21
21
|
# )
|
|
22
22
|
class MissingDataClassAnnotation < Base
|
|
23
|
-
include
|
|
24
|
-
|
|
25
|
-
include RangeHelp
|
|
26
|
-
|
|
27
|
-
include SourceCodeHelper
|
|
23
|
+
include MissingClassAnnotation
|
|
28
24
|
|
|
29
25
|
extend AutoCorrector
|
|
30
26
|
|
|
@@ -36,47 +32,7 @@ module RuboCop
|
|
|
36
32
|
private
|
|
37
33
|
|
|
38
34
|
# @rbs node: RuboCop::AST::SendNode
|
|
39
|
-
def
|
|
40
|
-
|
|
41
|
-
# @rbs arg: RuboCop::AST::Node
|
|
42
|
-
def data_attribute?: (RuboCop::AST::Node arg) -> bool
|
|
43
|
-
|
|
44
|
-
# @rbs node: RuboCop::AST::SendNode
|
|
45
|
-
def data_attributes: (RuboCop::AST::SendNode node) -> Array[RuboCop::AST::Node]
|
|
46
|
-
|
|
47
|
-
# @rbs line: Integer
|
|
48
|
-
def inline_type_annotation?: (Integer line) -> boolish
|
|
49
|
-
|
|
50
|
-
# @rbs node: RuboCop::AST::SendNode
|
|
51
|
-
def folded_data_class?: (RuboCop::AST::SendNode node) -> bool
|
|
52
|
-
|
|
53
|
-
# @rbs node: RuboCop::AST::SendNode
|
|
54
|
-
def add_offenses_for_folded_data_class: (RuboCop::AST::SendNode node) -> void
|
|
55
|
-
|
|
56
|
-
# @rbs node: RuboCop::AST::SendNode
|
|
57
|
-
def longest_argname: (RuboCop::AST::SendNode node) -> String
|
|
58
|
-
|
|
59
|
-
# @rbs node: RuboCop::AST::SendNode
|
|
60
|
-
def build_multiline_replacement: (RuboCop::AST::SendNode node) -> String
|
|
61
|
-
|
|
62
|
-
# @rbs node: RuboCop::AST::SendNode
|
|
63
|
-
def check_multiline_data_class: (RuboCop::AST::SendNode node) -> void
|
|
64
|
-
|
|
65
|
-
# @rbs corrector: RuboCop::Cop::Corrector
|
|
66
|
-
# @rbs node: RuboCop::AST::SendNode
|
|
67
|
-
# @rbs arg: RuboCop::AST::Node
|
|
68
|
-
def correct_multiline: (RuboCop::Cop::Corrector corrector, RuboCop::AST::SendNode node, RuboCop::AST::Node arg) -> void
|
|
69
|
-
|
|
70
|
-
# @rbs corrector: RuboCop::Cop::Corrector
|
|
71
|
-
# @rbs node: RuboCop::AST::SendNode
|
|
72
|
-
# @rbs arg: RuboCop::AST::Node
|
|
73
|
-
def insert_annotation: (RuboCop::Cop::Corrector corrector, RuboCop::AST::SendNode node, RuboCop::AST::Node arg) -> void
|
|
74
|
-
|
|
75
|
-
# @rbs node: RuboCop::AST::SendNode
|
|
76
|
-
def annotation_column: (RuboCop::AST::SendNode node) -> Integer
|
|
77
|
-
|
|
78
|
-
# @rbs line: Integer
|
|
79
|
-
def find_regular_comment: (Integer line) -> Parser::Source::Comment?
|
|
35
|
+
def struct_like_class?: (RuboCop::AST::SendNode node) -> bool
|
|
80
36
|
end
|
|
81
37
|
end
|
|
82
38
|
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Generated from lib/rubocop/cop/style/rbs_inline/missing_struct_class_annotation.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
module Style
|
|
6
|
+
module RbsInline
|
|
7
|
+
# Checks that `Struct.new` attributes have inline type annotations.
|
|
8
|
+
#
|
|
9
|
+
# Each attribute passed to `Struct.new` should have a trailing `#:` type
|
|
10
|
+
# annotation comment on the same line. A leading string argument (the struct
|
|
11
|
+
# name) and the `keyword_init:` keyword argument are not attributes and are
|
|
12
|
+
# ignored.
|
|
13
|
+
#
|
|
14
|
+
# @example
|
|
15
|
+
# # bad
|
|
16
|
+
# Point = Struct.new(:x, :y)
|
|
17
|
+
#
|
|
18
|
+
# # good
|
|
19
|
+
# Point = Struct.new(
|
|
20
|
+
# :x, #: Integer
|
|
21
|
+
# :y #: Integer
|
|
22
|
+
# )
|
|
23
|
+
class MissingStructClassAnnotation < Base
|
|
24
|
+
include MissingClassAnnotation
|
|
25
|
+
|
|
26
|
+
extend AutoCorrector
|
|
27
|
+
|
|
28
|
+
MSG: ::String
|
|
29
|
+
|
|
30
|
+
# @rbs node: RuboCop::AST::SendNode
|
|
31
|
+
def on_send: (RuboCop::AST::SendNode node) -> void
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
# @rbs node: RuboCop::AST::SendNode
|
|
36
|
+
def struct_like_class?: (RuboCop::AST::SendNode node) -> bool
|
|
37
|
+
|
|
38
|
+
# `Struct.new` treats a leading string argument as the struct name, so only
|
|
39
|
+
# symbol arguments are attributes.
|
|
40
|
+
# @rbs arg: RuboCop::AST::Node
|
|
41
|
+
def attr_argument?: (RuboCop::AST::Node arg) -> bool
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Generated from lib/rubocop/cop/style/rbs_inline/struct_class_comment_alignment.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
module Style
|
|
6
|
+
module RbsInline
|
|
7
|
+
# Checks that `#:` inline type annotations in `Struct.new` blocks are aligned.
|
|
8
|
+
#
|
|
9
|
+
# Each `#:` annotation comment should start at the same column, determined by
|
|
10
|
+
# the longest attribute name (plus trailing comma). Folded `Struct.new` calls
|
|
11
|
+
# (where attributes are not one per line) are excluded.
|
|
12
|
+
#
|
|
13
|
+
# @example
|
|
14
|
+
# # bad
|
|
15
|
+
# Point = Struct.new(
|
|
16
|
+
# :x, #: Integer
|
|
17
|
+
# :y #: Integer
|
|
18
|
+
# )
|
|
19
|
+
#
|
|
20
|
+
# # good
|
|
21
|
+
# Point = Struct.new(
|
|
22
|
+
# :x, #: Integer
|
|
23
|
+
# :y #: Integer
|
|
24
|
+
# )
|
|
25
|
+
class StructClassCommentAlignment < Base
|
|
26
|
+
include ClassCommentAlignment
|
|
27
|
+
|
|
28
|
+
extend AutoCorrector
|
|
29
|
+
|
|
30
|
+
MSG: ::String
|
|
31
|
+
|
|
32
|
+
# @rbs node: RuboCop::AST::SendNode
|
|
33
|
+
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
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Generated from lib/rubocop/cop/style/rbs_inline/struct_new_with_block.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
module Style
|
|
6
|
+
module RbsInline
|
|
7
|
+
# Checks for `Struct.new` calls with a block.
|
|
8
|
+
#
|
|
9
|
+
# RBS::Inline does not parse the contents of `Struct.new` blocks, so any
|
|
10
|
+
# methods defined inside will not be recognized for type checking. Instead,
|
|
11
|
+
# call `Struct.new` without a block and define additional methods by
|
|
12
|
+
# reopening the class separately.
|
|
13
|
+
#
|
|
14
|
+
# @example
|
|
15
|
+
# # bad
|
|
16
|
+
# User = Struct.new(:name, :role) do
|
|
17
|
+
# def admin? = role == :admin #: bool
|
|
18
|
+
# end
|
|
19
|
+
#
|
|
20
|
+
# # good
|
|
21
|
+
# User = Struct.new(:name, :role)
|
|
22
|
+
#
|
|
23
|
+
# class User
|
|
24
|
+
# def admin? = role == :admin #: bool
|
|
25
|
+
# end
|
|
26
|
+
class StructNewWithBlock < Base
|
|
27
|
+
MSG: ::String
|
|
28
|
+
|
|
29
|
+
# @rbs node: RuboCop::AST::SendNode
|
|
30
|
+
def on_send: (RuboCop::AST::SendNode node) -> void
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
# @rbs node: RuboCop::AST::SendNode
|
|
35
|
+
def struct_like_class?: (RuboCop::AST::SendNode node) -> bool
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
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.7.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-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: lint_roller
|
|
@@ -84,15 +84,19 @@ files:
|
|
|
84
84
|
- lib/rubocop-rbs_inline.rb
|
|
85
85
|
- lib/rubocop/cop/rbs_inline_cops.rb
|
|
86
86
|
- lib/rubocop/cop/style/rbs_inline/ast_utils.rb
|
|
87
|
+
- lib/rubocop/cop/style/rbs_inline/class_comment_alignment.rb
|
|
87
88
|
- lib/rubocop/cop/style/rbs_inline/comment_parser.rb
|
|
88
89
|
- lib/rubocop/cop/style/rbs_inline/data_class_comment_alignment.rb
|
|
89
90
|
- lib/rubocop/cop/style/rbs_inline/data_define_with_block.rb
|
|
91
|
+
- lib/rubocop/cop/style/rbs_inline/data_struct_helper.rb
|
|
90
92
|
- lib/rubocop/cop/style/rbs_inline/embedded_rbs_spacing.rb
|
|
91
93
|
- lib/rubocop/cop/style/rbs_inline/invalid_comment.rb
|
|
92
94
|
- lib/rubocop/cop/style/rbs_inline/invalid_types.rb
|
|
93
95
|
- lib/rubocop/cop/style/rbs_inline/keyword_separator.rb
|
|
94
96
|
- lib/rubocop/cop/style/rbs_inline/method_comment_spacing.rb
|
|
97
|
+
- lib/rubocop/cop/style/rbs_inline/missing_class_annotation.rb
|
|
95
98
|
- lib/rubocop/cop/style/rbs_inline/missing_data_class_annotation.rb
|
|
99
|
+
- lib/rubocop/cop/style/rbs_inline/missing_struct_class_annotation.rb
|
|
96
100
|
- lib/rubocop/cop/style/rbs_inline/missing_type_annotation.rb
|
|
97
101
|
- lib/rubocop/cop/style/rbs_inline/parameters_separator.rb
|
|
98
102
|
- lib/rubocop/cop/style/rbs_inline/redundant_annotation_with_skip.rb
|
|
@@ -100,6 +104,8 @@ files:
|
|
|
100
104
|
- lib/rubocop/cop/style/rbs_inline/redundant_type_annotation.rb
|
|
101
105
|
- lib/rubocop/cop/style/rbs_inline/require_rbs_inline_comment.rb
|
|
102
106
|
- lib/rubocop/cop/style/rbs_inline/source_code_helper.rb
|
|
107
|
+
- lib/rubocop/cop/style/rbs_inline/struct_class_comment_alignment.rb
|
|
108
|
+
- lib/rubocop/cop/style/rbs_inline/struct_new_with_block.rb
|
|
103
109
|
- lib/rubocop/cop/style/rbs_inline/unmatched_annotations.rb
|
|
104
110
|
- lib/rubocop/cop/style/rbs_inline/untyped_instance_variable.rb
|
|
105
111
|
- lib/rubocop/cop/style/rbs_inline/variable_comment_spacing.rb
|
|
@@ -112,15 +118,19 @@ files:
|
|
|
112
118
|
- sig/rubocop-rbs_inline.rbs
|
|
113
119
|
- sig/rubocop/cop/rbs_inline_cops.rbs
|
|
114
120
|
- sig/rubocop/cop/style/rbs_inline/ast_utils.rbs
|
|
121
|
+
- sig/rubocop/cop/style/rbs_inline/class_comment_alignment.rbs
|
|
115
122
|
- sig/rubocop/cop/style/rbs_inline/comment_parser.rbs
|
|
116
123
|
- sig/rubocop/cop/style/rbs_inline/data_class_comment_alignment.rbs
|
|
117
124
|
- sig/rubocop/cop/style/rbs_inline/data_define_with_block.rbs
|
|
125
|
+
- sig/rubocop/cop/style/rbs_inline/data_struct_helper.rbs
|
|
118
126
|
- sig/rubocop/cop/style/rbs_inline/embedded_rbs_spacing.rbs
|
|
119
127
|
- sig/rubocop/cop/style/rbs_inline/invalid_comment.rbs
|
|
120
128
|
- sig/rubocop/cop/style/rbs_inline/invalid_types.rbs
|
|
121
129
|
- sig/rubocop/cop/style/rbs_inline/keyword_separator.rbs
|
|
122
130
|
- sig/rubocop/cop/style/rbs_inline/method_comment_spacing.rbs
|
|
131
|
+
- sig/rubocop/cop/style/rbs_inline/missing_class_annotation.rbs
|
|
123
132
|
- sig/rubocop/cop/style/rbs_inline/missing_data_class_annotation.rbs
|
|
133
|
+
- sig/rubocop/cop/style/rbs_inline/missing_struct_class_annotation.rbs
|
|
124
134
|
- sig/rubocop/cop/style/rbs_inline/missing_type_annotation.rbs
|
|
125
135
|
- sig/rubocop/cop/style/rbs_inline/parameters_separator.rbs
|
|
126
136
|
- sig/rubocop/cop/style/rbs_inline/redundant_annotation_with_skip.rbs
|
|
@@ -130,6 +140,8 @@ files:
|
|
|
130
140
|
- sig/rubocop/cop/style/rbs_inline/redundant_type_annotation.rbs
|
|
131
141
|
- sig/rubocop/cop/style/rbs_inline/require_rbs_inline_comment.rbs
|
|
132
142
|
- sig/rubocop/cop/style/rbs_inline/source_code_helper.rbs
|
|
143
|
+
- sig/rubocop/cop/style/rbs_inline/struct_class_comment_alignment.rbs
|
|
144
|
+
- sig/rubocop/cop/style/rbs_inline/struct_new_with_block.rbs
|
|
133
145
|
- sig/rubocop/cop/style/rbs_inline/unmatched_annotations.rbs
|
|
134
146
|
- sig/rubocop/cop/style/rbs_inline/untyped_instance_variable.rbs
|
|
135
147
|
- sig/rubocop/cop/style/rbs_inline/variable_comment_spacing.rbs
|