rubocop-yard 0.8.1 → 0.8.2

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: 64ff6712be966753c2ddc2510a4a51c1d36488ed302b8fc848f50e8beb6561b5
4
- data.tar.gz: a34143c5775f3705adb8bd4aac2837b4c4b2334f7191ccc2c7629b015cd3fe89
3
+ metadata.gz: dc21b6abfe7772ded3bcfc7eb7c3db68b8eff3716d15d9442520e8d367c3295f
4
+ data.tar.gz: c706a4a3c2db6bbf36b22d1810f5ec06b4d7312ee7d2906ee57b8f6f41b40960
5
5
  SHA512:
6
- metadata.gz: 1bdf6a2b0740459083c5e1b0e93ecab91172b372821168972879f94bb3b59c21706a0eb84895d03cf6ce915ab25b510100c8c84edd7cecd8469d8b6950647cc0
7
- data.tar.gz: 89d4dd145df3813f14e4f3fb790e892c1948858843a8ab1b834450c6eac52164f5d222ebc8c8dcd3db3589d23e0b82ae599a9247e60f41d3697b82c8e0157c44
6
+ metadata.gz: ed1ed3631058b5d08ee5d8fc1e90ec7edcf5a5d3d6f9ada711fa9e6719102679156a20e98881337f69cec095810f90183651b7d005c321145ed3bf0cf2e70735
7
+ data.tar.gz: 5d1963992a5223efbfb696cde08c8428045d004b681ea4a53f5d8e73cd463907e491b3b3ac47aa00251b551aba13dd6232593bd4e472d7be1317cd7c3b75f77d
@@ -19,7 +19,7 @@ module RuboCop
19
19
 
20
20
  def each_types_explainer(docstring, &block)
21
21
  docstring.tags.each do |tag|
22
- types = extract_tag_types(tag)
22
+ types = extract_tag_types(tag) or next
23
23
 
24
24
  begin
25
25
  types_explainers = parse_type(types.join(', '))
@@ -57,6 +57,7 @@ module RuboCop
57
57
  end
58
58
 
59
59
  next unless node.arguments.none? { |arg_node| tag.name.to_sym == arg_node.name }
60
+ next unless types
60
61
 
61
62
  begin
62
63
  parse_type(types.join(', '))
@@ -148,8 +149,8 @@ module RuboCop
148
149
  end
149
150
 
150
151
  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
153
154
  offense_start = comment.location.column + start_column
154
155
  offense_end = offense_start + tag.name.length - 1
155
156
  range = source_range(processed_source.buffer, comment.location.line, offense_start..offense_end)
@@ -27,7 +27,7 @@ module RuboCop
27
27
  def check(comment)
28
28
  docstring = comment.text.gsub(/\A#\s*/, '')
29
29
  ::YARD::DocstringParser.new.parse(docstring).tags.each do |tag|
30
- types = extract_tag_types(tag)
30
+ types = extract_tag_types(tag) or next
31
31
 
32
32
  check_syntax_error(comment) do
33
33
  parse_type(types.join(', '))
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module YARD
5
- VERSION = "0.8.1"
5
+ VERSION = "0.8.2"
6
6
  end
7
7
  end
data/sig/rubocop/yard.rbs CHANGED
@@ -5,12 +5,36 @@ module RuboCop
5
5
  end
6
6
  module Cop
7
7
  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
8
13
  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")
14
38
  end
15
39
  end
16
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-yard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ksss
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-22 00:00:00.000000000 Z
11
+ date: 2023-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop