Skip to content

Commit d3f197c

Browse files
authored
Merge pull request #20 from ksss/fix-bug
Fix bug
2 parents 62f322e + c5ee2dd commit d3f197c

19 files changed

+235
-64
lines changed

Gemfile.lock

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,58 +8,69 @@ PATH
88
GEM
99
remote: https://rubygems.org/
1010
specs:
11-
activesupport (7.0.8)
11+
abbrev (0.1.1)
12+
activesupport (7.1.2)
13+
base64
14+
bigdecimal
1215
concurrent-ruby (~> 1.0, >= 1.0.2)
16+
connection_pool (>= 2.2.5)
17+
drb
1318
i18n (>= 1.6, < 2)
1419
minitest (>= 5.1)
20+
mutex_m
1521
tzinfo (~> 2.0)
1622
ast (2.4.2)
17-
base64 (0.1.1)
23+
base64 (0.2.0)
24+
bigdecimal (3.1.4)
1825
concurrent-ruby (1.2.2)
19-
csv (3.2.7)
26+
connection_pool (2.4.1)
27+
csv (3.2.8)
2028
debug (1.8.0)
2129
irb (>= 1.5.0)
2230
reline (>= 0.3.1)
23-
ffi (1.15.5)
24-
fileutils (1.7.1)
31+
drb (2.2.0)
32+
ruby2_keywords
33+
ffi (1.16.3)
34+
fileutils (1.7.2)
2535
i18n (1.14.1)
2636
concurrent-ruby (~> 1.0)
2737
io-console (0.6.0)
28-
irb (1.8.1)
38+
irb (1.9.1)
2939
rdoc
3040
reline (>= 0.3.8)
3141
json (2.6.3)
3242
language_server-protocol (3.17.0.3)
3343
listen (3.8.0)
3444
rb-fsevent (~> 0.10, >= 0.10.3)
3545
rb-inotify (~> 0.9, >= 0.9.10)
36-
logger (1.5.3)
46+
logger (1.6.0)
3747
minitest (5.20.0)
48+
mutex_m (0.2.0)
3849
parallel (1.23.0)
39-
parser (3.2.2.3)
50+
parser (3.2.2.4)
4051
ast (~> 2.4.1)
4152
racc
42-
psych (5.1.0)
53+
psych (5.1.1.1)
4354
stringio
44-
racc (1.7.1)
55+
racc (1.7.3)
4556
rainbow (3.1.1)
46-
rake (13.0.6)
57+
rake (13.1.0)
4758
rb-fsevent (0.11.2)
4859
rb-inotify (0.10.1)
4960
ffi (~> 1.0)
50-
rbs (3.2.1)
51-
rdoc (6.5.0)
61+
rbs (3.3.2)
62+
abbrev
63+
rdoc (6.6.0)
5264
psych (>= 4.0.0)
5365
regexp_parser (2.8.2)
54-
reline (0.3.8)
66+
reline (0.4.0)
5567
io-console (~> 0.5)
5668
rexml (3.2.6)
57-
rubocop (1.56.4)
58-
base64 (~> 0.1.1)
69+
rubocop (1.57.2)
5970
json (~> 2.3)
6071
language_server-protocol (>= 3.17.0)
6172
parallel (~> 1.10)
62-
parser (>= 3.2.2.3)
73+
parser (>= 3.2.2.4)
6374
rainbow (>= 2.2.2, < 4.0)
6475
regexp_parser (>= 1.8, < 3.0)
6576
rexml (>= 3.2.5, < 4.0)
@@ -69,8 +80,9 @@ GEM
6980
rubocop-ast (1.30.0)
7081
parser (>= 3.2.1.0)
7182
ruby-progressbar (1.13.0)
72-
securerandom (0.2.2)
73-
steep (1.5.3)
83+
ruby2_keywords (0.0.5)
84+
securerandom (0.3.0)
85+
steep (1.6.0)
7486
activesupport (>= 5.1)
7587
concurrent-ruby (>= 1.1.10)
7688
csv (>= 3.0.9)
@@ -85,13 +97,13 @@ GEM
8597
securerandom (>= 0.1)
8698
strscan (>= 1.0.0)
8799
terminal-table (>= 2, < 4)
88-
stringio (3.0.8)
89-
strscan (3.0.6)
100+
stringio (3.0.9)
101+
strscan (3.0.7)
90102
terminal-table (3.0.2)
91103
unicode-display_width (>= 1.1.1, < 3)
92104
tzinfo (2.0.6)
93105
concurrent-ruby (~> 1.0)
94-
unicode-display_width (2.4.2)
106+
unicode-display_width (2.5.0)
95107
yard (0.9.34)
96108

