rubocop-yard 0.9.3 → 1.0.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: 6ea212d5b8a01f36b28635f8959436cc74fc9946a31cda2a9c0a8657416d0e40
4
- data.tar.gz: cc737883475574dde1ac09c73236b3809f0ad4bc2cc3cf23c48fc69ba2af195a
3
+ metadata.gz: 40bdb35bd0b95a6bc84afcf35b31d27acfb45eba7dae27862fef99b4fb961f29
4
+ data.tar.gz: 00341d80e3051ed88f0ecc390e463c5a6e2edc25f63a4d00ee1b1fba56d83ce2
5
5
  SHA512:
6
- metadata.gz: f4ebb19d49340e6404b87dc1348ea96dedbece58551be6fac937ec74877c0724fc8b8ae28bf552090c38adc56006c69d1f6be7eefd93cc00eb0d0685982cb9d0
7
- data.tar.gz: 12ded42ee94f5dbcb2f81338fc4b20ce7fdb4f822c59c2f77e175091fde81017ebca2db425da42b792e332d49eb18826db6a52b8a293722f6ced2658c9455776
6
+ metadata.gz: b63811dcf428762af0afa33d0e237aa44b49846793ab7b19d66d4f5e5c1fd1484081e2b9a1b4ba999b535ea55572704369d484c4266bd28bd77117d9636f3b7c
7
+ data.tar.gz: a8c37ca47cfd1bd6dcc0a3f7d6e05f198ade8f7f530ba142593aee19be660c233912ff456f261162f9b9b98f2ed648f89b3cfe1ddce7b5e55f28d865e94bc9d8
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.10.0] - 2024-11-20
4
+
5
+ * Guess argument types by @ksss in https://github.com/ksss/rubocop-yard/pull/32
6
+
7
+ ## [0.9.3] - 2024-01-31
8
+
3
9
  - Suppress YARD warning logs
4
10
 
5
11
  ## [0.9.0] - 2023-11-28
data/README.md CHANGED
@@ -131,7 +131,8 @@ If bundler is not being used to manage dependencies, install the gem by executin
131
131
  Put this into your `.rubocop.yml`.
132
132
 
133
133
  ```yaml
134
- require: rubocop-yard
134
+ plugins:
135
+ - rubocop-yard
135
136
  ```
136
137
 
137
138
  ## Development
@@ -97,28 +97,53 @@ module RuboCop
97
97
 
98
98
  # @param [RuboCop::AST::ArgNode] argument
99
99
  def tag_prototype(argument)
100
- case argument.type
101
- when :kwrestarg
102
- case cop_config_prototype_name
103
- when "before"
104
- "@param #{argument.name} [Hash{Symbol => Object}]"
105
- when "after"
106
- "@param [Hash{Symbol => Object}] #{argument.name}"
107
- end
108
- when :restarg
109
- case cop_config_prototype_name
110
- when "before"
111
- "@param #{argument.name} [Array<Object>]"
112
- when "after"
113
- "@param [Array<Object>] #{argument.name}"
114
- end
100
+ type = case argument.type
101
+ when :kwrestarg
102
+ "Hash{Symbol => Object}"
103
+ when :restarg
104
+ "Array<Object>"
105
+ when :optarg, :kwoptarg
106
+ literal_to_yard_type(argument.children.last)
107
+ else
108
+ "Object"
109
+ end
110
+
111
+ case cop_config_prototype_name
112
+ when "before"
113
+ "@param #{argument.name} [#{type}]"
114
+ when "after"
115
+ "@param [#{type}] #{argument.name}"
116
+ end
117
+ end
118
+
119
+ def literal_to_yard_type(node)
120
+ case node.type
121
+ when :int
122
+ "Integer"
123
+ when :float
124
+ "Float"
125
+ when :rational
126
+ "Rational"
127
+ when :complex
128
+ "Complex"
129
+ when :str
130
+ "String"
131
+ when :true, :false
132
+ "Boolean"
133
+ when :sym
134
+ "Symbol"
135
+ when :array
136
+ "Array<Object>"
137
+ when :hash
138
+ "Hash{Symbol => Object}"
139
+ when :regexp
140
+ "Regexp"
141
+ when :irange, :erange
142
+ "Range[Object]"
143
+ when :nil
144
+ "Object, nil"
115
145
  else
116
- case cop_config_prototype_name
117
- when "before"
118
- "@param #{argument.name} [Object]"
119
- when "after"
120
- "@param [Object] #{argument.name}"
121
- end
146
+ "Object"
122
147
  end
123
148
  end
