rubocop-rbs_inline 1.1.0 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 330ffc2d84cf5c15d64d2922c93eb97017e4dd585cf52dea2e05ac2ec2ed60ab
4
- data.tar.gz: 7c550b9d63d636cd52d8ddf285e1dd9220b2764425ef59784685777c38f82963
3
+ metadata.gz: a8008a16d537a1c97bc627ada003d8b6cb5cf106816d0bdcd7ecb7c49255e941
4
+ data.tar.gz: 2597b7e5e77c085c887ec295de883451661752847d4e24a2d618625c5abaf341
5
5
  SHA512:
6
- metadata.gz: 1365b8c968cbd7341a8f685cdadc7334ac9d53ba78662af77522097df9440b8092821ef30c3445992809f71aedad50d45764a9a1a0e0baf54133d9cf029bc87b
7
- data.tar.gz: abc24e1e6df83cb0c24ddac363ed1e7b7b623cd9d528c59cc9869715ecf7cb01430f25b3681b8f64d22ebd8c3b94ab2595cfe7710bad6be70897a2676aeea783
6
+ metadata.gz: 23b3de5f3348d0a4fd045f4258e7f278832d581cca1404b0ab3196b2a608e3fdb1c3fde594f4d7619b9284846e8f608ba2248c0ac50b7cbd893655263bfb4e1b
7
+ data.tar.gz: 191da5351ce4d508b7ddc00c00b09b8944005aaf73aa1072bd03d85de6a3d411b9c84eb838161f0e88354a7c796da4027ee218c22b7ed887606de6d2874c6150
@@ -1,5 +1,7 @@
1
1
  {
2
2
  "cSpell.words": [
3
3
  "strscan"
4
- ]
4
+ ],
5
+ "rbs-helper.rbs-inline-on-save": true,
6
+ "rbs-helper.rbs-inline-signature-directory": "sig/"
5
7
  }
data/README.md CHANGED
@@ -1,38 +1,37 @@
1
- # Rubocop::RbsInline
1
+ # rubocop-rbs_inline
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
4
-
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rubocop/rbs_inline`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ rubocop-rbs_inline is a RuboCop extension that checks for [RBS::Inline](https://github.com/soutaro/rbs-inline) annotation comments in Ruby code.
6
4
 
7
5
  ## Installation
8
6
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
-
11
7
  Install the gem and add to the application's Gemfile by executing:
12
8
 
13
9
  ```bash
14
- bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
10
+ bundle add rubocop-rbs_inline
15
11
  ```
16
12
 
17
13
  If bundler is not being used to manage dependencies, install the gem by executing:
18
14
 
19
15
  ```bash
