yard-lint 1.4.0 → 1.5.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/CHANGELOG.md +60 -3
- data/README.md +154 -529
- data/bin/yard-lint +64 -5
- data/lib/yard/lint/config.rb +4 -0
- data/lib/yard/lint/config_validator.rb +230 -0
- data/lib/yard/lint/errors.rb +6 -0
- data/lib/yard/lint/path_grouper.rb +70 -0
- data/lib/yard/lint/result_builder.rb +19 -5
- data/lib/yard/lint/results/base.rb +3 -3
- data/lib/yard/lint/templates/default_config.yml +17 -0
- data/lib/yard/lint/templates/strict_config.yml +17 -0
- data/lib/yard/lint/todo_generator.rb +261 -0
- data/lib/yard/lint/validators/base.rb +1 -1
- data/lib/yard/lint/validators/documentation/missing_return/config.rb +23 -0
- data/lib/yard/lint/validators/documentation/missing_return/messages_builder.rb +23 -0
- data/lib/yard/lint/validators/documentation/missing_return/parser.rb +128 -0
- data/lib/yard/lint/validators/documentation/missing_return/result.rb +25 -0
- data/lib/yard/lint/validators/documentation/missing_return/validator.rb +40 -0
- data/lib/yard/lint/validators/documentation/missing_return.rb +49 -0
- data/lib/yard/lint/validators/documentation/undocumented_boolean_methods/parser.rb +1 -1
- data/lib/yard/lint/validators/documentation/undocumented_method_arguments/parser.rb +1 -1
- data/lib/yard/lint/validators/documentation/undocumented_method_arguments/validator.rb +3 -0
- data/lib/yard/lint/validators/documentation/undocumented_objects/parser.rb +1 -1
- data/lib/yard/lint/validators/tags/collection_type/messages_builder.rb +8 -2
- data/lib/yard/lint/validators/tags/collection_type/validator.rb +33 -14
- data/lib/yard/lint/validators/tags/example_style/config.rb +33 -0
- data/lib/yard/lint/validators/tags/example_style/linter_detector.rb +71 -0
- data/lib/yard/lint/validators/tags/example_style/messages_builder.rb +29 -0
- data/lib/yard/lint/validators/tags/example_style/parser.rb +88 -0
- data/lib/yard/lint/validators/tags/example_style/result.rb +42 -0
- data/lib/yard/lint/validators/tags/example_style/rubocop_runner.rb +210 -0
- data/lib/yard/lint/validators/tags/example_style/validator.rb +87 -0
- data/lib/yard/lint/validators/tags/example_style.rb +61 -0
- data/lib/yard/lint/validators/tags/forbidden_tags.rb +2 -2
- data/lib/yard/lint/validators/tags/invalid_types/validator.rb +1 -1
- data/lib/yard/lint/validators/tags/tag_group_separator/parser.rb +1 -1
- data/lib/yard/lint/validators/tags/type_syntax/validator.rb +19 -0
- data/lib/yard/lint/validators/warnings/unknown_tag/parser.rb +1 -1
- data/lib/yard/lint/version.rb +1 -1
- metadata +19 -7
- data/.coditsu/ci.yml +0 -3
- data/.ruby-version +0 -1
- data/Rakefile +0 -24
- data/misc/logo.png +0 -0
- data/renovate.json +0 -15
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Yard
|
|
4
|
+
module Lint
|
|
5
|
+
module Validators
|
|
6
|
+
module Tags
|
|
7
|
+
# ExampleStyle validator
|
|
8
|
+
#
|
|
9
|
+
# Validates code style in `@example` tags using RuboCop or StandardRB.
|
|
10
|
+
# This validator ensures that code examples follow the same style guidelines
|
|
11
|
+
# as the project codebase for consistency.
|
|
12
|
+
#
|
|
13
|
+
# ## Requirements
|
|
14
|
+
#
|
|
15
|
+
# - RuboCop or StandardRB gem must be installed
|
|
16
|
+
# - Validator auto-detects which linter to use based on project setup
|
|
17
|
+
#
|
|
18
|
+
# ## Configuration
|
|
19
|
+
#
|
|
20
|
+
# Basic usage:
|
|
21
|
+
#
|
|
22
|
+
# Tags/ExampleStyle:
|
|
23
|
+
# Enabled: true
|
|
24
|
+
#
|
|
25
|
+
# Advanced configuration:
|
|
26
|
+
#
|
|
27
|
+
# Tags/ExampleStyle:
|
|
28
|
+
# Enabled: true
|
|
29
|
+
# Linter: auto # 'auto', 'rubocop', 'standard', or 'none'
|
|
30
|
+
# SkipPatterns:
|
|
31
|
+
# - '/skip-lint/i'
|
|
32
|
+
# - '/bad code/i'
|
|
33
|
+
# DisabledCops:
|
|
34
|
+
# - 'Metrics/MethodLength'
|
|
35
|
+
#
|
|
36
|
+
# ## Skipping Examples
|
|
37
|
+
#
|
|
38
|
+
# Skip linting for specific examples (negative examples):
|
|
39
|
+
#
|
|
40
|
+
# # @example Bad code (skip-lint)
|
|
41
|
+
# # user = User.new("invalid")
|
|
42
|
+
#
|
|
43
|
+
# Or use inline RuboCop directives:
|
|
44
|
+
#
|
|
45
|
+
# # @example
|
|
46
|
+
# # # rubocop:disable all
|
|
47
|
+
# # user = User.new("invalid")
|
|
48
|
+
# # # rubocop:enable all
|
|
49
|
+
module ExampleStyle
|
|
50
|
+
autoload :Validator, 'yard/lint/validators/tags/example_style/validator'
|
|
51
|
+
autoload :Config, 'yard/lint/validators/tags/example_style/config'
|
|
52
|
+
autoload :Parser, 'yard/lint/validators/tags/example_style/parser'
|
|
53
|
+
autoload :Result, 'yard/lint/validators/tags/example_style/result'
|
|
54
|
+
autoload :MessagesBuilder, 'yard/lint/validators/tags/example_style/messages_builder'
|
|
55
|
+
autoload :LinterDetector, 'yard/lint/validators/tags/example_style/linter_detector'
|
|
56
|
+
autoload :RubocopRunner, 'yard/lint/validators/tags/example_style/rubocop_runner'
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -37,14 +37,14 @@ module Yard
|
|
|
37
37
|
# # Does something
|
|
38
38
|
# # @return [void]
|
|
39
39
|
# def do_something
|
|
40
|
-
# puts
|
|
40
|
+
# puts "done"
|
|
41
41
|
# end
|
|
42
42
|
#
|
|
43
43
|
# @example Good - Document side effects instead
|
|
44
44
|
# # Prints 'done' to stdout
|
|
45
45
|
# # @return [nil] always returns nil after printing
|
|
46
46
|
# def do_something
|
|
47
|
-
# puts
|
|
47
|
+
# puts "done"
|
|
48
48
|
# end
|
|
49
49
|
#
|
|
50
50
|
# @example Bad - @param [Object] (when configured as forbidden)
|
|
@@ -34,7 +34,7 @@ module Yard
|
|
|
34
34
|
allowed_types = ALLOWED_DEFAULTS + extra_types
|
|
35
35
|
|
|
36
36
|
# Sanitize type string (remove type syntax characters)
|
|
37
|
-
sanitize = ->(type) { type.tr('=><>,{} ', '') }
|
|
37
|
+
sanitize = ->(type) { type.tr('=><>,{} ()', '') }
|
|
38
38
|
|
|
39
39
|
# Check for invalid types
|
|
40
40
|
invalid_types = object.docstring.tags
|
|
@@ -7,7 +7,7 @@ module Yard
|
|
|
7
7
|
module TagGroupSeparator
|
|
8
8
|
# Parser for extracting tag group separator violations from raw validator output.
|
|
9
9
|
#
|
|
10
|
-
# @example Output format
|
|
10
|
+
# @example Output format (skip-lint)
|
|
11
11
|
# /path/to/file.rb:10: ClassName#method_name
|
|
12
12
|
# param->return,return->error
|
|
13
13
|
class Parser < Parsers::Base
|
|
@@ -7,6 +7,18 @@ module Yard
|
|
|
7
7
|
module TypeSyntax
|
|
8
8
|
# Runs YARD to validate type syntax using TypesExplainer::Parser
|
|
9
9
|
class Validator < Base
|
|
10
|
+
# Matches valid Ruby symbol literals: :foo, :foo?, :foo!, :foo=
|
|
11
|
+
SYMBOL_LITERAL = /\A:[a-zA-Z_]\w*[?!=]?\z/
|
|
12
|
+
# Matches valid quoted symbol literals: :"foo", :'foo' (quotes must match)
|
|
13
|
+
QUOTED_SYMBOL_LITERAL = /\A:("[^"]*"|'[^']*')\z/
|
|
14
|
+
# Matches string literals: "foo", 'foo' (quotes must match)
|
|
15
|
+
STRING_LITERAL = /\A("[^"]*"|'[^']*')\z/
|
|
16
|
+
# Matches numeric literals: 1, -1, 1.0, -2.5
|
|
17
|
+
NUMERIC_LITERAL = /\A-?\d+(\.\d+)?\z/
|
|
18
|
+
|
|
19
|
+
private_constant :SYMBOL_LITERAL, :QUOTED_SYMBOL_LITERAL, :STRING_LITERAL,
|
|
20
|
+
:NUMERIC_LITERAL
|
|
21
|
+
|
|
10
22
|
# Enable in-process execution
|
|
11
23
|
in_process visibility: :public
|
|
12
24
|
|
|
@@ -25,6 +37,13 @@ module Yard
|
|
|
25
37
|
next unless tag.types
|
|
26
38
|
|
|
27
39
|
tag.types.each do |type_str|
|
|
40
|
+
# Skip literal types that YARD accepts but TypesExplainer::Parser doesn't
|
|
41
|
+
# See: https://github.com/mensfeld/yard-lint/issues/109
|
|
42
|
+
next if type_str.match?(SYMBOL_LITERAL)
|
|
43
|
+
next if type_str.match?(QUOTED_SYMBOL_LITERAL)
|
|
44
|
+
next if type_str.match?(STRING_LITERAL)
|
|
45
|
+
next if type_str.match?(NUMERIC_LITERAL)
|
|
46
|
+
|
|
28
47
|
begin
|
|
29
48
|
YARD::Tags::TypesExplainer::Parser.parse(type_str)
|
|
30
49
|
rescue SyntaxError => e
|
|
@@ -6,7 +6,7 @@ module Yard
|
|
|
6
6
|
module Warnings
|
|
7
7
|
module UnknownTag
|
|
8
8
|
# Parser used to extract warnings details that are related to yard unknown tags
|
|
9
|
-
# @example
|
|
9
|
+
# @example Output format (skip-lint)
|
|
10
10
|
# [warn]: Unknown tag @example1 in file `/builds/path/engine.rb` near line 32
|
|
11
11
|
class Parser < ::Yard::Lint::Parsers::OneLineBase
|
|
12
12
|
# Set of regexps for detecting warnings reported by YARD stats
|
data/lib/yard/lint/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: yard-lint
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Maciej Mensfeld
|
|
@@ -46,12 +46,9 @@ executables:
|
|
|
46
46
|
extensions: []
|
|
47
47
|
extra_rdoc_files: []
|
|
48
48
|
files:
|
|
49
|
-
- ".coditsu/ci.yml"
|
|
50
|
-
- ".ruby-version"
|
|
51
49
|
- CHANGELOG.md
|
|
52
50
|
- LICENSE.txt
|
|
53
51
|
- README.md
|
|
54
|
-
- Rakefile
|
|
55
52
|
- bin/yard-lint
|
|
56
53
|
- lib/yard-lint.rb
|
|
57
54
|
- lib/yard/lint.rb
|
|
@@ -59,6 +56,7 @@ files:
|
|
|
59
56
|
- lib/yard/lint/config_generator.rb
|
|
60
57
|
- lib/yard/lint/config_loader.rb
|
|
61
58
|
- lib/yard/lint/config_updater.rb
|
|
59
|
+
- lib/yard/lint/config_validator.rb
|
|
62
60
|
- lib/yard/lint/errors.rb
|
|
63
61
|
- lib/yard/lint/executor/in_process_registry.rb
|
|
64
62
|
- lib/yard/lint/executor/query_executor.rb
|
|
@@ -70,6 +68,7 @@ files:
|
|
|
70
68
|
- lib/yard/lint/parsers/base.rb
|
|
71
69
|
- lib/yard/lint/parsers/one_line_base.rb
|
|
72
70
|
- lib/yard/lint/parsers/two_line_base.rb
|
|
71
|
+
- lib/yard/lint/path_grouper.rb
|
|
73
72
|
- lib/yard/lint/result_builder.rb
|
|
74
73
|
- lib/yard/lint/results/aggregate.rb
|
|
75
74
|
- lib/yard/lint/results/base.rb
|
|
@@ -77,6 +76,7 @@ files:
|
|
|
77
76
|
- lib/yard/lint/stats_calculator.rb
|
|
78
77
|
- lib/yard/lint/templates/default_config.yml
|
|
79
78
|
- lib/yard/lint/templates/strict_config.yml
|
|
79
|
+
- lib/yard/lint/todo_generator.rb
|
|
80
80
|
- lib/yard/lint/validators/base.rb
|
|
81
81
|
- lib/yard/lint/validators/config.rb
|
|
82
82
|
- lib/yard/lint/validators/documentation/blank_line_before_definition.rb
|
|
@@ -97,6 +97,12 @@ files:
|
|
|
97
97
|
- lib/yard/lint/validators/documentation/markdown_syntax/parser.rb
|
|
98
98
|
- lib/yard/lint/validators/documentation/markdown_syntax/result.rb
|
|
99
99
|
- lib/yard/lint/validators/documentation/markdown_syntax/validator.rb
|
|
100
|
+
- lib/yard/lint/validators/documentation/missing_return.rb
|
|
101
|
+
- lib/yard/lint/validators/documentation/missing_return/config.rb
|
|
102
|
+
- lib/yard/lint/validators/documentation/missing_return/messages_builder.rb
|
|
103
|
+
- lib/yard/lint/validators/documentation/missing_return/parser.rb
|
|
104
|
+
- lib/yard/lint/validators/documentation/missing_return/result.rb
|
|
105
|
+
- lib/yard/lint/validators/documentation/missing_return/validator.rb
|
|
100
106
|
- lib/yard/lint/validators/documentation/undocumented_boolean_methods.rb
|
|
101
107
|
- lib/yard/lint/validators/documentation/undocumented_boolean_methods/config.rb
|
|
102
108
|
- lib/yard/lint/validators/documentation/undocumented_boolean_methods/parser.rb
|
|
@@ -137,6 +143,14 @@ files:
|
|
|
137
143
|
- lib/yard/lint/validators/tags/collection_type/parser.rb
|
|
138
144
|
- lib/yard/lint/validators/tags/collection_type/result.rb
|
|
139
145
|
- lib/yard/lint/validators/tags/collection_type/validator.rb
|
|
146
|
+
- lib/yard/lint/validators/tags/example_style.rb
|
|
147
|
+
- lib/yard/lint/validators/tags/example_style/config.rb
|
|
148
|
+
- lib/yard/lint/validators/tags/example_style/linter_detector.rb
|
|
149
|
+
- lib/yard/lint/validators/tags/example_style/messages_builder.rb
|
|
150
|
+
- lib/yard/lint/validators/tags/example_style/parser.rb
|
|
151
|
+
- lib/yard/lint/validators/tags/example_style/result.rb
|
|
152
|
+
- lib/yard/lint/validators/tags/example_style/rubocop_runner.rb
|
|
153
|
+
- lib/yard/lint/validators/tags/example_style/validator.rb
|
|
140
154
|
- lib/yard/lint/validators/tags/example_syntax.rb
|
|
141
155
|
- lib/yard/lint/validators/tags/example_syntax/config.rb
|
|
142
156
|
- lib/yard/lint/validators/tags/example_syntax/messages_builder.rb
|
|
@@ -242,8 +256,6 @@ files:
|
|
|
242
256
|
- lib/yard/lint/validators/warnings/unknown_tag/result.rb
|
|
243
257
|
- lib/yard/lint/validators/warnings/unknown_tag/validator.rb
|
|
244
258
|
- lib/yard/lint/version.rb
|
|
245
|
-
- misc/logo.png
|
|
246
|
-
- renovate.json
|
|
247
259
|
homepage: https://github.com/mensfeld/yard-lint
|
|
248
260
|
licenses:
|
|
249
261
|
- MIT
|
|
@@ -266,7 +278,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
266
278
|
- !ruby/object:Gem::Version
|
|
267
279
|
version: '0'
|
|
268
280
|
requirements: []
|
|
269
|
-
rubygems_version: 4.0.
|
|
281
|
+
rubygems_version: 4.0.6
|
|
270
282
|
specification_version: 4
|
|
271
283
|
summary: YARD documentation linter and validator
|
|
272
284
|
test_files: []
|
data/.coditsu/ci.yml
DELETED
data/.ruby-version
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
4.0
|
data/Rakefile
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'bundler/setup'
|
|
4
|
-
require 'bundler/gem_tasks'
|
|
5
|
-
require 'etc'
|
|
6
|
-
|
|
7
|
-
namespace :spec do
|
|
8
|
-
# Determine optimal number of parallel processes
|
|
9
|
-
# Use all CPUs if less than 8, otherwise cap at 8
|
|
10
|
-
def parallel_process_count
|
|
11
|
-
cpus = Etc.nprocessors
|
|
12
|
-
[cpus, 8].min
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
desc 'Run integration specs in parallel'
|
|
16
|
-
task :integrations do
|
|
17
|
-
sh "bundle exec parallel_rspec -n #{parallel_process_count} spec/integrations/"
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
desc 'Run all specs in parallel'
|
|
21
|
-
task :parallel do
|
|
22
|
-
sh "bundle exec parallel_rspec -n #{parallel_process_count} spec/"
|
|
23
|
-
end
|
|
24
|
-
end
|
data/misc/logo.png
DELETED
|
Binary file
|
data/renovate.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
|
3
|
-
"extends": [
|
|
4
|
-
"config:recommended"
|
|
5
|
-
],
|
|
6
|
-
"minimumReleaseAge": "7 days",
|
|
7
|
-
"github-actions": {
|
|
8
|
-
"enabled": true,
|
|
9
|
-
"pinDigests": true
|
|
10
|
-
},
|
|
11
|
-
"includePaths": [
|
|
12
|
-
"Gemfile",
|
|
13
|
-
"yard-lint.gemspec"
|
|
14
|
-
]
|
|
15
|
-
}
|