yard-lint 1.2.2 → 1.2.3
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 +24 -0
- data/README.md +21 -0
- data/bin/yard-lint +12 -2
- data/lib/yard/lint/config_generator.rb +8 -179
- data/lib/yard/lint/runner.rb +42 -1
- data/lib/yard/lint/stats_calculator.rb +1 -1
- data/lib/yard/lint/templates/default_config.yml +174 -0
- data/lib/yard/lint/templates/strict_config.yml +178 -0
- data/lib/yard/lint/validators/documentation/undocumented_objects/parser.rb +2 -2
- data/lib/yard/lint/validators/tags/collection_type/parser.rb +1 -1
- data/lib/yard/lint/validators/tags/meaningless_tag/parser.rb +1 -1
- data/lib/yard/lint/validators/tags/tag_type_position/parser.rb +1 -1
- data/lib/yard/lint/validators/tags/tag_type_position.rb +4 -4
- data/lib/yard/lint/validators/tags/type_syntax/parser.rb +1 -1
- data/lib/yard/lint/version.rb +1 -1
- metadata +3 -5
- data/bin/console +0 -11
- data/bin/setup +0 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 21f921e879abc0fa9e4722a7731ca9a9cd2bf9ba80791be5de62e54c815dc64b
|
|
4
|
+
data.tar.gz: 921d9ece14e2b400b31c46cce77546fb59967d52fd7c0edb9e2e38a4085fd76a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 83ee69985db1ad6ef6180e29a5a5b337f2e315616df2efabf8f954bad2940151bd55c79dd83fe872dbd10135250f571edc9010c5ce465f19fdc52508041a03b4
|
|
7
|
+
data.tar.gz: 81a12c4ecdbebe8eb45987d2b8a5e5b6d75104640e8af225c3a005b1db6daa17ba0bfbb46256e463ed71587de424e7acf70318d6ba88d877a0aff581f878339c
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# YARD-Lint Changelog
|
|
2
2
|
|
|
3
|
+
## 1.2.3 (2025-11-13)
|
|
4
|
+
- **[Feature]** Add per-validator exclusion support for fine-grained file filtering
|
|
5
|
+
- Individual validators can now specify `Exclude` patterns in `.yard-lint.yml`
|
|
6
|
+
- Exclusions work alongside global `AllValidators.Exclude` patterns
|
|
7
|
+
- Both global and per-validator exclusions are applied (union of both pattern sets)
|
|
8
|
+
- Enables excluding intentionally invalid documentation examples from specific validators
|
|
9
|
+
- Default config excludes validator implementation files and spec fixtures from `Tags/ExampleSyntax`
|
|
10
|
+
- Pattern matching works with glob patterns (`**/*.rb`, `**/validators/**/parser.rb`)
|
|
11
|
+
- Filters validator results based on file location, not just input file selection
|
|
12
|
+
- Handles both absolute and relative paths correctly in pattern matching
|
|
13
|
+
- Comprehensive integration test coverage for exclusion scenarios
|
|
14
|
+
- Example: Exclude parser.rb files with intentionally broken @example tags from syntax validation
|
|
15
|
+
- **[Change]** Update `.yard-lint.yml` to set all validator severities to `error` level
|
|
16
|
+
- Changes `FailOnSeverity` from `warning` to `error` for stricter enforcement
|
|
17
|
+
- All validators now use `error` severity instead of `warning` or `convention`
|
|
18
|
+
- Ensures any documentation issue triggers exit code 1 for CI/CD pipelines
|
|
19
|
+
- Provides consistent behavior across all validation rules
|
|
20
|
+
- **[Fix]** Fix integration tests failing due to fixture files being filtered by global exclusions
|
|
21
|
+
- Added `test_config` helper in spec_helper.rb that clears default exclusions for tests
|
|
22
|
+
- Updated all integration test files to use `test_config` instead of `Yard::Lint::Config.new`
|
|
23
|
+
- Prevents test fixtures in `spec/fixtures/` from being filtered out by `spec/**/*` exclusion pattern
|
|
24
|
+
- Ensures integration tests can properly validate linter behavior on fixture files
|
|
25
|
+
- **[Fix]** Remove not needed `bin/` files.
|
|
26
|
+
|
|
3
27
|
## 1.2.2 (2025-11-13)
|
|
4
28
|
- **[Fix]** Fix `--version` flag failing with `uninitialized constant Yard::Lint::VERSION` error
|
|
5
29
|
- Zeitwerk expected `Version` (camel case) but file defined `VERSION` (all caps)
|
data/README.md
CHANGED
|
@@ -67,6 +67,17 @@ yard-lint --init
|
|
|
67
67
|
|
|
68
68
|
This creates `.yard-lint.yml` with sensible defaults in your current directory.
|
|
69
69
|
|
|
70
|
+
For new projects with high documentation standards, use strict mode:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
yard-lint --init --strict
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
This creates a strict configuration with:
|
|
77
|
+
- All validators set to `error` severity (no warnings or conventions)
|
|
78
|
+
- Minimum documentation coverage set to 100%
|
|
79
|
+
- Perfect for bootstrapping new repositories with high quality standards
|
|
80
|
+
|
|
70
81
|
### Command Line
|
|
71
82
|
|
|
72
83
|
Basic usage:
|
|
@@ -87,6 +98,9 @@ yard-lint lib/ --format json > report.json
|
|
|
87
98
|
# Generate config file (use --force to overwrite existing)
|
|
88
99
|
yard-lint --init
|
|
89
100
|
yard-lint --init --force
|
|
101
|
+
|
|
102
|
+
# Generate strict config (all errors, 100% coverage)
|
|
103
|
+
yard-lint --init --strict
|
|
90
104
|
```
|
|
91
105
|
|
|
92
106
|
### Diff Mode (Incremental Linting)
|
|
@@ -589,7 +603,14 @@ Options:
|
|
|
589
603
|
-f, --format FORMAT Output format (text, json)
|
|
590
604
|
-q, --quiet Quiet mode (only show summary)
|
|
591
605
|
--stats Show statistics summary
|
|
606
|
+
--min-coverage N Minimum documentation coverage required (0-100)
|
|
592
607
|
--[no-]progress Show progress indicator (default: auto-detect TTY)
|
|
608
|
+
--diff [REF] Lint only files changed since REF
|
|
609
|
+
--staged Lint only staged files
|
|
610
|
+
--changed Lint only uncommitted files
|
|
611
|
+
--init Generate .yard-lint.yml config file
|
|
612
|
+
--strict Generate strict config (use with --init)
|
|
613
|
+
--force Force overwrite when using --init
|
|
593
614
|
-v, --version Show version
|
|
594
615
|
-h, --help Show this help
|
|
595
616
|
```
|
data/bin/yard-lint
CHANGED
|
@@ -59,6 +59,10 @@ OptionParser.new do |opts|
|
|
|
59
59
|
options[:init] = true
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
+
opts.on('--strict', 'Generate strict config (all Error severity, 100% coverage). Use with --init') do
|
|
63
|
+
options[:strict] = true
|
|
64
|
+
end
|
|
65
|
+
|
|
62
66
|
opts.on('--force', 'Force overwrite when using --init') do
|
|
63
67
|
options[:force] = true
|
|
64
68
|
end
|
|
@@ -77,14 +81,20 @@ OptionParser.new do |opts|
|
|
|
77
81
|
puts ' yard-lint lib/ --staged # Lint only staged files'
|
|
78
82
|
puts ' yard-lint lib/ --changed # Lint only uncommitted files'
|
|
79
83
|
puts ' yard-lint lib/ --format json # Output in JSON format'
|
|
84
|
+
puts ' yard-lint --init # Generate default config'
|
|
85
|
+
puts ' yard-lint --init --strict # Generate strict config (all errors, 100% coverage)'
|
|
80
86
|
exit
|
|
81
87
|
end
|
|
82
88
|
end.parse!
|
|
83
89
|
|
|
84
90
|
# Handle --init flag
|
|
85
91
|
if options[:init]
|
|
86
|
-
if Yard::Lint::ConfigGenerator.generate(force: options[:force])
|
|
87
|
-
|
|
92
|
+
if Yard::Lint::ConfigGenerator.generate(force: options[:force], strict: options[:strict])
|
|
93
|
+
if options[:strict]
|
|
94
|
+
puts 'Created .yard-lint.yml with strict configuration (all Error severity, 100% coverage)'
|
|
95
|
+
else
|
|
96
|
+
puts 'Created .yard-lint.yml with default configuration'
|
|
97
|
+
end
|
|
88
98
|
exit 0
|
|
89
99
|
else
|
|
90
100
|
puts 'Error: .yard-lint.yml already exists'
|
|
@@ -4,194 +4,23 @@ module Yard
|
|
|
4
4
|
module Lint
|
|
5
5
|
# Generates default .yard-lint.yml configuration file
|
|
6
6
|
class ConfigGenerator
|
|
7
|
-
#
|
|
8
|
-
|
|
9
|
-
# YARD-Lint Configuration
|
|
10
|
-
# See https://github.com/mensfeld/yard-lint for documentation
|
|
11
|
-
|
|
12
|
-
# Global settings for all validators
|
|
13
|
-
AllValidators:
|
|
14
|
-
# YARD command-line options (applied to all validators by default)
|
|
15
|
-
YardOptions:
|
|
16
|
-
- --private
|
|
17
|
-
- --protected
|
|
18
|
-
|
|
19
|
-
# Global file exclusion patterns
|
|
20
|
-
Exclude:
|
|
21
|
-
- '\\.git'
|
|
22
|
-
- 'vendor/**/*'
|
|
23
|
-
- 'node_modules/**/*'
|
|
24
|
-
- 'spec/**/*'
|
|
25
|
-
- 'test/**/*'
|
|
26
|
-
|
|
27
|
-
# Exit code behavior (error, warning, convention, never)
|
|
28
|
-
FailOnSeverity: warning
|
|
29
|
-
|
|
30
|
-
# Minimum documentation coverage percentage (0-100)
|
|
31
|
-
# Fails if coverage is below this threshold
|
|
32
|
-
# MinCoverage: 80.0
|
|
33
|
-
|
|
34
|
-
# Diff mode settings
|
|
35
|
-
DiffMode:
|
|
36
|
-
# Default base ref for --diff (auto-detects main/master if not specified)
|
|
37
|
-
DefaultBaseRef: ~
|
|
38
|
-
|
|
39
|
-
# Documentation validators
|
|
40
|
-
Documentation/UndocumentedObjects:
|
|
41
|
-
Description: 'Checks for classes, modules, and methods without documentation.'
|
|
42
|
-
Enabled: true
|
|
43
|
-
Severity: warning
|
|
44
|
-
ExcludedMethods:
|
|
45
|
-
- 'initialize/0' # Exclude parameter-less initialize
|
|
46
|
-
- '/^_/' # Exclude private methods (by convention)
|
|
47
|
-
|
|
48
|
-
Documentation/UndocumentedMethodArguments:
|
|
49
|
-
Description: 'Checks for method parameters without @param tags.'
|
|
50
|
-
Enabled: true
|
|
51
|
-
Severity: warning
|
|
52
|
-
|
|
53
|
-
Documentation/UndocumentedBooleanMethods:
|
|
54
|
-
Description: 'Checks that question mark methods document their boolean return.'
|
|
55
|
-
Enabled: true
|
|
56
|
-
Severity: warning
|
|
57
|
-
|
|
58
|
-
Documentation/UndocumentedOptions:
|
|
59
|
-
Description: 'Detects methods with options hash parameters but no @option tags.'
|
|
60
|
-
Enabled: true
|
|
61
|
-
Severity: warning
|
|
62
|
-
|
|
63
|
-
Documentation/MarkdownSyntax:
|
|
64
|
-
Description: 'Detects common markdown syntax errors in documentation.'
|
|
65
|
-
Enabled: true
|
|
66
|
-
Severity: warning
|
|
67
|
-
|
|
68
|
-
# Tags validators
|
|
69
|
-
Tags/Order:
|
|
70
|
-
Description: 'Enforces consistent ordering of YARD tags.'
|
|
71
|
-
Enabled: true
|
|
72
|
-
Severity: convention
|
|
73
|
-
EnforcedOrder:
|
|
74
|
-
- param
|
|
75
|
-
- option
|
|
76
|
-
- return
|
|
77
|
-
- raise
|
|
78
|
-
- example
|
|
79
|
-
|
|
80
|
-
Tags/InvalidTypes:
|
|
81
|
-
Description: 'Validates type definitions in @param, @return, @option tags.'
|
|
82
|
-
Enabled: true
|
|
83
|
-
Severity: warning
|
|
84
|
-
ValidatedTags:
|
|
85
|
-
- param
|
|
86
|
-
- option
|
|
87
|
-
- return
|
|
88
|
-
|
|
89
|
-
Tags/TypeSyntax:
|
|
90
|
-
Description: 'Validates YARD type syntax using YARD parser.'
|
|
91
|
-
Enabled: true
|
|
92
|
-
Severity: warning
|
|
93
|
-
ValidatedTags:
|
|
94
|
-
- param
|
|
95
|
-
- option
|
|
96
|
-
- return
|
|
97
|
-
- yieldreturn
|
|
98
|
-
|
|
99
|
-
Tags/MeaninglessTag:
|
|
100
|
-
Description: 'Detects @param/@option tags on classes, modules, or constants.'
|
|
101
|
-
Enabled: true
|
|
102
|
-
Severity: warning
|
|
103
|
-
CheckedTags:
|
|
104
|
-
- param
|
|
105
|
-
- option
|
|
106
|
-
InvalidObjectTypes:
|
|
107
|
-
- class
|
|
108
|
-
- module
|
|
109
|
-
- constant
|
|
110
|
-
|
|
111
|
-
Tags/CollectionType:
|
|
112
|
-
Description: 'Validates Hash collection syntax consistency.'
|
|
113
|
-
Enabled: true
|
|
114
|
-
Severity: convention
|
|
115
|
-
EnforcedStyle: long # 'long' for Hash{K => V} (YARD standard), 'short' for {K => V}
|
|
116
|
-
ValidatedTags:
|
|
117
|
-
- param
|
|
118
|
-
- option
|
|
119
|
-
- return
|
|
120
|
-
- yieldreturn
|
|
121
|
-
|
|
122
|
-
Tags/TagTypePosition:
|
|
123
|
-
Description: 'Validates type annotation position in tags.'
|
|
124
|
-
Enabled: true
|
|
125
|
-
Severity: convention
|
|
126
|
-
CheckedTags:
|
|
127
|
-
- param
|
|
128
|
-
- option
|
|
129
|
-
# EnforcedStyle: 'type_after_name' (YARD standard: @param name [Type])
|
|
130
|
-
# or 'type_first' (@param [Type] name)
|
|
131
|
-
EnforcedStyle: type_after_name
|
|
132
|
-
|
|
133
|
-
Tags/ApiTags:
|
|
134
|
-
Description: 'Enforces @api tags on public objects.'
|
|
135
|
-
Enabled: false # Opt-in validator
|
|
136
|
-
Severity: warning
|
|
137
|
-
AllowedApis:
|
|
138
|
-
- public
|
|
139
|
-
- private
|
|
140
|
-
- internal
|
|
141
|
-
|
|
142
|
-
Tags/OptionTags:
|
|
143
|
-
Description: 'Requires @option tags for methods with options parameters.'
|
|
144
|
-
Enabled: true
|
|
145
|
-
Severity: warning
|
|
146
|
-
|
|
147
|
-
# Warnings validators - catches YARD parser errors
|
|
148
|
-
Warnings/UnknownTag:
|
|
149
|
-
Description: 'Detects unknown YARD tags.'
|
|
150
|
-
Enabled: true
|
|
151
|
-
Severity: error
|
|
152
|
-
|
|
153
|
-
Warnings/UnknownDirective:
|
|
154
|
-
Description: 'Detects unknown YARD directives.'
|
|
155
|
-
Enabled: true
|
|
156
|
-
Severity: error
|
|
157
|
-
|
|
158
|
-
Warnings/InvalidTagFormat:
|
|
159
|
-
Description: 'Detects malformed tag syntax.'
|
|
160
|
-
Enabled: true
|
|
161
|
-
Severity: error
|
|
162
|
-
|
|
163
|
-
Warnings/InvalidDirectiveFormat:
|
|
164
|
-
Description: 'Detects malformed directive syntax.'
|
|
165
|
-
Enabled: true
|
|
166
|
-
Severity: error
|
|
167
|
-
|
|
168
|
-
Warnings/DuplicatedParameterName:
|
|
169
|
-
Description: 'Detects duplicate @param tags.'
|
|
170
|
-
Enabled: true
|
|
171
|
-
Severity: error
|
|
172
|
-
|
|
173
|
-
Warnings/UnknownParameterName:
|
|
174
|
-
Description: 'Detects @param tags for non-existent parameters.'
|
|
175
|
-
Enabled: true
|
|
176
|
-
Severity: error
|
|
177
|
-
|
|
178
|
-
# Semantic validators
|
|
179
|
-
Semantic/AbstractMethods:
|
|
180
|
-
Description: 'Ensures @abstract methods do not have real implementations.'
|
|
181
|
-
Enabled: true
|
|
182
|
-
Severity: warning
|
|
183
|
-
YAML
|
|
7
|
+
# Path to templates directory
|
|
8
|
+
TEMPLATES_DIR = File.expand_path('templates', __dir__)
|
|
184
9
|
|
|
185
10
|
# Generate .yard-lint.yml file in current directory
|
|
186
11
|
# @param force [Boolean] overwrite existing file if true
|
|
12
|
+
# @param strict [Boolean] generate strict configuration (all errors, 100% coverage)
|
|
187
13
|
# @return [Boolean] true if file was created, false if already exists
|
|
188
|
-
def self.generate(force: false)
|
|
14
|
+
def self.generate(force: false, strict: false)
|
|
189
15
|
config_path = File.join(Dir.pwd, Config::DEFAULT_CONFIG_FILE)
|
|
190
16
|
|
|
191
17
|
if File.exist?(config_path) && !force
|
|
192
18
|
false
|
|
193
19
|
else
|
|
194
|
-
|
|
20
|
+
template_name = strict ? 'strict_config.yml' : 'default_config.yml'
|
|
21
|
+
template_path = File.join(TEMPLATES_DIR, template_name)
|
|
22
|
+
content = File.read(template_path)
|
|
23
|
+
File.write(config_path, content)
|
|
195
24
|
true
|
|
196
25
|
end
|
|
197
26
|
end
|
data/lib/yard/lint/runner.rb
CHANGED
|
@@ -96,6 +96,43 @@ module Yard
|
|
|
96
96
|
end
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
+
# Filter result offenses based on per-validator exclusions
|
|
100
|
+
# Removes offenses where the file path matches exclusion patterns
|
|
101
|
+
# @param validator_name [String] full validator name
|
|
102
|
+
# @param result [Results::Base] result object with offenses
|
|
103
|
+
# @return [Results::Base, nil] result with filtered offenses, or nil if no offenses remain
|
|
104
|
+
def filter_result_offenses(validator_name, result)
|
|
105
|
+
validator_excludes = config.validator_all_excludes(validator_name)
|
|
106
|
+
return result if validator_excludes.empty?
|
|
107
|
+
|
|
108
|
+
working_dir = Dir.pwd
|
|
109
|
+
filtered_keys = %i[severity type name message location_line]
|
|
110
|
+
|
|
111
|
+
filtered_offenses = result.offenses.reject do |offense|
|
|
112
|
+
file_path = offense[:location] || offense[:file]
|
|
113
|
+
next true unless file_path
|
|
114
|
+
|
|
115
|
+
# Convert to relative path for pattern matching
|
|
116
|
+
relative_path = if file_path.start_with?(working_dir)
|
|
117
|
+
file_path.sub(%r{^#{Regexp.escape(working_dir)}/}, '')
|
|
118
|
+
else
|
|
119
|
+
file_path
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Check if file matches any exclusion pattern
|
|
123
|
+
validator_excludes.any? do |pattern|
|
|
124
|
+
File.fnmatch(pattern, relative_path, File::FNM_PATHNAME | File::FNM_EXTGLOB)
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Return nil if no offenses remain after filtering
|
|
129
|
+
return nil if filtered_offenses.empty?
|
|
130
|
+
|
|
131
|
+
# Create a new result object with filtered offenses
|
|
132
|
+
# We need to preserve the result class and config
|
|
133
|
+
result.class.new(filtered_offenses.map { |o| o.except(*filtered_keys) }, result.config)
|
|
134
|
+
end
|
|
135
|
+
|
|
99
136
|
# Parse raw results from validators and create Result objects
|
|
100
137
|
# Delegates result building to ResultBuilder
|
|
101
138
|
# @param raw [Hash] hash with raw results from all validators
|
|
@@ -108,7 +145,11 @@ module Yard
|
|
|
108
145
|
next unless config.validator_enabled?(validator_name)
|
|
109
146
|
|
|
110
147
|
result = @result_builder.build(validator_name, raw)
|
|
111
|
-
|
|
148
|
+
next unless result
|
|
149
|
+
|
|
150
|
+
# Filter offenses based on per-validator exclusions
|
|
151
|
+
filtered_result = filter_result_offenses(validator_name, result)
|
|
152
|
+
results << filtered_result if filtered_result
|
|
112
153
|
end
|
|
113
154
|
|
|
114
155
|
results
|
|
@@ -8,7 +8,7 @@ module Yard
|
|
|
8
8
|
attr_reader :config, :files
|
|
9
9
|
|
|
10
10
|
# @param config [Yard::Lint::Config] configuration object
|
|
11
|
-
# @param files [Array<String>] files
|
|
11
|
+
# @param files [Array<String>] Ruby source files whose YARD documentation will be checked for coverage statistics
|
|
12
12
|
def initialize(config, files)
|
|
13
13
|
@config = config
|
|
14
14
|
@files = Array(files).compact
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# YARD-Lint Configuration
|
|
2
|
+
# See https://github.com/mensfeld/yard-lint for documentation
|
|
3
|
+
|
|
4
|
+
# Global settings for all validators
|
|
5
|
+
AllValidators:
|
|
6
|
+
# YARD command-line options (applied to all validators by default)
|
|
7
|
+
YardOptions:
|
|
8
|
+
- --private
|
|
9
|
+
- --protected
|
|
10
|
+
|
|
11
|
+
# Global file exclusion patterns
|
|
12
|
+
Exclude:
|
|
13
|
+
- '\.git'
|
|
14
|
+
- 'vendor/**/*'
|
|
15
|
+
- 'node_modules/**/*'
|
|
16
|
+
- 'spec/**/*'
|
|
17
|
+
- 'test/**/*'
|
|
18
|
+
|
|
19
|
+
# Exit code behavior (error, warning, convention, never)
|
|
20
|
+
FailOnSeverity: warning
|
|
21
|
+
|
|
22
|
+
# Minimum documentation coverage percentage (0-100)
|
|
23
|
+
# Fails if coverage is below this threshold
|
|
24
|
+
# MinCoverage: 80.0
|
|
25
|
+
|
|
26
|
+
# Diff mode settings
|
|
27
|
+
DiffMode:
|
|
28
|
+
# Default base ref for --diff (auto-detects main/master if not specified)
|
|
29
|
+
DefaultBaseRef: ~
|
|
30
|
+
|
|
31
|
+
# Documentation validators
|
|
32
|
+
Documentation/UndocumentedObjects:
|
|
33
|
+
Description: 'Checks for classes, modules, and methods without documentation.'
|
|
34
|
+
Enabled: true
|
|
35
|
+
Severity: warning
|
|
36
|
+
ExcludedMethods:
|
|
37
|
+
- 'initialize/0' # Exclude parameter-less initialize
|
|
38
|
+
- '/^_/' # Exclude private methods (by convention)
|
|
39
|
+
|
|
40
|
+
Documentation/UndocumentedMethodArguments:
|
|
41
|
+
Description: 'Checks for method parameters without @param tags.'
|
|
42
|
+
Enabled: true
|
|
43
|
+
Severity: warning
|
|
44
|
+
|
|
45
|
+
Documentation/UndocumentedBooleanMethods:
|
|
46
|
+
Description: 'Checks that question mark methods document their boolean return.'
|
|
47
|
+
Enabled: true
|
|
48
|
+
Severity: warning
|
|
49
|
+
|
|
50
|
+
Documentation/UndocumentedOptions:
|
|
51
|
+
Description: 'Detects methods with options hash parameters but no @option tags.'
|
|
52
|
+
Enabled: true
|
|
53
|
+
Severity: warning
|
|
54
|
+
|
|
55
|
+
Documentation/MarkdownSyntax:
|
|
56
|
+
Description: 'Detects common markdown syntax errors in documentation.'
|
|
57
|
+
Enabled: true
|
|
58
|
+
Severity: warning
|
|
59
|
+
|
|
60
|
+
# Tags validators
|
|
61
|
+
Tags/Order:
|
|
62
|
+
Description: 'Enforces consistent ordering of YARD tags.'
|
|
63
|
+
Enabled: true
|
|
64
|
+
Severity: convention
|
|
65
|
+
EnforcedOrder:
|
|
66
|
+
- param
|
|
67
|
+
- option
|
|
68
|
+
- return
|
|
69
|
+
- raise
|
|
70
|
+
- example
|
|
71
|
+
|
|
72
|
+
Tags/InvalidTypes:
|
|
73
|
+
Description: 'Validates type definitions in @param, @return, @option tags.'
|
|
74
|
+
Enabled: true
|
|
75
|
+
Severity: warning
|
|
76
|
+
ValidatedTags:
|
|
77
|
+
- param
|
|
78
|
+
- option
|
|
79
|
+
- return
|
|
80
|
+
|
|
81
|
+
Tags/TypeSyntax:
|
|
82
|
+
Description: 'Validates YARD type syntax using YARD parser.'
|
|
83
|
+
Enabled: true
|
|
84
|
+
Severity: warning
|
|
85
|
+
ValidatedTags:
|
|
86
|
+
- param
|
|
87
|
+
- option
|
|
88
|
+
- return
|
|
89
|
+
- yieldreturn
|
|
90
|
+
|
|
91
|
+
Tags/MeaninglessTag:
|
|
92
|
+
Description: 'Detects @param/@option tags on classes, modules, or constants.'
|
|
93
|
+
Enabled: true
|
|
94
|
+
Severity: warning
|
|
95
|
+
CheckedTags:
|
|
96
|
+
- param
|
|
97
|
+
- option
|
|
98
|
+
InvalidObjectTypes:
|
|
99
|
+
- class
|
|
100
|
+
- module
|
|
101
|
+
- constant
|
|
102
|
+
|
|
103
|
+
Tags/CollectionType:
|
|
104
|
+
Description: 'Validates Hash collection syntax consistency.'
|
|
105
|
+
Enabled: true
|
|
106
|
+
Severity: convention
|
|
107
|
+
EnforcedStyle: long # 'long' for Hash{K => V} (YARD standard), 'short' for {K => V}
|
|
108
|
+
ValidatedTags:
|
|
109
|
+
- param
|
|
110
|
+
- option
|
|
111
|
+
- return
|
|
112
|
+
- yieldreturn
|
|
113
|
+
|
|
114
|
+
Tags/TagTypePosition:
|
|
115
|
+
Description: 'Validates type annotation position in tags.'
|
|
116
|
+
Enabled: true
|
|
117
|
+
Severity: convention
|
|
118
|
+
CheckedTags:
|
|
119
|
+
- param
|
|
120
|
+
- option
|
|
121
|
+
# EnforcedStyle: 'type_after_name' (YARD standard: @param name [Type])
|
|
122
|
+
# or 'type_first' (@param [Type] name)
|
|
123
|
+
EnforcedStyle: type_after_name
|
|
124
|
+
|
|
125
|
+
Tags/ApiTags:
|
|
126
|
+
Description: 'Enforces @api tags on public objects.'
|
|
127
|
+
Enabled: false # Opt-in validator
|
|
128
|
+
Severity: warning
|
|
129
|
+
AllowedApis:
|
|
130
|
+
- public
|
|
131
|
+
- private
|
|
132
|
+
- internal
|
|
133
|
+
|
|
134
|
+
Tags/OptionTags:
|
|
135
|
+
Description: 'Requires @option tags for methods with options parameters.'
|
|
136
|
+
Enabled: true
|
|
137
|
+
Severity: warning
|
|
138
|
+
|
|
139
|
+
# Warnings validators - catches YARD parser errors
|
|
140
|
+
Warnings/UnknownTag:
|
|
141
|
+
Description: 'Detects unknown YARD tags.'
|
|
142
|
+
Enabled: true
|
|
143
|
+
Severity: error
|
|
144
|
+
|
|
145
|
+
Warnings/UnknownDirective:
|
|
146
|
+
Description: 'Detects unknown YARD directives.'
|
|
147
|
+
Enabled: true
|
|
148
|
+
Severity: error
|
|
149
|
+
|
|
150
|
+
Warnings/InvalidTagFormat:
|
|
151
|
+
Description: 'Detects malformed tag syntax.'
|
|
152
|
+
Enabled: true
|
|
153
|
+
Severity: error
|
|
154
|
+
|
|
155
|
+
Warnings/InvalidDirectiveFormat:
|
|
156
|
+
Description: 'Detects malformed directive syntax.'
|
|
157
|
+
Enabled: true
|
|
158
|
+
Severity: error
|
|
159
|
+
|
|
160
|
+
Warnings/DuplicatedParameterName:
|
|
161
|
+
Description: 'Detects duplicate @param tags.'
|
|
162
|
+
Enabled: true
|
|
163
|
+
Severity: error
|
|
164
|
+
|
|
165
|
+
Warnings/UnknownParameterName:
|
|
166
|
+
Description: 'Detects @param tags for non-existent parameters.'
|
|
167
|
+
Enabled: true
|
|
168
|
+
Severity: error
|
|
169
|
+
|
|
170
|
+
# Semantic validators
|
|
171
|
+
Semantic/AbstractMethods:
|
|
172
|
+
Description: 'Ensures @abstract methods do not have real implementations.'
|
|
173
|
+
Enabled: true
|
|
174
|
+
Severity: warning
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# YARD-Lint Configuration (Strict Mode)
|
|
2
|
+
# See https://github.com/mensfeld/yard-lint for documentation
|
|
3
|
+
#
|
|
4
|
+
# This is a strict configuration suitable for new projects with high documentation standards.
|
|
5
|
+
# All validators are set to 'error' severity (no warnings or conventions).
|
|
6
|
+
# Minimum coverage is set to 100%.
|
|
7
|
+
|
|
8
|
+
# Global settings for all validators
|
|
9
|
+
AllValidators:
|
|
10
|
+
# YARD command-line options (applied to all validators by default)
|
|
11
|
+
YardOptions:
|
|
12
|
+
- --private
|
|
13
|
+
- --protected
|
|
14
|
+
|
|
15
|
+
# Global file exclusion patterns
|
|
16
|
+
Exclude:
|
|
17
|
+
- '\.git'
|
|
18
|
+
- 'vendor/**/*'
|
|
19
|
+
- 'node_modules/**/*'
|
|
20
|
+
- 'spec/**/*'
|
|
21
|
+
- 'test/**/*'
|
|
22
|
+
|
|
23
|
+
# Exit code behavior (error, warning, convention, never)
|
|
24
|
+
FailOnSeverity: error
|
|
25
|
+
|
|
26
|
+
# Minimum documentation coverage percentage (0-100)
|
|
27
|
+
# Fails if coverage is below this threshold
|
|
28
|
+
MinCoverage: 100.0
|
|
29
|
+
|
|
30
|
+
# Diff mode settings
|
|
31
|
+
DiffMode:
|
|
32
|
+
# Default base ref for --diff (auto-detects main/master if not specified)
|
|
33
|
+
DefaultBaseRef: ~
|
|
34
|
+
|
|
35
|
+
# Documentation validators
|
|
36
|
+
Documentation/UndocumentedObjects:
|
|
37
|
+
Description: 'Checks for classes, modules, and methods without documentation.'
|
|
38
|
+
Enabled: true
|
|
39
|
+
Severity: error
|
|
40
|
+
ExcludedMethods:
|
|
41
|
+
- 'initialize/0' # Exclude parameter-less initialize
|
|
42
|
+
- '/^_/' # Exclude private methods (by convention)
|
|
43
|
+
|
|
44
|
+
Documentation/UndocumentedMethodArguments:
|
|
45
|
+
Description: 'Checks for method parameters without @param tags.'
|
|
46
|
+
Enabled: true
|
|
47
|
+
Severity: error
|
|
48
|
+
|
|
49
|
+
Documentation/UndocumentedBooleanMethods:
|
|
50
|
+
Description: 'Checks that question mark methods document their boolean return.'
|
|
51
|
+
Enabled: true
|
|
52
|
+
Severity: error
|
|
53
|
+
|
|
54
|
+
Documentation/UndocumentedOptions:
|
|
55
|
+
Description: 'Detects methods with options hash parameters but no @option tags.'
|
|
56
|
+
Enabled: true
|
|
57
|
+
Severity: error
|
|
58
|
+
|
|
59
|
+
Documentation/MarkdownSyntax:
|
|
60
|
+
Description: 'Detects common markdown syntax errors in documentation.'
|
|
61
|
+
Enabled: true
|
|
62
|
+
Severity: error
|
|
63
|
+
|
|
64
|
+
# Tags validators
|
|
65
|
+
Tags/Order:
|
|
66
|
+
Description: 'Enforces consistent ordering of YARD tags.'
|
|
67
|
+
Enabled: true
|
|
68
|
+
Severity: error
|
|
69
|
+
EnforcedOrder:
|
|
70
|
+
- param
|
|
71
|
+
- option
|
|
72
|
+
- return
|
|
73
|
+
- raise
|
|
74
|
+
- example
|
|
75
|
+
|
|
76
|
+
Tags/InvalidTypes:
|
|
77
|
+
Description: 'Validates type definitions in @param, @return, @option tags.'
|
|
78
|
+
Enabled: true
|
|
79
|
+
Severity: error
|
|
80
|
+
ValidatedTags:
|
|
81
|
+
- param
|
|
82
|
+
- option
|
|
83
|
+
- return
|
|
84
|
+
|
|
85
|
+
Tags/TypeSyntax:
|
|
86
|
+
Description: 'Validates YARD type syntax using YARD parser.'
|
|
87
|
+
Enabled: true
|
|
88
|
+
Severity: error
|
|
89
|
+
ValidatedTags:
|
|
90
|
+
- param
|
|
91
|
+
- option
|
|
92
|
+
- return
|
|
93
|
+
- yieldreturn
|
|
94
|
+
|
|
95
|
+
Tags/MeaninglessTag:
|
|
96
|
+
Description: 'Detects @param/@option tags on classes, modules, or constants.'
|
|
97
|
+
Enabled: true
|
|
98
|
+
Severity: error
|
|
99
|
+
CheckedTags:
|
|
100
|
+
- param
|
|
101
|
+
- option
|
|
102
|
+
InvalidObjectTypes:
|
|
103
|
+
- class
|
|
104
|
+
- module
|
|
105
|
+
- constant
|
|
106
|
+
|
|
107
|
+
Tags/CollectionType:
|
|
108
|
+
Description: 'Validates Hash collection syntax consistency.'
|
|
109
|
+
Enabled: true
|
|
110
|
+
Severity: error
|
|
111
|
+
EnforcedStyle: long # 'long' for Hash{K => V} (YARD standard), 'short' for {K => V}
|
|
112
|
+
ValidatedTags:
|
|
113
|
+
- param
|
|
114
|
+
- option
|
|
115
|
+
- return
|
|
116
|
+
- yieldreturn
|
|
117
|
+
|
|
118
|
+
Tags/TagTypePosition:
|
|
119
|
+
Description: 'Validates type annotation position in tags.'
|
|
120
|
+
Enabled: true
|
|
121
|
+
Severity: error
|
|
122
|
+
CheckedTags:
|
|
123
|
+
- param
|
|
124
|
+
- option
|
|
125
|
+
# EnforcedStyle: 'type_after_name' (YARD standard: @param name [Type])
|
|
126
|
+
# or 'type_first' (@param [Type] name)
|
|
127
|
+
EnforcedStyle: type_after_name
|
|
128
|
+
|
|
129
|
+
Tags/ApiTags:
|
|
130
|
+
Description: 'Enforces @api tags on public objects.'
|
|
131
|
+
Enabled: false # Opt-in validator
|
|
132
|
+
Severity: error
|
|
133
|
+
AllowedApis:
|
|
134
|
+
- public
|
|
135
|
+
- private
|
|
136
|
+
- internal
|
|
137
|
+
|
|
138
|
+
Tags/OptionTags:
|
|
139
|
+
Description: 'Requires @option tags for methods with options parameters.'
|
|
140
|
+
Enabled: true
|
|
141
|
+
Severity: error
|
|
142
|
+
|
|
143
|
+
# Warnings validators - catches YARD parser errors
|
|
144
|
+
Warnings/UnknownTag:
|
|
145
|
+
Description: 'Detects unknown YARD tags.'
|
|
146
|
+
Enabled: true
|
|
147
|
+
Severity: error
|
|
148
|
+
|
|
149
|
+
Warnings/UnknownDirective:
|
|
150
|
+
Description: 'Detects unknown YARD directives.'
|
|
151
|
+
Enabled: true
|
|
152
|
+
Severity: error
|
|
153
|
+
|
|
154
|
+
Warnings/InvalidTagFormat:
|
|
155
|
+
Description: 'Detects malformed tag syntax.'
|
|
156
|
+
Enabled: true
|
|
157
|
+
Severity: error
|
|
158
|
+
|
|
159
|
+
Warnings/InvalidDirectiveFormat:
|
|
160
|
+
Description: 'Detects malformed directive syntax.'
|
|
161
|
+
Enabled: true
|
|
162
|
+
Severity: error
|
|
163
|
+
|
|
164
|
+
Warnings/DuplicatedParameterName:
|
|
165
|
+
Description: 'Detects duplicate @param tags.'
|
|
166
|
+
Enabled: true
|
|
167
|
+
Severity: error
|
|
168
|
+
|
|
169
|
+
Warnings/UnknownParameterName:
|
|
170
|
+
Description: 'Detects @param tags for non-existent parameters.'
|
|
171
|
+
Enabled: true
|
|
172
|
+
Severity: error
|
|
173
|
+
|
|
174
|
+
# Semantic validators
|
|
175
|
+
Semantic/AbstractMethods:
|
|
176
|
+
Description: 'Ensures @abstract methods do not have real implementations.'
|
|
177
|
+
Enabled: true
|
|
178
|
+
Severity: error
|
|
@@ -16,7 +16,7 @@ module Yard
|
|
|
16
16
|
|
|
17
17
|
# @param yard_list_output [String] raw yard list results string
|
|
18
18
|
# @param config [Yard::Lint::Config, nil] configuration object (optional)
|
|
19
|
-
# @
|
|
19
|
+
# @option _kwargs [Object] :unused this parameter accepts no options (reserved for future use)
|
|
20
20
|
# @return [Array<Hash>] Array with undocumented objects details
|
|
21
21
|
def call(yard_list_output, config: nil, **_kwargs)
|
|
22
22
|
excluded_methods = config&.validator_config(
|
|
@@ -108,7 +108,7 @@ module Yard
|
|
|
108
108
|
|
|
109
109
|
# Match an arity pattern like "initialize/0"
|
|
110
110
|
# @param method_name [String] the method name
|
|
111
|
-
# @param arity [Integer, nil] the method
|
|
111
|
+
# @param arity [Integer, nil] number of parameters the method accepts (nil if unknown)
|
|
112
112
|
# @param pattern [String] the full pattern like "initialize/0"
|
|
113
113
|
# @return [Boolean] true if matches
|
|
114
114
|
def match_arity_pattern(method_name, arity, pattern)
|
|
@@ -9,7 +9,7 @@ module Yard
|
|
|
9
9
|
class Parser < ::Yard::Lint::Parsers::Base
|
|
10
10
|
# Parses YARD query output into structured violation data
|
|
11
11
|
# @param yard_output [String] raw output from YARD query
|
|
12
|
-
# @
|
|
12
|
+
# @option _kwargs [Object] :unused this parameter accepts no options (reserved for future use)
|
|
13
13
|
# @return [Array<Hash>] array of violation hashes
|
|
14
14
|
def call(yard_output, **_kwargs)
|
|
15
15
|
return [] if yard_output.nil? || yard_output.strip.empty?
|
|
@@ -13,7 +13,7 @@ module Yard
|
|
|
13
13
|
# file.rb:LINE: ClassName
|
|
14
14
|
# object_type|tag_name
|
|
15
15
|
# @param yard_output [String] raw YARD query results
|
|
16
|
-
# @
|
|
16
|
+
# @option _kwargs [Object] :unused this parameter accepts no options (reserved for future use)
|
|
17
17
|
# @return [Array<Hash>] array with violation details
|
|
18
18
|
def call(yard_output, **_kwargs)
|
|
19
19
|
return [] if yard_output.nil? || yard_output.strip.empty?
|
|
@@ -9,7 +9,7 @@ module Yard
|
|
|
9
9
|
class Parser < ::Yard::Lint::Parsers::Base
|
|
10
10
|
# Parses YARD query output into structured violation data
|
|
11
11
|
# @param yard_output [String] raw output from YARD query
|
|
12
|
-
# @
|
|
12
|
+
# @option _kwargs [Object] :unused this parameter accepts no options (reserved for future use)
|
|
13
13
|
# @return [Array<Hash>] array of violation hashes
|
|
14
14
|
def call(yard_output, **_kwargs)
|
|
15
15
|
return [] if yard_output.nil? || yard_output.strip.empty?
|
|
@@ -20,8 +20,8 @@ module Yard
|
|
|
20
20
|
# end
|
|
21
21
|
#
|
|
22
22
|
# @example Bad - Type before parameter name (when using default style)
|
|
23
|
-
# # @param [String]
|
|
24
|
-
# # @param [Integer]
|
|
23
|
+
# # @param name [String] the user's name
|
|
24
|
+
# # @param age [Integer] the user's age
|
|
25
25
|
# def create_user(name, age)
|
|
26
26
|
# end
|
|
27
27
|
#
|
|
@@ -33,8 +33,8 @@ module Yard
|
|
|
33
33
|
# EnforcedStyle: type_first
|
|
34
34
|
#
|
|
35
35
|
# @example Good - When EnforcedStyle is type_first
|
|
36
|
-
# # @param [String]
|
|
37
|
-
# # @param [Integer]
|
|
36
|
+
# # @param name [String] the user's name
|
|
37
|
+
# # @param age [Integer] the user's age
|
|
38
38
|
# def create_user(name, age)
|
|
39
39
|
# end
|
|
40
40
|
#
|
|
@@ -13,7 +13,7 @@ module Yard
|
|
|
13
13
|
# file.rb:LINE: ClassName#method_name
|
|
14
14
|
# tag_name|type_string|error_message
|
|
15
15
|
# @param yard_output [String] raw YARD query results
|
|
16
|
-
# @
|
|
16
|
+
# @option _kwargs [Object] :unused this parameter accepts no options (reserved for future use)
|
|
17
17
|
# @return [Array<Hash>] array with violation details
|
|
18
18
|
def call(yard_output, **_kwargs)
|
|
19
19
|
return [] if yard_output.nil? || yard_output.strip.empty?
|
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.2.
|
|
4
|
+
version: 1.2.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Maciej Mensfeld
|
|
@@ -42,8 +42,6 @@ description: A comprehensive linter for YARD documentation that checks for undoc
|
|
|
42
42
|
email:
|
|
43
43
|
- maciej@mensfeld.pl
|
|
44
44
|
executables:
|
|
45
|
-
- console
|
|
46
|
-
- setup
|
|
47
45
|
- yard-lint
|
|
48
46
|
extensions: []
|
|
49
47
|
extra_rdoc_files: []
|
|
@@ -53,8 +51,6 @@ files:
|
|
|
53
51
|
- LICENSE.txt
|
|
54
52
|
- README.md
|
|
55
53
|
- Rakefile
|
|
56
|
-
- bin/console
|
|
57
|
-
- bin/setup
|
|
58
54
|
- bin/yard-lint
|
|
59
55
|
- lib/yard-lint.rb
|
|
60
56
|
- lib/yard/lint.rb
|
|
@@ -74,6 +70,8 @@ files:
|
|
|
74
70
|
- lib/yard/lint/results/base.rb
|
|
75
71
|
- lib/yard/lint/runner.rb
|
|
76
72
|
- lib/yard/lint/stats_calculator.rb
|
|
73
|
+
- lib/yard/lint/templates/default_config.yml
|
|
74
|
+
- lib/yard/lint/templates/strict_config.yml
|
|
77
75
|
- lib/yard/lint/validators/base.rb
|
|
78
76
|
- lib/yard/lint/validators/config.rb
|
|
79
77
|
- lib/yard/lint/validators/documentation/markdown_syntax.rb
|
data/bin/console
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require "bundler/setup"
|
|
5
|
-
require "yard/lint"
|
|
6
|
-
|
|
7
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
|
-
# with your gem easier. You can also use a different console, if you like.
|
|
9
|
-
|
|
10
|
-
require "irb"
|
|
11
|
-
IRB.start(__FILE__)
|