124
149
 
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'lint_roller'
4
+
5
+ module RuboCop
6
+ module YARD
7
+ # A plugin that integrates RuboCop Performance with RuboCop's plugin system.
8
+ class Plugin < LintRoller::Plugin
9
+ def about
10
+ LintRoller::About.new(
11
+ name: 'rubocop-yard',
12
+ version: VERSION,
13
+ homepage: 'https://github.com/ksss/rubocop-yard',
14
+ description: 'Check yardoc format like tag type.'
15
+ )
16
+ end
17
+
18
+ def supported?(context)
19
+ context.engine == :rubocop
20
+ end
21
+
22
+ def rules(_context)
23
+ LintRoller::Rules.new(
24
+ type: :path,
25
+ config_format: :rubocop,
26
+ value: Pathname.new(__dir__).join('../../../config/default.yml')
27
+ )
28
+ end
29
+ end
30
+ end
31
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module YARD
5
- VERSION = "0.9.3"
5
+ VERSION = "1.0.0"
6
6
  end
7
7
  end
data/lib/rubocop-yard.rb CHANGED
@@ -4,8 +4,6 @@ require 'rubocop'
4
4
 
5
5
  require_relative 'rubocop/yard'
6
6
  require_relative 'rubocop/yard/version'
7
- require_relative 'rubocop/yard/inject'
8
-
9
- RuboCop::YARD::Inject.defaults!
7
+ require_relative 'rubocop/yard/plugin'
10
8
 
11
9
  require_relative 'rubocop/cop/yard_cops'
metadata CHANGED
@@ -1,29 +1,42 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-yard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ksss
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-01-31 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: lint_roller
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
13
26
  - !ruby/object:Gem::Dependency
14
27
  name: rubocop
15
28
  requirement: !ruby/object:Gem::Requirement
16
29
  requirements:
17
30
  - - "~>"
18
31
  - !ruby/object:Gem::Version
19
- version: '1.21'
32
+ version: '1.72'
20
33
  type: :runtime
21
34
  prerelease: false
22
35
  version_requirements: !ruby/object:Gem::Requirement
23
36
  requirements:
24
37
  - - "~>"
25
38
  - !ruby/object:Gem::Version
26
- version: '1.21'
39
+ version: '1.72'
27
40
  - !ruby/object:Gem::Dependency
28
41
  name: yard
29
42
  requirement: !ruby/object:Gem::Requirement
@@ -61,7 +74,7 @@ files:
61
74
  - lib/rubocop/cop/yard/tag_type_syntax.rb
62
75
  - lib/rubocop/cop/yard_cops.rb
63
76
  - lib/rubocop/yard.rb
64
- - lib/rubocop/yard/inject.rb
77
+ - lib/rubocop/yard/plugin.rb
65
78
  - lib/rubocop/yard/version.rb
66
79
  - sig/rubocop/yard.rbs
67
80
  homepage: https://github.com/ksss/rubocop-yard
@@ -72,7 +85,7 @@ metadata:
72
85
  source_code_uri: https://github.com/ksss/rubocop-yard
73
86
  changelog_uri: https://github.com/ksss/rubocop-yard
74
87
  rubygems_mfa_required: 'true'
75
- post_install_message:
88
+ default_lint_roller_plugin: RuboCop::YARD::Plugin
76
89
  rdoc_options: []
77
90
  require_paths:
78
91
  - lib
@@ -87,8 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
100
  - !ruby/object:Gem::Version
88
101
  version: '0'
89
102
  requirements: []
90
- rubygems_version: 3.5.3
91
- signing_key:
103
+ rubygems_version: 3.7.0.dev
92
104
  specification_version: 4
93
105
  summary: Check yardoc format.
94
106
  test_files: []
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # The original code is from https://github.com/rubocop/rubocop-rspec/blob/master/lib/rubocop/rspec/inject.rb
4
- # See https://github.com/rubocop/rubocop-rspec/blob/master/MIT-LICENSE.md
5
- module RuboCop
6
- module YARD
7
- # Because RuboCop doesn't yet support plugins, we have to monkey patch in a
8
- # bit of our configuration.
9
- module Inject
10
- def self.defaults!
11
- path = CONFIG_DEFAULT.to_s
12
- hash = ConfigLoader.send(:load_yaml_configuration, path)
13
- config = Config.new(hash, path).tap(&:make_excludes_absolute)
14
- puts "configuration from #{path}" if ConfigLoader.debug?
15
- config = ConfigLoader.merge_with_default(config, path)
16
- ConfigLoader.instance_variable_set(:@default_configuration, config)
17
- end
18
- end
19
- end
20
- end