20
- gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
16
+ gem install rubocop-rbs_inline
21
17
  ```
22
18
 
23
- ## Usage
19
+ Add the following to your `.rubocop.yml`:
24
20
 
25
- TODO: Write usage instructions here
21
+ ```
22
+ require:
23
+ - rubocop-rbs_inline
24
+ ```
26
25
 
27
26
  ## Development
28
27
 
29
28
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
29
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and add Git tag named `vX.Y.Z` and push it to the GitHub. Then GitHub Actions will be release the package to [rubygems.org](https://rubygems.org).
32
31
 
33
32
  ## Contributing
34
33
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rubocop-rbs_inline. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/rubocop-rbs_inline/blob/main/CODE_OF_CONDUCT.md).
34
+ Bug reports and pull requests are welcome on GitHub at https://github.com/tk0miya/rubocop-rbs_inline. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/tk0miya/rubocop-rbs_inline/blob/main/CODE_OF_CONDUCT.md).
36
35
 
37
36
  ## License
38
37
 
@@ -40,4 +39,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
40
39
 
41
40
  ## Code of Conduct
42
41
 
43
- Everyone interacting in the Rubocop::RbsInline project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/rubocop-rbs_inline/blob/main/CODE_OF_CONDUCT.md).
42
+ Everyone interacting in the rubocop-rbs_inline project's codebases and issue trackers is expected to follow the [code of conduct](https://github.com/tk0miya/rubocop-rbs_inline/blob/main/CODE_OF_CONDUCT.md).
@@ -23,10 +23,11 @@ module RuboCop
23
23
  class InvalidTypes < Base
24
24
  include RangeHelp
25
25
  include RBS::Inline::AST::Annotations
26
+ include RBS::Inline::AST::Members
26
27
 
27
28
  MSG = 'Invalid annotation found.'
28
29
 
29
- def on_new_investigation #: void # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
30
+ def on_new_investigation #: void # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
30
31
  results = parse_comments
31
32
  results.each do |result|
32
33
  result.each_annotation do |annotation|
@@ -44,6 +45,11 @@ module RuboCop
44
45
  add_offense(range) if annotation.self_types.empty?
45
46
  when SyntaxErrorAssertion
46
47
  add_offense(range)
48
+ when Embedded
49
+ comment = annotation.source.comments.fetch(0)
50
+ parsing_result = RBS::Inline::AnnotationParser::ParsingResult.new(comment)
51
+ embedded = RBSEmbedded.new(parsing_result, annotation)
52
+ add_offense(range) if embedded.members.is_a?(RBS::ParsingError)
47
53
  end
48
54
  end
49
55
  end
@@ -43,9 +43,9 @@ module RuboCop
43
43
  result.each do |comment|
44
44
  comment.each_annotation do |annotation|
45
45
  case annotation
46
- when RBS::Inline::AST::Annotations::VarType
47
- add_offense_for(annotation) unless annotation.name.start_with?('@')
48
- when RBS::Inline::AST::Annotations::BlockType, RBS::Inline::AST::Annotations::ReturnType
46
+ when RBS::Inline::AST::Annotations::BlockType,
47
+ RBS::Inline::AST::Annotations::ReturnType,
48
+ RBS::Inline::AST::Annotations::VarType
49
49
  add_offense_for(annotation)
50
50
  end
51
51
  end
@@ -57,7 +57,7 @@ module RuboCop
57
57
  private
58
58
 
59
59
  # @rbs node: Parser::AST::Node
60
- def process(node) #: void
60
+ def process(node) #: void # rubocop:disable Metrics/CyclomaticComplexity
61
61
  arguments = arguments_for(node)
62
62
 
63
63
  comment = result.find { |r| r.comments.map(&:location).map(&:start_line).include? node.location.line - 1 }
@@ -66,6 +66,8 @@ module RuboCop
66
66
  result.delete(comment)
67
67
  comment.each_annotation do |annotation|
68
68
  case annotation
69
+ when RBS::Inline::AST::Annotations::IvarType
70
+ add_offense_for(annotation)
69
71
  when RBS::Inline::AST::Annotations::VarType, RBS::Inline::AST::Annotations::BlockType
70
72
  add_offense_for(annotation) unless arguments.include?(annotation_name(annotation))
71
73
  end
@@ -119,6 +121,7 @@ module RuboCop
119
121
  end
120
122
 
121
123
  # @rbs annotation: RBS::Inline::AST::Annotations::BlockType |
124
+ # RBS::Inline::AST::Annotations::IvarType |
122
125
  # RBS::Inline::AST::Annotations::ReturnType |
123
126
  # RBS::Inline::AST::Annotations::VarType
124
127
  def annotation_name(annotation) #: String
@@ -133,6 +136,7 @@ module RuboCop
133
136
  end
134
137
 
135
138
  # @rbs annotation: RBS::Inline::AST::Annotations::BlockType |
139
+ # RBS::Inline::AST::Annotations::IvarType |
136
140
  # RBS::Inline::AST::Annotations::ReturnType |
137
141
  # RBS::Inline::AST::Annotations::VarType
138
142
  def add_offense_for(annotation) #: void # rubocop:disable Metrics/AbcSize
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module RbsInline
5
- VERSION = '1.1.0'
5
+ VERSION = '1.2.0'
6
6
  end
7
7
  end
@@ -6,7 +6,7 @@ gems:
6
6
  source:
7
7
  type: git
8
8
  name: ruby/gem_rbs_collection
9
- revision: 7ae9e3cf731a9628e0cc39064ed6e2cf51d822da
9
+ revision: 218cf130d31f63e110e350efc3fa265311b0f238
10
10
  remote: https://github.com/ruby/gem_rbs_collection.git
11
11
  repo_dir: gems
12
12
  - name: dbm
@@ -18,7 +18,7 @@ gems:
18
18
  source:
19
19
  type: git
20
20
  name: ruby/gem_rbs_collection
21
- revision: 7ae9e3cf731a9628e0cc39064ed6e2cf51d822da
21
+ revision: 218cf130d31f63e110e350efc3fa265311b0f238
22
22
  remote: https://github.com/ruby/gem_rbs_collection.git
23
23
  repo_dir: gems
24
24
  - name: fileutils
@@ -46,7 +46,7 @@ gems:
46
46
  source:
47
47
  type: git
48
48
  name: ruby/gem_rbs_collection
49
- revision: 7ae9e3cf731a9628e0cc39064ed6e2cf51d822da
49
+ revision: 218cf130d31f63e110e350efc3fa265311b0f238
50
50
  remote: https://github.com/ruby/gem_rbs_collection.git
51
51
  repo_dir: gems
52
52
  - name: parser
@@ -54,7 +54,7 @@ gems:
54
54
  source:
55
55
  type: git
56
56
  name: ruby/gem_rbs_collection
57
- revision: 7ae9e3cf731a9628e0cc39064ed6e2cf51d822da
57
+ revision: 218cf130d31f63e110e350efc3fa265311b0f238
58
58
  remote: https://github.com/ruby/gem_rbs_collection.git
59
59
  repo_dir: gems
60
60
  - name: pathname
@@ -78,7 +78,7 @@ gems:
78
78
  source:
79
79
  type: git
80
80
  name: ruby/gem_rbs_collection
81
- revision: 7ae9e3cf731a9628e0cc39064ed6e2cf51d822da
81
+ revision: 218cf130d31f63e110e350efc3fa265311b0f238
82
82
  remote: https://github.com/ruby/gem_rbs_collection.git
83
83
  repo_dir: gems
84
84
  - name: rake
@@ -86,15 +86,15 @@ gems:
86
86
  source:
87
87
  type: git
88
88
  name: ruby/gem_rbs_collection
89
- revision: 7ae9e3cf731a9628e0cc39064ed6e2cf51d822da
89
+ revision: 218cf130d31f63e110e350efc3fa265311b0f238
90
90
  remote: https://github.com/ruby/gem_rbs_collection.git
91
91
  repo_dir: gems
92
92
  - name: rbs
93
- version: 3.5.3
93
+ version: 3.6.1
94
94
  source:
95
95
  type: rubygems
96
96
  - name: rbs-inline
97
- version: 0.8.0
97
+ version: 0.9.0
98
98
  source:
99
99
  type: rubygems
100
100
  - name: rdoc
@@ -106,7 +106,7 @@ gems:
106
106
  source:
107
107
  type: git
108
108
  name: ruby/gem_rbs_collection
109
- revision: 7ae9e3cf731a9628e0cc39064ed6e2cf51d822da
109
+ revision: 218cf130d31f63e110e350efc3fa265311b0f238
110
110
  remote: https://github.com/ruby/gem_rbs_collection.git
111
111
  repo_dir: gems
112
112
  - name: rubocop
@@ -114,7 +114,7 @@ gems:
114
114
  source:
115
115
  type: git
116
116
  name: ruby/gem_rbs_collection
117
- revision: 7ae9e3cf731a9628e0cc39064ed6e2cf51d822da
117
+ revision: 218cf130d31f63e110e350efc3fa265311b0f238
118
118
  remote: https://github.com/ruby/gem_rbs_collection.git
119
119
  repo_dir: gems
120
120
  - name: rubocop-ast
@@ -122,7 +122,7 @@ gems:
122
122
  source:
123
123
  type: git
124
124
  name: ruby/gem_rbs_collection
125
- revision: 7ae9e3cf731a9628e0cc39064ed6e2cf51d822da
125
+ revision: 218cf130d31f63e110e350efc3fa265311b0f238
126
126
  remote: https://github.com/ruby/gem_rbs_collection.git
127
127
  repo_dir: gems
128
128
  - name: strscan
@@ -22,6 +22,8 @@ module RuboCop
22
22
 
23
23
  include RBS::Inline::AST::Annotations
24
24
 
25
+ include RBS::Inline::AST::Members
26
+
25
27
  MSG: ::String
26
28
 
27
29
  def on_new_investigation: () -> void
@@ -45,14 +45,16 @@ module RuboCop
45
45
  def parse_comments: () -> Array[RBS::Inline::AnnotationParser::ParsingResult]
46
46
 
47
47
  # @rbs annotation: RBS::Inline::AST::Annotations::BlockType |
48
+ # RBS::Inline::AST::Annotations::IvarType |
48
49
  # RBS::Inline::AST::Annotations::ReturnType |
49
50
  # RBS::Inline::AST::Annotations::VarType
50
- def annotation_name: (RBS::Inline::AST::Annotations::BlockType | RBS::Inline::AST::Annotations::ReturnType | RBS::Inline::AST::Annotations::VarType annotation) -> String
51
+ def annotation_name: (RBS::Inline::AST::Annotations::BlockType | RBS::Inline::AST::Annotations::IvarType | RBS::Inline::AST::Annotations::ReturnType | RBS::Inline::AST::Annotations::VarType annotation) -> String
51
52
 
52
53
  # @rbs annotation: RBS::Inline::AST::Annotations::BlockType |
54
+ # RBS::Inline::AST::Annotations::IvarType |
53
55
  # RBS::Inline::AST::Annotations::ReturnType |
54
56
  # RBS::Inline::AST::Annotations::VarType
55
- def add_offense_for: (RBS::Inline::AST::Annotations::BlockType | RBS::Inline::AST::Annotations::ReturnType | RBS::Inline::AST::Annotations::VarType annotation) -> void
57
+ def add_offense_for: (RBS::Inline::AST::Annotations::BlockType | RBS::Inline::AST::Annotations::IvarType | RBS::Inline::AST::Annotations::ReturnType | RBS::Inline::AST::Annotations::VarType annotation) -> void
56
58
 
57
59
  # @rbs byte_offset: Integer
58
60
  def character_offset: (Integer byte_offset) -> Integer
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.1.0
4
+ version: 1.2.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: 2024-10-05 00:00:00.000000000 Z
11
+ date: 2024-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbs-inline