97109
PLATFORMS

lib/rubocop/cop/yard/helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def parse_type(type)
1919

2020
def each_types_explainer(docstring, &block)
2121
docstring.tags.each do |tag|
22-
types = extract_tag_types(tag)
22+
types = extract_tag_types(tag) or next
2323

2424
begin
2525
types_explainers = parse_type(types.join(', '))

lib/rubocop/cop/yard/mismatch_name.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def on_def(node)
5757
end
5858

5959
next unless node.arguments.none? { |arg_node| tag.name.to_sym == arg_node.name }
60+
next unless types
6061

6162
begin
6263
parse_type(types.join(', '))
@@ -148,8 +149,8 @@ def find_by_tag(preceding_lines, tag, i)
148149
end
149150

150151
def add_offense_to_tag(node, comment, tag)
151-
tag_name_regexp = Regexp.new("\\b#{Regexp.escape(tag.name)}\\b")
152-
start_column = comment.source.index(tag_name_regexp)
152+
tag_name_regexp = Regexp.new("\\s#{Regexp.escape(tag.name)}\\s")
153+
start_column = comment.source.index(tag_name_regexp) or return
153154
offense_start = comment.location.column + start_column
154155
offense_end = offense_start + tag.name.length - 1
155156
range = source_range(processed_source.buffer, comment.location.line, offense_start..offense_end)

