rubocop-rbs_inline 1.6.0 → 1.6.1
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 +6 -0
- data/Rakefile +19 -19
- data/Steepfile +2 -2
- data/config/default.yml +8 -51
- data/lib/rubocop/cop/rbs_inline_cops.rb +20 -20
- data/lib/rubocop/cop/style/rbs_inline/comment_parser.rb +5 -5
- data/lib/rubocop/cop/style/rbs_inline/data_class_comment_alignment.rb +2 -2
- data/lib/rubocop/cop/style/rbs_inline/data_define_with_block.rb +3 -3
- 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_data_class_annotation.rb +8 -8
- data/lib/rubocop/cop/style/rbs_inline/missing_type_annotation.rb +15 -15
- 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/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 +15 -11
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bd596a937ef29c9dd1053c9b874725aebde2e9fab387053243268810bb0a8103
|
|
4
|
+
data.tar.gz: '03865a85b9ef1783eb85816c386aee96370e48e7169994ea5cc96c1a323aacd9'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a5c053242db495271ee4751bcba23bc67d876d8d668e0984634d1154452a87476ff82330ea9010c48cd0f285918124d2dc42145bb750a3a8d0f25368e8ee8e22
|
|
7
|
+
data.tar.gz: 0e78d76dc58a9ba77439f65013cf1aa46492ee84337a43c6630e81d18c02d5fba23b0fab88c42f7a73d35d3c3bf02c4cfc9bee50f9337fb4d0d2a5189ddfdbf1
|
data/.rubocop.yml
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
- rubocop-rake
|
|
3
|
-
- rubocop-rspec
|
|
4
|
-
- rubocop-rbs_inline
|
|
1
|
+
# NOTE: Rules are sorted in ASCII order.
|
|
5
2
|
|
|
6
3
|
AllCops:
|
|
7
4
|
NewCops: enable
|
|
@@ -10,43 +7,56 @@ AllCops:
|
|
|
10
7
|
- bin/**/*
|
|
11
8
|
- vendor/**/*
|
|
12
9
|
|
|
10
|
+
plugins:
|
|
11
|
+
- rubocop-numbered-params
|
|
12
|
+
- rubocop-rake
|
|
13
|
+
- rubocop-rbs_inline
|
|
14
|
+
- rubocop-rspec
|
|
15
|
+
|
|
16
|
+
# Layout
|
|
17
|
+
Layout/LeadingCommentSpace:
|
|
18
|
+
AllowRBSInlineAnnotation: true
|
|
19
|
+
AllowSteepAnnotation: true
|
|
20
|
+
|
|
13
21
|
Layout/LineLength:
|
|
14
22
|
Max: 120
|
|
15
23
|
|
|
24
|
+
# Metrics
|
|
16
25
|
Metrics/AbcSize:
|
|
17
26
|
Max: 20
|
|
18
27
|
|
|
19
28
|
Metrics/BlockLength:
|
|
20
29
|
Exclude:
|
|
21
|
-
- spec/**/*_spec.rb
|
|
30
|
+
- "spec/**/*_spec.rb"
|
|
31
|
+
|
|
32
|
+
Metrics/ClassLength:
|
|
33
|
+
Max: 200
|
|
22
34
|
|
|
23
35
|
Metrics/MethodLength:
|
|
24
|
-
Max:
|
|
36
|
+
Max: 30
|
|
25
37
|
|
|
38
|
+
# Naming
|
|
26
39
|
Naming/FileName:
|
|
27
40
|
Exclude:
|
|
28
|
-
- lib/rubocop-rbs_inline.rb
|
|
41
|
+
- "lib/rubocop-rbs_inline.rb"
|
|
29
42
|
|
|
43
|
+
# RSpec
|
|
30
44
|
RSpec/ExampleLength:
|
|
31
|
-
Max: 20
|
|
32
|
-
|
|
33
|
-
RSpec/NestedGroups:
|
|
34
|
-
Max: 5
|
|
35
|
-
|
|
36
|
-
Style/Documentation:
|
|
37
45
|
Enabled: false
|
|
38
46
|
|
|
39
|
-
|
|
40
|
-
|
|
47
|
+
RSpec/MultipleMemoizedHelpers:
|
|
48
|
+
Max: 10
|
|
41
49
|
|
|
42
|
-
|
|
43
|
-
Layout/LeadingCommentSpace:
|
|
50
|
+
RSpec/MultipleExpectations:
|
|
44
51
|
Enabled: false
|
|
45
52
|
|
|
46
|
-
|
|
53
|
+
RSpec/NamedSubject:
|
|
47
54
|
Enabled: false
|
|
48
55
|
|
|
49
|
-
|
|
56
|
+
RSpec/NestedGroups:
|
|
57
|
+
Max: 5
|
|
58
|
+
|
|
59
|
+
# RbsInline
|
|
50
60
|
Style/RbsInline/MissingTypeAnnotation:
|
|
51
61
|
EnforcedStyle: doc_style_and_return_annotation
|
|
52
62
|
|
|
@@ -55,3 +65,22 @@ Style/RbsInline/RedundantTypeAnnotation:
|
|
|
55
65
|
|
|
56
66
|
Style/RbsInline/RequireRbsInlineComment:
|
|
57
67
|
EnforcedStyle: never
|
|
68
|
+
|
|
69
|
+
# Style
|
|
70
|
+
Style/AccessorGrouping:
|
|
71
|
+
Enabled: false
|
|
72
|
+
|
|
73
|
+
Style/CommentedKeyword:
|
|
74
|
+
Enabled: false
|
|
75
|
+
|
|
76
|
+
Style/Documentation:
|
|
77
|
+
Enabled: false
|
|
78
|
+
|
|
79
|
+
Style/HashSyntax:
|
|
80
|
+
EnforcedShorthandSyntax: always
|
|
81
|
+
|
|
82
|
+
Style/StringLiterals:
|
|
83
|
+
EnforcedStyle: double_quotes
|
|
84
|
+
|
|
85
|
+
Style/StringLiteralsInInterpolation:
|
|
86
|
+
EnforcedStyle: double_quotes
|
data/CHANGELOG.md
CHANGED
data/Rakefile
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
3
|
+
require "bundler/gem_tasks"
|
|
4
|
+
require "rubocop/rake_task"
|
|
5
5
|
|
|
6
6
|
RuboCop::RakeTask.new
|
|
7
7
|
|
|
@@ -9,18 +9,18 @@ task default: :ci
|
|
|
9
9
|
|
|
10
10
|
task ci: %i[rubocop spec steep rbs:validate]
|
|
11
11
|
|
|
12
|
-
require
|
|
12
|
+
require "rspec/core/rake_task"
|
|
13
13
|
|
|
14
14
|
RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
15
|
-
spec.pattern = FileList[
|
|
15
|
+
spec.pattern = FileList["spec/**/*_spec.rb"]
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
desc
|
|
18
|
+
desc "Generate a new cop with a template"
|
|
19
19
|
task :new_cop, [:cop] do |_task, args|
|
|
20
|
-
require
|
|
20
|
+
require "rubocop"
|
|
21
21
|
|
|
22
22
|
cop_name = args.fetch(:cop) do
|
|
23
|
-
warn
|
|
23
|
+
warn "usage: bundle exec rake new_cop[Department/Name]"
|
|
24
24
|
exit!
|
|
25
25
|
end
|
|
26
26
|
|
|
@@ -28,30 +28,30 @@ task :new_cop, [:cop] do |_task, args|
|
|
|
28
28
|
|
|
29
29
|
generator.write_source
|
|
30
30
|
generator.write_spec
|
|
31
|
-
generator.inject_require(root_file_path:
|
|
32
|
-
generator.inject_config(config_file_path:
|
|
31
|
+
generator.inject_require(root_file_path: "lib/rubocop/cop/rbs_inline_cops.rb")
|
|
32
|
+
generator.inject_config(config_file_path: "config/default.yml")
|
|
33
33
|
|
|
34
34
|
puts generator.todo
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
namespace :rbs do
|
|
38
|
-
desc
|
|
38
|
+
desc "Install RBS signatures"
|
|
39
39
|
task :install do
|
|
40
|
-
sh
|
|
40
|
+
sh "bundle", "exec", "rbs", "collection", "install", "--frozen"
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
-
desc
|
|
43
|
+
desc "Generate RBS files"
|
|
44
44
|
task :generate do
|
|
45
|
-
sh
|
|
45
|
+
sh "rbs-inline", "--opt-out", "--output=sig", "lib"
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
desc
|
|
49
|
-
task validate:
|
|
50
|
-
sh
|
|
48
|
+
desc "Validate RBS files"
|
|
49
|
+
task validate: "rbs:install" do
|
|
50
|
+
sh "rbs", "-Isig", "validate"
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
desc
|
|
55
|
-
task steep:
|
|
56
|
-
sh
|
|
54
|
+
desc "Run Steep type checker"
|
|
55
|
+
task steep: "rbs:install" do
|
|
56
|
+
sh "bundle", "exec", "steep", "check"
|
|
57
57
|
end
|
data/Steepfile
CHANGED
data/config/default.yml
CHANGED
|
@@ -1,66 +1,50 @@
|
|
|
1
|
+
Style/RbsInline:
|
|
2
|
+
inherit_mode:
|
|
3
|
+
merge:
|
|
4
|
+
- Exclude
|
|
5
|
+
Exclude:
|
|
6
|
+
- 'spec/**/*'
|
|
7
|
+
- 'test/**/*'
|
|
8
|
+
|
|
1
9
|
Style/RbsInline/DataClassCommentAlignment:
|
|
2
10
|
Description: "Checks that `#:` inline type annotations in `Data.define` blocks are aligned."
|
|
3
11
|
Enabled: true
|
|
4
12
|
VersionAdded: '1.5.0'
|
|
5
|
-
Exclude:
|
|
6
|
-
- 'spec/**/*'
|
|
7
|
-
- 'test/**/*'
|
|
8
13
|
|
|
9
14
|
Style/RbsInline/DataDefineWithBlock:
|
|
10
15
|
Description: "Checks for `Data.define` calls with a block, which RBS::Inline does not parse."
|
|
11
16
|
Enabled: true
|
|
12
17
|
VersionAdded: '1.5.0'
|
|
13
|
-
Exclude:
|
|
14
|
-
- 'spec/**/*'
|
|
15
|
-
- 'test/**/*'
|
|
16
18
|
|
|
17
19
|
Style/RbsInline/EmbeddedRbsSpacing:
|
|
18
20
|
Description: 'Checks that `@rbs!` comments (embedded RBS) are followed by a blank line.'
|
|
19
21
|
Enabled: true
|
|
20
22
|
VersionAdded: '1.5.0'
|
|
21
|
-
Exclude:
|
|
22
|
-
- 'spec/**/*'
|
|
23
|
-
- 'test/**/*'
|
|
24
23
|
|
|
25
24
|
Style/RbsInline/InvalidComment:
|
|
26
25
|
Description: "Checks the rbs-inline annotation comment is valid."
|
|
27
26
|
Enabled: true
|
|
28
27
|
VersionAdded: "1.0.0"
|
|
29
|
-
Exclude:
|
|
30
|
-
- 'spec/**/*'
|
|
31
|
-
- 'test/**/*'
|
|
32
28
|
|
|
33
29
|
Style/RbsInline/InvalidTypes:
|
|
34
30
|
Description: "Checks the rbs-inline annotation comment uses valid types."
|
|
35
31
|
Enabled: true
|
|
36
32
|
VersionAdded: "1.0.0"
|
|
37
|
-
Exclude:
|
|
38
|
-
- 'spec/**/*'
|
|
39
|
-
- 'test/**/*'
|
|
40
33
|
|
|
41
34
|
Style/RbsInline/KeywordSeparator:
|
|
42
35
|
Description: "Checks the rbs-inline annotation comment does not use a separator after the keywords."
|
|
43
36
|
Enabled: true
|
|
44
37
|
VersionAdded: "1.0.0"
|
|
45
|
-
Exclude:
|
|
46
|
-
- 'spec/**/*'
|
|
47
|
-
- 'test/**/*'
|
|
48
38
|
|
|
49
39
|
Style/RbsInline/MethodCommentSpacing:
|
|
50
40
|
Description: 'Checks that method-related `@rbs` annotations are placed immediately before method definitions.'
|
|
51
41
|
Enabled: true
|
|
52
42
|
VersionAdded: '1.5.0'
|
|
53
|
-
Exclude:
|
|
54
|
-
- 'spec/**/*'
|
|
55
|
-
- 'test/**/*'
|
|
56
43
|
|
|
57
44
|
Style/RbsInline/MissingDataClassAnnotation:
|
|
58
45
|
Description: "Checks that `Data.define` attributes have inline type annotations."
|
|
59
46
|
Enabled: true
|
|
60
47
|
VersionAdded: '1.5.0'
|
|
61
|
-
Exclude:
|
|
62
|
-
- 'spec/**/*'
|
|
63
|
-
- 'test/**/*'
|
|
64
48
|
|
|
65
49
|
Style/RbsInline/MissingTypeAnnotation:
|
|
66
50
|
Description: "Checks that method definitions and attr_* declarations have RBS inline type annotations."
|
|
@@ -73,34 +57,22 @@ Style/RbsInline/MissingTypeAnnotation:
|
|
|
73
57
|
- method_type_signature
|
|
74
58
|
- method_type_signature_or_return_annotation
|
|
75
59
|
Visibility: all
|
|
76
|
-
Exclude:
|
|
77
|
-
- 'spec/**/*'
|
|
78
|
-
- 'test/**/*'
|
|
79
60
|
|
|
80
61
|
Style/RbsInline/ParametersSeparator:
|
|
81
62
|
Description: "Checks the rbs-inline annotation comment uses a separator to parameters"
|
|
82
63
|
Enabled: true
|
|
83
64
|
VersionAdded: "1.0.0"
|
|
84
|
-
Exclude:
|
|
85
|
-
- 'spec/**/*'
|
|
86
|
-
- 'test/**/*'
|
|
87
65
|
|
|
88
66
|
Style/RbsInline/RedundantAnnotationWithSkip:
|
|
89
67
|
Description: "Checks for redundant type annotations when `@rbs skip` or `@rbs override` is present."
|
|
90
68
|
Enabled: true
|
|
91
69
|
SafeAutoCorrect: false
|
|
92
70
|
VersionAdded: '1.5.0'
|
|
93
|
-
Exclude:
|
|
94
|
-
- 'spec/**/*'
|
|
95
|
-
- 'test/**/*'
|
|
96
71
|
|
|
97
72
|
Style/RbsInline/RedundantInstanceVariableAnnotation:
|
|
98
73
|
Description: "Checks for redundant `@rbs` instance variable type annotation when `attr_*` with an inline type annotation is already defined."
|
|
99
74
|
Enabled: true
|
|
100
75
|
VersionAdded: '1.5.0'
|
|
101
|
-
Exclude:
|
|
102
|
-
- 'spec/**/*'
|
|
103
|
-
- 'test/**/*'
|
|
104
76
|
|
|
105
77
|
Style/RbsInline/RedundantTypeAnnotation:
|
|
106
78
|
Description: "Checks for redundant type annotations when multiple type specifications exist for the same method definition."
|
|
@@ -112,9 +84,6 @@ Style/RbsInline/RedundantTypeAnnotation:
|
|
|
112
84
|
- method_type_signature
|
|
113
85
|
- doc_style
|
|
114
86
|
- doc_style_and_return_annotation
|
|
115
|
-
Exclude:
|
|
116
|
-
- 'spec/**/*'
|
|
117
|
-
- 'test/**/*'
|
|
118
87
|
|
|
119
88
|
Style/RbsInline/RequireRbsInlineComment:
|
|
120
89
|
Description: "Checks the presence or absence of `# rbs_inline: enabled` magic comment."
|
|
@@ -124,30 +93,18 @@ Style/RbsInline/RequireRbsInlineComment:
|
|
|
124
93
|
SupportedStyles:
|
|
125
94
|
- always
|
|
126
95
|
- never
|
|
127
|
-
Exclude:
|
|
128
|
-
- 'spec/**/*'
|
|
129
|
-
- 'test/**/*'
|
|
130
96
|
|
|
131
97
|
Style/RbsInline/UnmatchedAnnotations:
|
|
132
98
|
Description: "Checks the rbs-inline annotation comment is surely matched."
|
|
133
99
|
Enabled: true
|
|
134
100
|
VersionAdded: "1.0.0"
|
|
135
|
-
Exclude:
|
|
136
|
-
- 'spec/**/*'
|
|
137
|
-
- 'test/**/*'
|
|
138
101
|
|
|
139
102
|
Style/RbsInline/UntypedInstanceVariable:
|
|
140
103
|
Description: "Checks that instance variables in classes/modules have RBS type annotations."
|
|
141
104
|
Enabled: true
|
|
142
105
|
VersionAdded: '1.5.0'
|
|
143
|
-
Exclude:
|
|
144
|
-
- 'spec/**/*'
|
|
145
|
-
- 'test/**/*'
|
|
146
106
|
|
|
147
107
|
Style/RbsInline/VariableCommentSpacing:
|
|
148
108
|
Description: 'Checks that `@rbs` variable comments are followed by a blank line.'
|
|
149
109
|
Enabled: true
|
|
150
110
|
VersionAdded: '1.5.0'
|
|
151
|
-
Exclude:
|
|
152
|
-
- 'spec/**/*'
|
|
153
|
-
- 'test/**/*'
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative
|
|
4
|
-
require_relative
|
|
5
|
-
require_relative
|
|
6
|
-
require_relative
|
|
7
|
-
require_relative
|
|
8
|
-
require_relative
|
|
9
|
-
require_relative
|
|
10
|
-
require_relative
|
|
11
|
-
require_relative
|
|
12
|
-
require_relative
|
|
13
|
-
require_relative
|
|
14
|
-
require_relative
|
|
15
|
-
require_relative
|
|
16
|
-
require_relative
|
|
17
|
-
require_relative
|
|
18
|
-
require_relative
|
|
19
|
-
require_relative
|
|
20
|
-
require_relative
|
|
21
|
-
require_relative
|
|
22
|
-
require_relative
|
|
3
|
+
require_relative "style/rbs_inline/ast_utils"
|
|
4
|
+
require_relative "style/rbs_inline/source_code_helper"
|
|
5
|
+
require_relative "style/rbs_inline/comment_parser"
|
|
6
|
+
require_relative "style/rbs_inline/data_class_comment_alignment"
|
|
7
|
+
require_relative "style/rbs_inline/data_define_with_block"
|
|
8
|
+
require_relative "style/rbs_inline/embedded_rbs_spacing"
|
|
9
|
+
require_relative "style/rbs_inline/invalid_comment"
|
|
10
|
+
require_relative "style/rbs_inline/invalid_types"
|
|
11
|
+
require_relative "style/rbs_inline/keyword_separator"
|
|
12
|
+
require_relative "style/rbs_inline/method_comment_spacing"
|
|
13
|
+
require_relative "style/rbs_inline/missing_data_class_annotation"
|
|
14
|
+
require_relative "style/rbs_inline/missing_type_annotation"
|
|
15
|
+
require_relative "style/rbs_inline/parameters_separator"
|
|
16
|
+
require_relative "style/rbs_inline/redundant_annotation_with_skip"
|
|
17
|
+
require_relative "style/rbs_inline/redundant_instance_variable_annotation"
|
|
18
|
+
require_relative "style/rbs_inline/redundant_type_annotation"
|
|
19
|
+
require_relative "style/rbs_inline/require_rbs_inline_comment"
|
|
20
|
+
require_relative "style/rbs_inline/unmatched_annotations"
|
|
21
|
+
require_relative "style/rbs_inline/untyped_instance_variable"
|
|
22
|
+
require_relative "style/rbs_inline/variable_comment_spacing"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "rbs/inline"
|
|
4
4
|
|
|
5
|
-
require_relative
|
|
5
|
+
require_relative "source_code_helper"
|
|
6
6
|
|
|
7
7
|
module RuboCop
|
|
8
8
|
module Cop
|
|
@@ -49,7 +49,7 @@ module RuboCop
|
|
|
49
49
|
|
|
50
50
|
# Exclude trailing inline comments (e.g., `def method = value #: Type`)
|
|
51
51
|
# by verifying all comment lines contain only whitespace before '#'
|
|
52
|
-
r.comments.all? {
|
|
52
|
+
r.comments.all? { processed_source.buffer.source_line(_1.location.start_line).match?(/\A\s*#/) }
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
|
|
@@ -60,8 +60,8 @@ module RuboCop
|
|
|
60
60
|
return unless leading_annotation
|
|
61
61
|
|
|
62
62
|
annotation_lines = leading_annotation.comments
|
|
63
|
-
.select {
|
|
64
|
-
.map {
|
|
63
|
+
.select { _1.location.slice.start_with?("#:") }
|
|
64
|
+
.map { _1.location.start_line }
|
|
65
65
|
return if annotation_lines.empty?
|
|
66
66
|
|
|
67
67
|
comments = processed_source.comments.select do |c|
|
|
@@ -31,7 +31,7 @@ module RuboCop
|
|
|
31
31
|
include SourceCodeHelper
|
|
32
32
|
extend AutoCorrector
|
|
33
33
|
|
|
34
|
-
MSG =
|
|
34
|
+
MSG = "Misaligned inline type annotation for Data attribute."
|
|
35
35
|
|
|
36
36
|
# @rbs node: RuboCop::AST::SendNode
|
|
37
37
|
def on_send(node) #: void
|
|
@@ -125,7 +125,7 @@ module RuboCop
|
|
|
125
125
|
replace_start = line_begin + content_end_col
|
|
126
126
|
replace_end = line_begin + comment.location.column
|
|
127
127
|
|
|
128
|
-
corrector.replace(range_between(replace_start, replace_end),
|
|
128
|
+
corrector.replace(range_between(replace_start, replace_end), " " * padding)
|
|
129
129
|
end
|
|
130
130
|
end
|
|
131
131
|
end
|
|
@@ -28,9 +28,9 @@ module RuboCop
|
|
|
28
28
|
# end
|
|
29
29
|
#
|
|
30
30
|
class DataDefineWithBlock < Base
|
|
31
|
-
MSG =
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
MSG = "Do not use `Data.define` with a block. RBS::Inline does not parse block contents, " \
|
|
32
|
+
"so methods defined in the block will not be recognized. " \
|
|
33
|
+
"Use a separate class definition instead."
|
|
34
34
|
|
|
35
35
|
# @rbs node: RuboCop::AST::SendNode
|
|
36
36
|
def on_send(node) #: void
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative
|
|
4
|
-
require_relative
|
|
3
|
+
require_relative "source_code_helper"
|
|
4
|
+
require_relative "comment_parser"
|
|
5
5
|
|
|
6
6
|
module RuboCop
|
|
7
7
|
module Cop
|
|
@@ -30,7 +30,7 @@ module RuboCop
|
|
|
30
30
|
include SourceCodeHelper
|
|
31
31
|
include CommentParser
|
|
32
32
|
|
|
33
|
-
MSG =
|
|
33
|
+
MSG = "`@rbs!` comment must be followed by a blank line."
|
|
34
34
|
|
|
35
35
|
def on_new_investigation #: void
|
|
36
36
|
check_embedded_rbs_spacing
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "rbs/inline/annotation_parser/tokenizer"
|
|
4
4
|
|
|
5
5
|
module RuboCop
|
|
6
6
|
module Cop
|
|
@@ -22,11 +22,11 @@ module RuboCop
|
|
|
22
22
|
class InvalidComment < Base
|
|
23
23
|
extend AutoCorrector
|
|
24
24
|
|
|
25
|
-
MSG =
|
|
25
|
+
MSG = "Invalid RBS annotation comment found."
|
|
26
26
|
|
|
27
27
|
# refs: https://github.com/soutaro/rbs-inline/blob/main/lib/rbs/inline/annotation_parser/tokenizer.rb
|
|
28
28
|
RBS_INLINE_KEYWORDS = %w[inherits override use module-self generic skip module class].freeze #: Array[String]
|
|
29
|
-
RBS_INLINE_KEYWORD_PATTERN = RBS_INLINE_KEYWORDS.join(
|
|
29
|
+
RBS_INLINE_KEYWORD_PATTERN = RBS_INLINE_KEYWORDS.join("|") #: String
|
|
30
30
|
|
|
31
31
|
SIGNATURE_PATTERN = '\(.*\)\s*(\??\s*{.*?}\s*)?->\s*.*'
|
|
32
32
|
|
|
@@ -56,10 +56,10 @@ module RuboCop
|
|
|
56
56
|
# @rbs text: String
|
|
57
57
|
def corrected_text(text) #: String?
|
|
58
58
|
case text
|
|
59
|
-
when MISSING_HASH_COLON then text.sub(/\A#\s+/,
|
|
60
|
-
when SPACE_BEFORE_COLON then text.sub(/\A#\s+:\s*/,
|
|
61
|
-
when MIXED_ANNOTATION then text.sub(/\A#:\s+/,
|
|
62
|
-
when MISSING_AT_SIGN then text.sub(/\A#\s*rbs\s+/,
|
|
59
|
+
when MISSING_HASH_COLON then text.sub(/\A#\s+/, "#: ")
|
|
60
|
+
when SPACE_BEFORE_COLON then text.sub(/\A#\s+:\s*/, "#: ")
|
|
61
|
+
when MIXED_ANNOTATION then text.sub(/\A#:\s+/, "# ")
|
|
62
|
+
when MISSING_AT_SIGN then text.sub(/\A#\s*rbs\s+/, "# @rbs ")
|
|
63
63
|
end
|
|
64
64
|
end
|
|
65
65
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "rbs/inline"
|
|
4
4
|
|
|
5
5
|
module RuboCop
|
|
6
6
|
module Cop
|
|
@@ -27,7 +27,7 @@ module RuboCop
|
|
|
27
27
|
include RBS::Inline::AST::Annotations
|
|
28
28
|
include RBS::Inline::AST::Members
|
|
29
29
|
|
|
30
|
-
MSG =
|
|
30
|
+
MSG = "Invalid annotation found."
|
|
31
31
|
|
|
32
32
|
def on_new_investigation #: void
|
|
33
33
|
parse_comments.each do |result|
|
|
@@ -19,7 +19,7 @@ module RuboCop
|
|
|
19
19
|
include CommentParser
|
|
20
20
|
include RangeHelp
|
|
21
21
|
|
|
22
|
-
MSG =
|
|
22
|
+
MSG = "Do not use `:` after the keyword."
|
|
23
23
|
|
|
24
24
|
# refs: https://github.com/soutaro/rbs-inline/blob/main/lib/rbs/inline/annotation_parser/tokenizer.rb
|
|
25
25
|
RBS_INLINE_KEYWORDS = %w[inherits override use module-self generic skip module class].freeze #: Array[String]
|
|
@@ -49,7 +49,7 @@ module RuboCop
|
|
|
49
49
|
|
|
50
50
|
def on_investigation_end #: void
|
|
51
51
|
processed_source.comments.each do |comment|
|
|
52
|
-
matched = comment.text.match(/\A#\s+@rbs\s+(#{RBS_INLINE_KEYWORDS.join(
|
|
52
|
+
matched = comment.text.match(/\A#\s+@rbs\s+(#{RBS_INLINE_KEYWORDS.join("|")}):/)
|
|
53
53
|
next unless matched
|
|
54
54
|
next if valid_method_annotation?(comment)
|
|
55
55
|
|
|
@@ -86,7 +86,7 @@ module RuboCop
|
|
|
86
86
|
# followed by `:` but no type.
|
|
87
87
|
# @rbs comment: Parser::Source::Comment
|
|
88
88
|
def no_argument_keyword_without_type?(comment) #: bool
|
|
89
|
-
comment.text.match?(/\A#\s+@rbs\s+(#{NO_ARGUMENT_KEYWORDS.join(
|
|
89
|
+
comment.text.match?(/\A#\s+@rbs\s+(#{NO_ARGUMENT_KEYWORDS.join("|")}):\s*\z/)
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
# @rbs comment: Parser::Source::Comment
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative
|
|
4
|
-
require_relative
|
|
3
|
+
require_relative "source_code_helper"
|
|
4
|
+
require_relative "comment_parser"
|
|
5
5
|
|
|
6
6
|
module RuboCop
|
|
7
7
|
module Cop
|
|
@@ -61,8 +61,8 @@ module RuboCop
|
|
|
61
61
|
include SourceCodeHelper
|
|
62
62
|
include CommentParser
|
|
63
63
|
|
|
64
|
-
MSG =
|
|
65
|
-
MSG_WITH_BLANK_LINE =
|
|
64
|
+
MSG = "Method-related `@rbs` annotation must be immediately before a method definition."
|
|
65
|
+
MSG_WITH_BLANK_LINE = "Remove blank line between method annotation and method definition."
|
|
66
66
|
METHOD_DEFINITION_PATTERN =
|
|
67
67
|
/\A(?:(?:private|protected|public|private_class_method|module_function)\s+)?def\s/ #: Regexp
|
|
68
68
|
|
|
@@ -115,7 +115,7 @@ module RuboCop
|
|
|
115
115
|
when RBS::Inline::AST::Annotations::VarType
|
|
116
116
|
# VarType includes both parameter types and variable types (@ivar, @@cvar)
|
|
117
117
|
# Only consider it method-related if it's a parameter annotation (name doesn't start with @)
|
|
118
|
-
return true unless annotation.name.start_with?(
|
|
118
|
+
return true unless annotation.name.start_with?("@")
|
|
119
119
|
when RBS::Inline::AST::Annotations::ReturnType,
|
|
120
120
|
RBS::Inline::AST::Annotations::BlockType,
|
|
121
121
|
RBS::Inline::AST::Annotations::Override,
|
|
@@ -166,7 +166,7 @@ module RuboCop
|
|
|
166
166
|
# @rbs comment: RBS::Inline::AnnotationParser::ParsingResult
|
|
167
167
|
def skip_only_annotation?(comment) #: bool
|
|
168
168
|
annotations = [] #: Array[RBS::Inline::AST::Annotations::t]
|
|
169
|
-
comment.each_annotation {
|
|
169
|
+
comment.each_annotation { annotations << _1 }
|
|
170
170
|
annotations.any? && annotations.all?(RBS::Inline::AST::Annotations::Skip)
|
|
171
171
|
end
|
|
172
172
|
|