lib/rubocop/cop/yard/tag_type_syntax.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def on_new_investigation
2727
def check(comment)
2828
docstring = comment.text.gsub(/\A#\s*/, '')
2929
::YARD::DocstringParser.new.parse(docstring).tags.each do |tag|
30-
types = extract_tag_types(tag)
30+
types = extract_tag_types(tag) or next
3131

3232
check_syntax_error(comment) do
3333
parse_type(types.join(', '))

rbs_collection.lock.yaml

Lines changed: 75 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,27 @@
11
---
2-
sources:
3-
- type: git
4-
name: ruby/gem_rbs_collection
5-
revision: 12424e3d58a56044aa60cd99c83150145163bc37
6-
remote: https://github.com/ruby/gem_rbs_collection.git
7-
repo_dir: gems
82
path: ".gem_rbs_collection"
93
gems:
104
- name: activesupport
115
version: '7.0'
126
source:
137
type: git
148
name: ruby/gem_rbs_collection
15-
revision: 12424e3d58a56044aa60cd99c83150145163bc37
9+
revision: 4b0d2f72e63b6c3e92dc54e19ce23dd24524f9a7
1610
remote: https://github.com/ruby/gem_rbs_collection.git
1711
repo_dir: gems
1812
- name: ast
1913
version: '2.4'
2014
source:
2115
type: git
2216
name: ruby/gem_rbs_collection
23-
revision: 12424e3d58a56044aa60cd99c83150145163bc37
17+
revision: 4b0d2f72e63b6c3e92dc54e19ce23dd24524f9a7
2418
remote: https://github.com/ruby/gem_rbs_collection.git
2519
repo_dir: gems
2620
- name: base64
2721
version: '0'
2822
source:
2923
type: stdlib
30-
- name: cgi
24+
- name: bigdecimal
3125
version: '0'
3226
source:
3327
type: stdlib
@@ -36,7 +30,15 @@ gems:
3630
source:
3731
type: git
3832
name: ruby/gem_rbs_collection
39-
revision: 12424e3d58a56044aa60cd99c83150145163bc37
33+
revision: 4b0d2f72e63b6c3e92dc54e19ce23dd24524f9a7
34+
remote: https://github.com/ruby/gem_rbs_collection.git
35+
repo_dir: gems
36+
- name: connection_pool
37+
version: '2.4'
38+
source:
39+
type: git
40+
name: ruby/gem_rbs_collection
41+
revision: 4b0d2f72e63b6c3e92dc54e19ce23dd24524f9a7
4042
remote: https://github.com/ruby/gem_rbs_collection.git
4143
repo_dir: gems
4244
- name: csv
@@ -47,6 +49,10 @@ gems:
4749
version: '0'
4850
source:
4951
type: stdlib
52+
- name: dbm
53+
version: '0'
54+
source:
55+
type: stdlib
5056
- name: erb
5157
version: '0'
5258
source:
@@ -64,7 +70,7 @@ gems:
6470
source:
6571
type: git
6672
name: ruby/gem_rbs_collection
67-
revision: 12424e3d58a56044aa60cd99c83150145163bc37
73+
revision: 4b0d2f72e63b6c3e92dc54e19ce23dd24524f9a7
6874
remote: https://github.com/ruby/gem_rbs_collection.git
6975
repo_dir: gems
7076
- name: io-console
@@ -80,7 +86,7 @@ gems:
8086
source:
8187
type: git
8288
name: ruby/gem_rbs_collection
83-
revision: 12424e3d58a56044aa60cd99c83150145163bc37
89+
revision: 4b0d2f72e63b6c3e92dc54e19ce23dd24524f9a7
8490
remote: https://github.com/ruby/gem_rbs_collection.git
8591
repo_dir: gems
8692
- name: logger
@@ -108,21 +114,73 @@ gems:
108114
source:
109115
type: git
110116
name: ruby/gem_rbs_collection
111-
revision: 12424e3d58a56044aa60cd99c83150145163bc37
117+
revision: 4b0d2f72e63b6c3e92dc54e19ce23dd24524f9a7
118+
remote: https://github.com/ruby/gem_rbs_collection.git
119+
repo_dir: gems
120+
- name: parser
121+
version: '3.2'
122+
source:
123+
type: git
124+
name: ruby/gem_rbs_collection
125+
revision: 4b0d2f72e63b6c3e92dc54e19ce23dd24524f9a7
112126
remote: https://github.com/ruby/gem_rbs_collection.git
113127
repo_dir: gems
128+
- name: pstore
129+
version: '0'
130+
source:
131+
type: stdlib
132+
- name: psych
133+
version: '0'
134+
source:
135+
type: stdlib
114136
- name: rainbow
115137
version: '3.0'
116138
source:
117139
type: git
118140
name: ruby/gem_rbs_collection
119-
revision: 12424e3d58a56044aa60cd99c83150145163bc37
141+
revision: 4b0d2f72e63b6c3e92dc54e19ce23dd24524f9a7
142+
remote: https://github.com/ruby/gem_rbs_collection.git
143+
repo_dir: gems
144+
- name: rake
145+
version: '13.0'
146+
source:
147+
type: git
148+
name: ruby/gem_rbs_collection
149+
revision: 4b0d2f72e63b6c3e92dc54e19ce23dd24524f9a7
120150
remote: https://github.com/ruby/gem_rbs_collection.git
121151
repo_dir: gems
122152
- name: rdoc
123153
version: '0'
124154
source:
125155
type: stdlib
156+
- name: regexp_parser
157+
version: '2.8'
158+
source:
159+
type: git
160+
name: ruby/gem_rbs_collection
161+
revision: 4b0d2f72e63b6c3e92dc54e19ce23dd24524f9a7
162+
remote: https://github.com/ruby/gem_rbs_collection.git
163+
repo_dir: gems
164+
- name: ripper
165+
version: '0'
166+
source:
167+
type: stdlib
168+
- name: rubocop
169+
version: '1.57'
170+
source:
171+
type: git
172+
name: ruby/gem_rbs_collection
173+
revision: 4b0d2f72e63b6c3e92dc54e19ce23dd24524f9a7
174+
remote: https://github.com/ruby/gem_rbs_collection.git
175+
repo_dir: gems
176+
- name: rubocop-ast
177+
version: '1.30'
178+
source:
179+
type: git
180+
name: ruby/gem_rbs_collection
181+
revision: 4b0d2f72e63b6c3e92dc54e19ce23dd24524f9a7
182+
remote: https://github.com/ruby/gem_rbs_collection.git
183+
repo_dir: gems
126184
- name: securerandom
127185
version: '0'
128186
source:
@@ -132,22 +190,18 @@ gems:
132190
source:
133191
type: stdlib
134192
- name: steep
135-
version: 1.5.3
193+
version: 1.6.0
136194
source:
137195
type: rubygems
138196
- name: strscan
139197
version: '0'
140198
source:
141199
type: stdlib
142-
- name: tempfile
143-
version: '0'
144-
source:
145-
type: stdlib
146200
- name: time
147201
version: '0'
148202
source:
149203
type: stdlib
150-
- name: uri
204+
- name: timeout
151205
version: '0'
152206
source:
153207
type: stdlib
@@ -156,7 +210,7 @@ gems:
156210
source:
157211
type: git
158212
name: ruby/gem_rbs_collection
159-
revision: 12424e3d58a56044aa60cd99c83150145163bc37
213+
revision: 4b0d2f72e63b6c3e92dc54e19ce23dd24524f9a7
160214
remote: https://github.com/ruby/gem_rbs_collection.git
161215
repo_dir: gems
162216
gemfile_lock_path: Gemfile.lock

sig/rubocop/yard.rbs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,36 @@ module RuboCop
55
end
66
module Cop
77
module YARD
8+
type tag = ::YARD::Tags::Tag | ::YARD::Tags::OverloadTag | ::YARD::Tags::OptionTag
9+
type tag_types = YARD::Tags::TypesExplainer::Type
10+
| ::YARD::Tags::TypesExplainer::CollectionType
11+
| ::YARD::Tags::TypesExplainer::FixedCollectionType
12+
| ::YARD::Tags::TypesExplainer::HashCollectionType
813
class CollectionType
9-
type t = YARD::Tags::TypesExplainer::Type
10-
| ::YARD::Tags::TypesExplainer::CollectionType
11-
| ::YARD::Tags::TypesExplainer::FixedCollectionType
12-
| ::YARD::Tags::TypesExplainer::HashCollectionType
13-
private def check_mismatch_collection_type: (untyped comment, t types_explainer) -> void
14+
private def check_mismatch_collection_type: (untyped comment, tag_types types_explainer) -> void
15+
end
16+
17+
module Helper
18+
def extract_tag_types: (tag tag) -> Array[String]?
19+
end
20+
21+
class TagTypeSyntax < ::RuboCop::Cop::Base
22+
include YARD::Helper
23+
24+
private
25+
26+
def check: (::Parser::Source::Comment comment) -> void
27+
def check_syntax_error: (::Parser::Source::Comment comment) { () -> void } -> void
28+
def inline_comment?: (::Parser::Source::Comment comment) -> bool
29+
def include_yard_tag?: (::Parser::Source::Comment comment) -> bool
30+
def tag_range_for_comment: (::Parser::Source::Comment comment) -> untyped
31+
end
32+
33+
class MismatchName < ::RuboCop::Cop::Base
34+
include YARD::Helper
35+
36+
def add_offense_to_tag: (untyped node, ::Parser::Source::Comment comment, ::YARD::Tags::Tag tag) -> void
37+
def cop_config_prototype_name: () -> ("before" | "after")
1438
end
1539
end
1640
end

0 commit comments

Comments
 (0)