yard-lint 1.2.2 → 1.3.0.rc1
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 +174 -1
- data/README.md +118 -3
- data/Rakefile +20 -0
- data/bin/yard-lint +80 -37
- data/lib/yard/lint/config.rb +5 -0
- data/lib/yard/lint/config_generator.rb +8 -179
- data/lib/yard/lint/config_updater.rb +222 -0
- data/lib/yard/lint/errors.rb +6 -0
- data/lib/yard/lint/executor/in_process_registry.rb +130 -0
- data/lib/yard/lint/executor/query_executor.rb +109 -0
- data/lib/yard/lint/executor/result_collector.rb +55 -0
- data/lib/yard/lint/executor/warning_dispatcher.rb +79 -0
- data/lib/yard/lint/results/base.rb +2 -1
- data/lib/yard/lint/runner.rb +88 -35
- data/lib/yard/lint/stats_calculator.rb +1 -1
- data/lib/yard/lint/templates/default_config.yml +279 -0
- data/lib/yard/lint/templates/strict_config.yml +283 -0
- data/lib/yard/lint/validators/base.rb +52 -118
- data/lib/yard/lint/validators/documentation/blank_line_before_definition/config.rb +25 -0
- data/lib/yard/lint/validators/documentation/blank_line_before_definition/messages_builder.rb +39 -0
- data/lib/yard/lint/validators/documentation/blank_line_before_definition/parser.rb +59 -0
- data/lib/yard/lint/validators/documentation/blank_line_before_definition/result.rb +61 -0
- data/lib/yard/lint/validators/documentation/blank_line_before_definition/validator.rb +94 -0
- data/lib/yard/lint/validators/documentation/blank_line_before_definition.rb +63 -0
- data/lib/yard/lint/validators/documentation/empty_comment_line/config.rb +24 -0
- data/lib/yard/lint/validators/documentation/empty_comment_line/messages_builder.rb +34 -0
- data/lib/yard/lint/validators/documentation/empty_comment_line/parser.rb +60 -0
- data/lib/yard/lint/validators/documentation/empty_comment_line/result.rb +25 -0
- data/lib/yard/lint/validators/documentation/empty_comment_line/validator.rb +109 -0
- data/lib/yard/lint/validators/documentation/empty_comment_line.rb +58 -0
- data/lib/yard/lint/validators/documentation/markdown_syntax/validator.rb +36 -21
- data/lib/yard/lint/validators/documentation/markdown_syntax.rb +0 -1
- data/lib/yard/lint/validators/documentation/undocumented_boolean_methods/validator.rb +19 -29
- data/lib/yard/lint/validators/documentation/undocumented_boolean_methods.rb +0 -1
- data/lib/yard/lint/validators/documentation/undocumented_method_arguments/validator.rb +18 -34
- data/lib/yard/lint/validators/documentation/undocumented_method_arguments.rb +0 -1
- data/lib/yard/lint/validators/documentation/undocumented_objects/parser.rb +2 -2
- data/lib/yard/lint/validators/documentation/undocumented_objects/validator.rb +17 -25
- data/lib/yard/lint/validators/documentation/undocumented_objects.rb +4 -5
- data/lib/yard/lint/validators/documentation/undocumented_options/validator.rb +30 -21
- data/lib/yard/lint/validators/documentation/undocumented_options.rb +0 -1
- data/lib/yard/lint/validators/semantic/abstract_methods/result.rb +2 -2
- data/lib/yard/lint/validators/semantic/abstract_methods/validator.rb +31 -43
- data/lib/yard/lint/validators/semantic/abstract_methods.rb +0 -1
- data/lib/yard/lint/validators/tags/api_tags/validator.rb +24 -39
- data/lib/yard/lint/validators/tags/api_tags.rb +0 -1
- data/lib/yard/lint/validators/tags/collection_type/parser.rb +1 -1
- data/lib/yard/lint/validators/tags/collection_type/validator.rb +37 -66
- data/lib/yard/lint/validators/tags/collection_type.rb +0 -1
- data/lib/yard/lint/validators/tags/example_syntax/validator.rb +51 -64
- data/lib/yard/lint/validators/tags/example_syntax.rb +0 -1
- data/lib/yard/lint/validators/tags/informal_notation/config.rb +40 -0
- data/lib/yard/lint/validators/tags/informal_notation/messages_builder.rb +35 -0
- data/lib/yard/lint/validators/tags/informal_notation/parser.rb +55 -0
- data/lib/yard/lint/validators/tags/informal_notation/result.rb +26 -0
- data/lib/yard/lint/validators/tags/informal_notation/validator.rb +133 -0
- data/lib/yard/lint/validators/tags/informal_notation.rb +45 -0
- data/lib/yard/lint/validators/tags/invalid_types/validator.rb +57 -70
- data/lib/yard/lint/validators/tags/invalid_types.rb +0 -1
- data/lib/yard/lint/validators/tags/meaningless_tag/parser.rb +1 -1
- data/lib/yard/lint/validators/tags/meaningless_tag/validator.rb +22 -54
- data/lib/yard/lint/validators/tags/meaningless_tag.rb +0 -1
- data/lib/yard/lint/validators/tags/non_ascii_type/config.rb +21 -0
- data/lib/yard/lint/validators/tags/non_ascii_type/messages_builder.rb +29 -0
- data/lib/yard/lint/validators/tags/non_ascii_type/parser.rb +59 -0
- data/lib/yard/lint/validators/tags/non_ascii_type/result.rb +25 -0
- data/lib/yard/lint/validators/tags/non_ascii_type/validator.rb +50 -0
- data/lib/yard/lint/validators/tags/non_ascii_type.rb +39 -0
- data/lib/yard/lint/validators/tags/option_tags/result.rb +2 -2
- data/lib/yard/lint/validators/tags/option_tags/validator.rb +25 -40
- data/lib/yard/lint/validators/tags/option_tags.rb +0 -1
- data/lib/yard/lint/validators/tags/order/validator.rb +28 -55
- data/lib/yard/lint/validators/tags/order.rb +0 -1
- data/lib/yard/lint/validators/tags/redundant_param_description/config.rb +15 -1
- data/lib/yard/lint/validators/tags/redundant_param_description/messages_builder.rb +5 -0
- data/lib/yard/lint/validators/tags/redundant_param_description/validator.rb +134 -100
- data/lib/yard/lint/validators/tags/redundant_param_description.rb +0 -1
- data/lib/yard/lint/validators/tags/tag_group_separator/config.rb +29 -0
- data/lib/yard/lint/validators/tags/tag_group_separator/messages_builder.rb +49 -0
- data/lib/yard/lint/validators/tags/tag_group_separator/parser.rb +67 -0
- data/lib/yard/lint/validators/tags/tag_group_separator/result.rb +28 -0
- data/lib/yard/lint/validators/tags/tag_group_separator/validator.rb +117 -0
- data/lib/yard/lint/validators/tags/tag_group_separator.rb +49 -0
- data/lib/yard/lint/validators/tags/tag_type_position/parser.rb +1 -1
- data/lib/yard/lint/validators/tags/tag_type_position/validator.rb +53 -84
- data/lib/yard/lint/validators/tags/tag_type_position.rb +4 -5
- data/lib/yard/lint/validators/tags/type_syntax/parser.rb +8 -3
- data/lib/yard/lint/validators/tags/type_syntax/validator.rb +29 -59
- data/lib/yard/lint/validators/tags/type_syntax.rb +0 -1
- data/lib/yard/lint/validators/warnings/duplicated_parameter_name/validator.rb +1 -18
- data/lib/yard/lint/validators/warnings/invalid_directive_format/validator.rb +1 -18
- data/lib/yard/lint/validators/warnings/invalid_tag_format/validator.rb +1 -18
- data/lib/yard/lint/validators/warnings/unknown_directive/validator.rb +1 -18
- data/lib/yard/lint/validators/warnings/unknown_parameter_name/messages_builder.rb +243 -0
- data/lib/yard/lint/validators/warnings/unknown_parameter_name/result.rb +4 -3
- data/lib/yard/lint/validators/warnings/unknown_parameter_name/validator.rb +1 -18
- data/lib/yard/lint/validators/warnings/unknown_tag/messages_builder.rb +144 -0
- data/lib/yard/lint/validators/warnings/unknown_tag/result.rb +4 -3
- data/lib/yard/lint/validators/warnings/unknown_tag/validator.rb +1 -18
- data/lib/yard/lint/validators/warnings/unknown_tag.rb +10 -0
- data/lib/yard/lint/version.rb +1 -1
- data/lib/yard/lint.rb +81 -13
- data/renovate.json +1 -8
- metadata +40 -6
- data/bin/console +0 -11
- data/bin/setup +0 -8
- data/lib/yard/lint/command_cache.rb +0 -93
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eb5e9ce0ee619596a8e5d35f7d46a9494ac6e0682215ad0f0bf48a3a87ee8f04
|
|
4
|
+
data.tar.gz: 5eff9bd848c484de1c752d60577f9d3ce2910a8d4f61825b02d1552a9209c598
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1e435ab938578b0c84ce189def96cfe2c0ab3e0d5881ab3a7d8e1c89b4e082fa21b0388175685ccce08df1a95bcacca8d5c61a703f0aaf81f9950b6bd95119a8
|
|
7
|
+
data.tar.gz: 1de8b9658868b6bda3504151486ffa25fc86ee379d3fd41e19b05b5bf93024bd6f244bfaf79e97d45b08e4a3862db890dda9a4f8d8d9576e616021c945a43bf9
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,178 @@
|
|
|
1
1
|
# YARD-Lint Changelog
|
|
2
2
|
|
|
3
|
+
## 1.3.0 (Unreleased)
|
|
4
|
+
- **[Fix]** Expand `Tags/Order` default `EnforcedOrder` to include all standard YARD tags
|
|
5
|
+
- Previous config only included: `param`, `option`, `return`, `raise`, `example`
|
|
6
|
+
- Now includes full order: `param`, `option`, `yield`, `yieldparam`, `yieldreturn`, `return`, `raise`, `see`, `example`, `note`, `todo`
|
|
7
|
+
- Tags not in the list were silently ignored, so `@note`, `@todo`, `@see`, and `@yield*` ordering was not validated
|
|
8
|
+
- Updated both `default_config.yml` and `strict_config.yml`
|
|
9
|
+
- **[Enhancement]** Add `IMPORTANT:` pattern detection to `Tags/InformalNotation` validator
|
|
10
|
+
- Detects `IMPORTANT:` and `Important:` informal notation and suggests using `@note` tag
|
|
11
|
+
- YARD does not have a dedicated `@important` tag; `@note` is the standard tag for emphasized notes
|
|
12
|
+
- **[Feature]** Add `Tags/TagGroupSeparator` validator to enforce blank line separators between different YARD tag groups (#29)
|
|
13
|
+
- Enforces visual separation between semantically different tag groups (e.g., `@param` tags should be separated from `@return` tags by a blank line)
|
|
14
|
+
- Configurable tag groups: param (param, option), return (return), error (raise, throws), example (example), meta (see, note, todo, deprecated, since, version, api), yield (yield, yieldparam, yieldreturn)
|
|
15
|
+
- Optional `RequireAfterDescription` setting to require blank line between description and first tag
|
|
16
|
+
- Unknown tags are treated as their own group (require separator from known groups)
|
|
17
|
+
- Disabled by default (opt-in validator) with 'convention' severity
|
|
18
|
+
- **[Feature]** Add `Tags/InformalNotation` validator to detect informal notation patterns in documentation (#33)
|
|
19
|
+
- Detects patterns like `Note:`, `TODO:`, `See:`, `Warning:`, `Deprecated:` and suggests proper YARD tags
|
|
20
|
+
- Suggests appropriate replacements: `@note`, `@todo`, `@see`, `@deprecated`, `@author`, `@version`, etc.
|
|
21
|
+
- Skips patterns inside fenced code blocks to avoid false positives
|
|
22
|
+
- Case-insensitive matching by default (configurable via `CaseSensitive`)
|
|
23
|
+
- Start-of-line matching by default (configurable via `RequireStartOfLine`)
|
|
24
|
+
- Fully configurable pattern mappings via `Patterns` option
|
|
25
|
+
- Enabled by default with 'warning' severity
|
|
26
|
+
- **[Feature]** Add `Tags/NonAsciiType` validator to detect non-ASCII characters in YARD type specifications (#39)
|
|
27
|
+
- Ruby type names must be valid Ruby identifiers (ASCII only)
|
|
28
|
+
- Detects characters like `…` (U+2026), `→` (U+2192), `—` (U+2014) in type specs
|
|
29
|
+
- Common cause: copy-paste from word processors with smart typography
|
|
30
|
+
- Reports specific character and Unicode code point in error message
|
|
31
|
+
- Example: `@param flags [Symbol, …]` → reports `'…' (U+2026)`
|
|
32
|
+
- Enabled by default with 'warning' severity
|
|
33
|
+
- Configurable `ValidatedTags` (default: param, option, return, yieldreturn, yieldparam)
|
|
34
|
+
- **[Fix]** Fix `Encoding::CompatibilityError` crash when YARD encounters non-ASCII characters in type specifications
|
|
35
|
+
- TypeSyntax validator now handles encoding issues gracefully
|
|
36
|
+
- Sanitizes YARD error messages that may contain invalid UTF-8 sequences
|
|
37
|
+
- **[Fix]** Fix relative exclusion patterns not matching files discovered with absolute paths
|
|
38
|
+
- Patterns like `vendor/**/*` were not being applied when running `yard-lint /path/to/project` or `yard-lint .`
|
|
39
|
+
- Root cause: `expand_path` converted files to absolute paths before filtering, but compared against relative patterns
|
|
40
|
+
- Now matches patterns against both relative and absolute paths (similar to RuboCop's `PathUtil#match_path?`)
|
|
41
|
+
- Extracted `discover_ruby_files` method for better separation of concerns
|
|
42
|
+
- Added `determine_base_dir`, `excluded_file?`, `relative_path_from`, and `match_path?` helper methods
|
|
43
|
+
- Comprehensive integration tests in `spec/integrations/global_exclusions_spec.rb`
|
|
44
|
+
- **[Enhancement]** Make PATH argument optional, defaulting to current directory (like RuboCop)
|
|
45
|
+
- Running `yard-lint` without arguments now lints the current directory
|
|
46
|
+
- Maintains backward compatibility with explicit path arguments
|
|
47
|
+
- Updated help text and examples to show default behavior
|
|
48
|
+
- **[Fix]** Respect per-validator `YardOptions` when filtering by visibility (#41)
|
|
49
|
+
- Executor was ignoring `YardOptions` defined on individual validators
|
|
50
|
+
- Specifying `YardOptions` on a specific validator now correctly overrides `AllValidators` defaults
|
|
51
|
+
- Enables use cases like validating tag order on private methods, but skipping documentation requirement
|
|
52
|
+
- Example: Set `--private` in `AllValidators.YardOptions`, then override with empty `YardOptions: []` on `Documentation/UndocumentedObjects` to skip private methods or constants
|
|
53
|
+
- **[Feature]** Add in-process YARD execution for ~10x faster performance
|
|
54
|
+
- Parses files once and shares the YARD registry across all validators
|
|
55
|
+
- Eliminates subprocess spawning overhead (previously spawned 17+ processes per run)
|
|
56
|
+
- Maintains identical detection results and output format
|
|
57
|
+
- All 17 validators migrated to in-process execution
|
|
58
|
+
- Warning validators (UnknownTag, UnknownParameterName, etc.) capture YARD warnings during parsing
|
|
59
|
+
- Respects `--private`/`--protected` YardOptions for visibility filtering
|
|
60
|
+
- Fixed `void` typo in allowed types (was `vold`)
|
|
61
|
+
- Properly handles symbol types (`:all`, `:public`) in type validation
|
|
62
|
+
- **[Change]** Remove shell mode execution (was deprecated fallback)
|
|
63
|
+
- In-process execution is now the only mode
|
|
64
|
+
- Shell mode fallback code and `YARD_LINT_SHELL_MODE` environment variable removed
|
|
65
|
+
- Simplifies codebase by removing ~1000 lines of shell-related code
|
|
66
|
+
- **[Feature]** Add `Documentation/EmptyCommentLine` validator to detect unnecessary empty comment lines in YARD documentation blocks
|
|
67
|
+
- Detects empty `#` lines at the start of documentation blocks (leading)
|
|
68
|
+
- Detects empty `#` lines at the end of documentation blocks (trailing)
|
|
69
|
+
- Correctly allows empty lines between sections (e.g., between description and @param tags)
|
|
70
|
+
- Configurable `EnabledPatterns` to check leading, trailing, or both
|
|
71
|
+
- Reads source files directly to detect comment block boundaries
|
|
72
|
+
- Enabled by default with 'convention' severity
|
|
73
|
+
- Comprehensive test coverage with 45 unit and integration tests
|
|
74
|
+
- **[Feature]** Add "did you mean" suggestions for UnknownParameterName validator
|
|
75
|
+
- Suggests correct parameter names when documentation mismatches are detected
|
|
76
|
+
- Uses Ruby's `did_you_mean` gem as primary suggestion engine
|
|
77
|
+
- Falls back to Levenshtein distance algorithm when DidYouMean doesn't find matches
|
|
78
|
+
- Parses Ruby source files directly to extract actual method parameters
|
|
79
|
+
- Handles all parameter types: regular, keyword, splat, block, with defaults
|
|
80
|
+
- Example: `@param user_nme [String] typo` → suggests "did you mean 'user_name'?"
|
|
81
|
+
- Only suggests when parameter names are similar enough (distance threshold)
|
|
82
|
+
- Comprehensive test coverage with 19 unit tests and 12 integration tests
|
|
83
|
+
- Inspired by yard-junk's helpful error messages
|
|
84
|
+
- **[Feature]** Add "did you mean" suggestions for UnknownTag validator
|
|
85
|
+
- Suggests correct YARD tag names when typos are detected
|
|
86
|
+
- Dynamically loads valid tags and directives from YARD::Tags::Library for automatic compatibility with any YARD version
|
|
87
|
+
- Checks against all 22 standard YARD meta-data tags and 8 directives (in YARD 0.9.x)
|
|
88
|
+
- Uses Ruby's `did_you_mean` gem as primary suggestion engine
|
|
89
|
+
- Falls back to Levenshtein distance algorithm when DidYouMean doesn't find matches
|
|
90
|
+
- Example: `@returns [String]` → suggests "did you mean '@return'?"
|
|
91
|
+
- Example: `@raises [Error]` → suggests "did you mean '@raise'?"
|
|
92
|
+
- Example: `@params value` → suggests "did you mean '@param'?"
|
|
93
|
+
- Only suggests when tag names are similar enough (within 50% edit distance)
|
|
94
|
+
- Comprehensive test coverage with 35 unit tests and 12 integration tests covering common typos
|
|
95
|
+
- Completes the "did you mean" feature set alongside UnknownParameterName validator
|
|
96
|
+
- Inspired by yard-junk's helpful suggestion system
|
|
97
|
+
- **[Fix]** Replace hard-coded `#!/bin/bash` with `#!/bin/sh` for BSD/macOS compatibility (#34)
|
|
98
|
+
- Scripts now use POSIX-compliant shell instead of Bash
|
|
99
|
+
- Fixes `Errno::ENOENT` errors on *BSD systems where `/bin/bash` doesn't exist
|
|
100
|
+
- Affects all validators that use temporary shell scripts: InvalidTypes, RedundantParamDescription, EmptyCommentLine, TypeSyntax, CollectionType, MeaninglessTag, TagTypePosition
|
|
101
|
+
- **[Fix]** Fix Runner bug where offense messages were lost during per-validator exclusion filtering
|
|
102
|
+
- `filter_result_offenses` was creating new Result objects with stripped offense data
|
|
103
|
+
- Enhanced messages (like "did you mean" suggestions) were being discarded
|
|
104
|
+
- Now modifies existing Result object's offenses array to preserve all data
|
|
105
|
+
- Fixes issue affecting all validators with custom message builders
|
|
106
|
+
- **[Change]** Update `.yard-lint.yml` to set `FailOnSeverity` to `convention` level
|
|
107
|
+
- Previously set to `error`, now fails on any severity including convention
|
|
108
|
+
- Ensures stricter enforcement of documentation style conventions
|
|
109
|
+
- **[CI]** Add macOS testing to CI workflow
|
|
110
|
+
- Tests Ruby 3.4 on macOS to validate BSD/POSIX compatibility
|
|
111
|
+
- **[CI]** Add parallel_tests gem to run specs in parallel for faster CI execution
|
|
112
|
+
- **[Feature]** Add `ArticleParamPhrase` pattern to `Tags/RedundantParamDescription` validator (#32)
|
|
113
|
+
- Detects filler phrases like "The action being performed" or "A callback to invoke"
|
|
114
|
+
- Matches pattern: `<Article> <param_name> <connector> [<low_value_verb>...]`
|
|
115
|
+
- Configurable `LowValueConnectors` list (default: being, to, that, which, for)
|
|
116
|
+
- Configurable `LowValueVerbs` list (default: perform, process, use, handle, act, pass, invoke, call, execute, run)
|
|
117
|
+
- Enabled by default via `EnabledPatterns.ArticleParamPhrase`
|
|
118
|
+
- Pattern-specific error message explaining the filler phrase adds no value
|
|
119
|
+
- Comprehensive test coverage with fixtures and integration tests
|
|
120
|
+
- **[Feature]** Add `--only` CLI option to run specific validators
|
|
121
|
+
- Run single validator: `yard-lint --only Tags/TypeSyntax`
|
|
122
|
+
- Run multiple validators: `yard-lint --only Tags/Order,Tags/TypeSyntax`
|
|
123
|
+
- Overrides `Enabled: false` in config for specified validators
|
|
124
|
+
- Provides "did you mean" suggestions for typos using Ruby's `did_you_mean` gem
|
|
125
|
+
- Lists all available validators when unknown validator is specified
|
|
126
|
+
- Requires exact validator names (case-sensitive, full path like `Tags/Order`)
|
|
127
|
+
- **[Feature]** Add `Documentation/BlankLineBeforeDefinition` validator to detect blank lines between YARD documentation and definitions (#30)
|
|
128
|
+
- Detects single blank line violations where YARD still associates docs but violates conventions
|
|
129
|
+
- Detects orphaned documentation (2+ blank lines) where YARD completely ignores the documentation
|
|
130
|
+
- Works with methods, classes, and modules
|
|
131
|
+
- Configurable `EnabledPatterns` to check only single blank lines, only orphaned docs, or both
|
|
132
|
+
- Separate `Severity` and `OrphanedSeverity` configuration options for different violation types
|
|
133
|
+
- Respects `--private` and `--protected` YardOptions for visibility filtering
|
|
134
|
+
- Enabled by default with 'convention' severity for both violation types
|
|
135
|
+
- **[Fix]** Fix yard-lint silently returning "No offenses found" for non-existent file paths
|
|
136
|
+
- Previously, specifying a non-existent path would silently succeed with empty results
|
|
137
|
+
- Now raises `Errors::FileNotFoundError` with clear message: "No such file or directory: /path"
|
|
138
|
+
- Matches behavior of similar tools like RuboCop
|
|
139
|
+
- Only validates explicit file paths (glob patterns and directories are not affected)
|
|
140
|
+
- **[Feature]** Add `--update` command to update existing `.yard-lint.yml` with new validators
|
|
141
|
+
- Adds new validators introduced in newer yard-lint versions with their template defaults
|
|
142
|
+
- Removes obsolete validators that no longer exist in yard-lint
|
|
143
|
+
- Preserves all existing user configuration (custom severities, exclusions, etc.)
|
|
144
|
+
- Reports added, removed, and preserved validator counts
|
|
145
|
+
- Supports `--strict` flag to use strict template defaults for new validators
|
|
146
|
+
- Example: `yard-lint --update` or `yard-lint --update --strict`
|
|
147
|
+
- **[Fix]** Fix integration specs failing in parallel test runs due to relative fixture paths
|
|
148
|
+
- Updated `MeaninglessTag`, `EmptyCommentLine`, `MultiValidatorComprehensive`, `InformalNotation`, `BlankLineBeforeDefinition`, `MagicComments`, `CollectionType`, `TagTypePosition` specs to use absolute paths
|
|
149
|
+
- Updated `ValidatorCoverage` spec to use absolute paths for config and template files
|
|
150
|
+
- Uses `File.expand_path` with `__dir__` for reliable path resolution regardless of working directory
|
|
151
|
+
|
|
152
|
+
## 1.2.3 (2025-11-13)
|
|
153
|
+
- **[Feature]** Add per-validator exclusion support for fine-grained file filtering
|
|
154
|
+
- Individual validators can now specify `Exclude` patterns in `.yard-lint.yml`
|
|
155
|
+
- Exclusions work alongside global `AllValidators.Exclude` patterns
|
|
156
|
+
- Both global and per-validator exclusions are applied (union of both pattern sets)
|
|
157
|
+
- Enables excluding intentionally invalid documentation examples from specific validators
|
|
158
|
+
- Default config excludes validator implementation files and spec fixtures from `Tags/ExampleSyntax`
|
|
159
|
+
- Pattern matching works with glob patterns (`**/*.rb`, `**/validators/**/parser.rb`)
|
|
160
|
+
- Filters validator results based on file location, not just input file selection
|
|
161
|
+
- Handles both absolute and relative paths correctly in pattern matching
|
|
162
|
+
- Comprehensive integration test coverage for exclusion scenarios
|
|
163
|
+
- Example: Exclude parser.rb files with intentionally broken @example tags from syntax validation
|
|
164
|
+
- **[Change]** Update `.yard-lint.yml` to set all validator severities to `error` level
|
|
165
|
+
- Changes `FailOnSeverity` from `warning` to `error` for stricter enforcement
|
|
166
|
+
- All validators now use `error` severity instead of `warning` or `convention`
|
|
167
|
+
- Ensures any documentation issue triggers exit code 1 for CI/CD pipelines
|
|
168
|
+
- Provides consistent behavior across all validation rules
|
|
169
|
+
- **[Fix]** Fix integration tests failing due to fixture files being filtered by global exclusions
|
|
170
|
+
- Added `test_config` helper in spec_helper.rb that clears default exclusions for tests
|
|
171
|
+
- Updated all integration test files to use `test_config` instead of `Yard::Lint::Config.new`
|
|
172
|
+
- Prevents test fixtures in `spec/fixtures/` from being filtered out by `spec/**/*` exclusion pattern
|
|
173
|
+
- Ensures integration tests can properly validate linter behavior on fixture files
|
|
174
|
+
- **[Fix]** Remove not needed `bin/` files.
|
|
175
|
+
|
|
3
176
|
## 1.2.2 (2025-11-13)
|
|
4
177
|
- **[Fix]** Fix `--version` flag failing with `uninitialized constant Yard::Lint::VERSION` error
|
|
5
178
|
- Zeitwerk expected `Version` (camel case) but file defined `VERSION` (all caps)
|
|
@@ -121,7 +294,7 @@
|
|
|
121
294
|
- [Change] YARD database directories are now created under a base temp directory with unique subdirectories per argument set.
|
|
122
295
|
|
|
123
296
|
## 0.2.1 (2025-11-07)
|
|
124
|
-
- Release to validate Trusted Publishing flow.
|
|
297
|
+
- Release to validate Trusted Publishing flow.
|
|
125
298
|
|
|
126
299
|
## 0.2.0 (2025-11-07)
|
|
127
300
|
|
data/README.md
CHANGED
|
@@ -9,7 +9,7 @@ A comprehensive linter for YARD documentation that helps you maintain clean, con
|
|
|
9
9
|
|
|
10
10
|
## Why Documentation Quality Matters More Than Ever
|
|
11
11
|
|
|
12
|
-
Accurate documentation isn't just for human developers anymore. [Research shows](https://arxiv.org/html/2404.03114) that incorrect documentation reduces AI assistant success rates up to 50% (from 44.7% to 22.1%).
|
|
12
|
+
Accurate documentation isn't just for human developers anymore. [Research shows](https://arxiv.org/html/2404.03114) that incorrect documentation reduces AI assistant success rates up to 50% (from 44.7% to 22.1%).
|
|
13
13
|
|
|
14
14
|
**The problem:** Documentation drifts as code changes-parameters get renamed, return types change, but docs stay stale. This doesn't just confuse developers; it trains AI coding assistants to generate confidently wrong code.
|
|
15
15
|
|
|
@@ -23,6 +23,7 @@ YARD-Lint validates your YARD documentation for:
|
|
|
23
23
|
- **Missing parameter documentation**: Methods with undocumented parameters
|
|
24
24
|
- **Invalid tag types**: Type definitions that aren't valid Ruby classes or allowed defaults
|
|
25
25
|
- **Invalid type syntax**: Malformed YARD type syntax (unclosed brackets, empty generics, etc.)
|
|
26
|
+
- **Non-ASCII type characters**: Detects Unicode characters in type specifications (e.g., `…`, `→`, `—`) that are invalid Ruby identifiers
|
|
26
27
|
- **Invalid tag ordering**: Tags that don't follow your specified order
|
|
27
28
|
- **Meaningless tags**: `@param` or `@option` tags on classes, modules, or constants (only valid on methods)
|
|
28
29
|
- **Collection type syntax**: Enforces `Hash{K => V}` over `Hash<K, V>` (YARD standard)
|
|
@@ -33,7 +34,12 @@ YARD-Lint validates your YARD documentation for:
|
|
|
33
34
|
- **Option hash documentation**: Validate that methods with options parameters have @option tags
|
|
34
35
|
- **Example code syntax validation**: Validates Ruby syntax in `@example` tags to catch broken code examples
|
|
35
36
|
- **Redundant parameter descriptions**: Detects meaningless parameter descriptions that add no value (e.g., `@param user [User] The user`)
|
|
37
|
+
- **Empty comment lines**: Detects unnecessary empty `#` lines at the start or end of documentation blocks
|
|
38
|
+
- **Blank lines before definitions**: Detects blank lines between YARD documentation and method/class/module definitions (single blank line = convention violation, 2+ blank lines = orphaned documentation that YARD ignores)
|
|
39
|
+
- **Informal notation patterns**: Detects `Note:`, `TODO:`, `See:` etc. and suggests proper YARD tags (`@note`, `@todo`, `@see`)
|
|
40
|
+
- **Tag group separation**: Enforces blank lines between different YARD tag groups (e.g., between `@param` and `@return` tags) for improved readability
|
|
36
41
|
- **YARD warnings**: Unknown tags, invalid directives, duplicated parameter names, and more
|
|
42
|
+
- **Smart suggestions**: Provides "did you mean" suggestions for typos in parameter names using Ruby's `did_you_mean` gem with Levenshtein distance fallback
|
|
37
43
|
|
|
38
44
|
## Installation
|
|
39
45
|
|
|
@@ -67,6 +73,28 @@ yard-lint --init
|
|
|
67
73
|
|
|
68
74
|
This creates `.yard-lint.yml` with sensible defaults in your current directory.
|
|
69
75
|
|
|
76
|
+
For new projects with high documentation standards, use strict mode:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
yard-lint --init --strict
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
This creates a strict configuration with:
|
|
83
|
+
- All validators set to `error` severity (no warnings or conventions)
|
|
84
|
+
- Minimum documentation coverage set to 100%
|
|
85
|
+
- Perfect for bootstrapping new repositories with high quality standards
|
|
86
|
+
|
|
87
|
+
After upgrading yard-lint, update your config to include any new validators:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
yard-lint --update
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
This will:
|
|
94
|
+
- Add any new validators introduced in the latest version (with their default settings)
|
|
95
|
+
- Remove any obsolete validators that no longer exist
|
|
96
|
+
- Preserve all your existing configuration
|
|
97
|
+
|
|
70
98
|
### Command Line
|
|
71
99
|
|
|
72
100
|
Basic usage:
|
|
@@ -87,6 +115,9 @@ yard-lint lib/ --format json > report.json
|
|
|
87
115
|
# Generate config file (use --force to overwrite existing)
|
|
88
116
|
yard-lint --init
|
|
89
117
|
yard-lint --init --force
|
|
118
|
+
|
|
119
|
+
# Generate strict config (all errors, 100% coverage)
|
|
120
|
+
yard-lint --init --strict
|
|
90
121
|
```
|
|
91
122
|
|
|
92
123
|
### Diff Mode (Incremental Linting)
|
|
@@ -197,6 +228,21 @@ jobs:
|
|
|
197
228
|
- Works with diff mode to enforce coverage only on changed files
|
|
198
229
|
- Performance optimized with auto-cleanup temp directories for large codebases
|
|
199
230
|
|
|
231
|
+
### Running Specific Validators
|
|
232
|
+
|
|
233
|
+
Run only specific validators using the `--only` option - useful for debugging, gradual adoption, or focused CI checks:
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
# Run only one validator
|
|
237
|
+
yard-lint --only Tags/TypeSyntax lib/
|
|
238
|
+
|
|
239
|
+
# Run multiple validators (comma-separated)
|
|
240
|
+
yard-lint --only Tags/Order,Tags/TypeSyntax lib/
|
|
241
|
+
|
|
242
|
+
# Combine with other options
|
|
243
|
+
yard-lint --only Documentation/UndocumentedObjects --diff main lib/
|
|
244
|
+
```
|
|
245
|
+
|
|
200
246
|
## Configuration
|
|
201
247
|
|
|
202
248
|
YARD-Lint is configured via a `.yard-lint.yml` configuration file (similar to `.rubocop.yml`).
|
|
@@ -493,10 +539,13 @@ Supported glob patterns:
|
|
|
493
539
|
| `Documentation/UndocumentedBooleanMethods` | Checks that question mark methods document their boolean return | Enabled (warning) | `Enabled`, `Severity`, `Exclude` |
|
|
494
540
|
| `Documentation/UndocumentedOptions` | Detects methods with options hash/kwargs parameters but no `@option` tags | Enabled (warning) | `Enabled`, `Severity`, `Exclude` |
|
|
495
541
|
| `Documentation/MarkdownSyntax` | Detects common markdown syntax errors in documentation (unclosed backticks, invalid list markers, etc.) | Enabled (warning) | `Enabled`, `Severity`, `Exclude` |
|
|
542
|
+
| `Documentation/EmptyCommentLine` | Detects empty `#` lines at the start or end of documentation blocks | Enabled (convention) | `Enabled`, `Severity`, `Exclude`, `EnabledPatterns` |
|
|
543
|
+
| `Documentation/BlankLineBeforeDefinition` | Detects blank lines between documentation and definitions (single blank = convention violation, 2+ blank = orphaned docs) | Enabled (convention) | `Enabled`, `Severity`, `OrphanedSeverity`, `Exclude`, `EnabledPatterns` |
|
|
496
544
|
| **Tags Validators** |
|
|
497
545
|
| `Tags/Order` | Enforces consistent ordering of YARD tags | Enabled (convention) | `Enabled`, `Severity`, `Exclude`, `EnforcedOrder` |
|
|
498
546
|
| `Tags/InvalidTypes` | Validates type definitions in `@param`, `@return`, `@option` tags | Enabled (warning) | `Enabled`, `Severity`, `Exclude`, `ValidatedTags`, `ExtraTypes` |
|
|
499
547
|
| `Tags/TypeSyntax` | Validates YARD type syntax (detects unclosed brackets, empty generics, etc.) | Enabled (warning) | `Enabled`, `Severity`, `Exclude`, `ValidatedTags` |
|
|
548
|
+
| `Tags/NonAsciiType` | Detects non-ASCII characters in type specifications (e.g., `…`, `→`, `—`) | Enabled (warning) | `Enabled`, `Severity`, `Exclude`, `ValidatedTags` |
|
|
500
549
|
| `Tags/MeaninglessTag` | Detects `@param`/`@option` tags on classes, modules, or constants (only valid on methods) | Enabled (warning) | `Enabled`, `Severity`, `Exclude`, `CheckedTags`, `InvalidObjectTypes` |
|
|
501
550
|
| `Tags/CollectionType` | Enforces `Hash{K => V}` over `Hash<K, V>` (YARD standard collection syntax) | Enabled (convention) | `Enabled`, `Severity`, `Exclude`, `ValidatedTags` |
|
|
502
551
|
| `Tags/TagTypePosition` | Validates type annotation position (`@param name [Type]` vs `@param [Type] name`) | Enabled (convention) | `Enabled`, `Severity`, `Exclude`, `CheckedTags`, `EnforcedStyle` |
|
|
@@ -504,13 +553,15 @@ Supported glob patterns:
|
|
|
504
553
|
| `Tags/OptionTags` | Requires `@option` tags for methods with options parameters | Enabled (warning) | `Enabled`, `Severity`, `Exclude` |
|
|
505
554
|
| `Tags/ExampleSyntax` | Validates Ruby syntax in `@example` tags to catch broken code examples | Enabled (warning) | `Enabled`, `Severity`, `Exclude` |
|
|
506
555
|
| `Tags/RedundantParamDescription` | Detects meaningless parameter descriptions that add no value beyond the parameter name | Enabled (convention) | `Enabled`, `Severity`, `Exclude`, `CheckedTags`, `Articles`, `MaxRedundantWords`, `MinMeaningfulLength`, `GenericTerms`, `EnabledPatterns` |
|
|
556
|
+
| `Tags/InformalNotation` | Detects informal notation patterns (`Note:`, `TODO:`, etc.) and suggests proper YARD tags | Enabled (warning) | `Enabled`, `Severity`, `Exclude`, `CaseSensitive`, `RequireStartOfLine`, `Patterns` |
|
|
557
|
+
| `Tags/TagGroupSeparator` | Enforces blank line separators between different YARD tag groups (e.g., between `@param` and `@return` tags) | Disabled (opt-in) | `Enabled`, `Severity`, `Exclude`, `TagGroups`, `RequireAfterDescription` |
|
|
507
558
|
| **Warnings Validators** |
|
|
508
|
-
| `Warnings/UnknownTag` | Detects unknown YARD tags | Enabled (error) | `Enabled`, `Severity`, `Exclude` |
|
|
559
|
+
| `Warnings/UnknownTag` | Detects unknown YARD tags with "did you mean" suggestions | Enabled (error) | `Enabled`, `Severity`, `Exclude` |
|
|
509
560
|
| `Warnings/UnknownDirective` | Detects unknown YARD directives | Enabled (error) | `Enabled`, `Severity`, `Exclude` |
|
|
510
561
|
| `Warnings/InvalidTagFormat` | Detects malformed tag syntax | Enabled (error) | `Enabled`, `Severity`, `Exclude` |
|
|
511
562
|
| `Warnings/InvalidDirectiveFormat` | Detects malformed directive syntax | Enabled (error) | `Enabled`, `Severity`, `Exclude` |
|
|
512
563
|
| `Warnings/DuplicatedParameterName` | Detects duplicate `@param` tags | Enabled (error) | `Enabled`, `Severity`, `Exclude` |
|
|
513
|
-
| `Warnings/UnknownParameterName` | Detects `@param` tags for non-existent parameters | Enabled (error) | `Enabled`, `Severity`, `Exclude` |
|
|
564
|
+
| `Warnings/UnknownParameterName` | Detects `@param` tags for non-existent parameters with "did you mean" suggestions | Enabled (error) | `Enabled`, `Severity`, `Exclude` |
|
|
514
565
|
| **Semantic Validators** |
|
|
515
566
|
| `Semantic/AbstractMethods` | Ensures `@abstract` methods don't have real implementations | Enabled (warning) | `Enabled`, `Severity`, `Exclude` |
|
|
516
567
|
|
|
@@ -528,6 +579,61 @@ yard server
|
|
|
528
579
|
|
|
529
580
|
Then open http://localhost:8808 in your browser to browse the full validator documentation with examples.
|
|
530
581
|
|
|
582
|
+
### Smart Suggestions with "Did You Mean"
|
|
583
|
+
|
|
584
|
+
YARD-Lint provides intelligent suggestions for common typos in both tag names and parameter names.
|
|
585
|
+
|
|
586
|
+
#### Unknown Tag Suggestions
|
|
587
|
+
|
|
588
|
+
The `Warnings/UnknownTag` validator suggests correct YARD tags for typos:
|
|
589
|
+
|
|
590
|
+
**Example:**
|
|
591
|
+
|
|
592
|
+
```ruby
|
|
593
|
+
# @params value [String] should be @param
|
|
594
|
+
# @returns [String] should be @return
|
|
595
|
+
# @raises [Error] should be @raise
|
|
596
|
+
def process(value)
|
|
597
|
+
# ...
|
|
598
|
+
end
|
|
599
|
+
```
|
|
600
|
+
|
|
601
|
+
**Output:**
|
|
602
|
+
|
|
603
|
+
```
|
|
604
|
+
lib/processor.rb:10: [error] Unknown tag @params (did you mean '@param'?)
|
|
605
|
+
lib/processor.rb:11: [error] Unknown tag @returns (did you mean '@return'?)
|
|
606
|
+
lib/processor.rb:12: [error] Unknown tag @raises (did you mean '@raise'?)
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
#### Unknown Parameter Suggestions
|
|
610
|
+
|
|
611
|
+
The `Warnings/UnknownParameterName` validator suggests correct parameter names:
|
|
612
|
+
|
|
613
|
+
**Example:**
|
|
614
|
+
|
|
615
|
+
```ruby
|
|
616
|
+
# @param usr_name [String] the username
|
|
617
|
+
# @param usr_email [String] the email
|
|
618
|
+
def create_user(user_name, user_email)
|
|
619
|
+
# ...
|
|
620
|
+
end
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
**Output:**
|
|
624
|
+
|
|
625
|
+
```
|
|
626
|
+
lib/user.rb:123: [error] @param tag has unknown parameter name: usr_name (did you mean 'user_name'?)
|
|
627
|
+
lib/user.rb:124: [error] @param tag has unknown parameter name: usr_email (did you mean 'user_email'?)
|
|
628
|
+
```
|
|
629
|
+
|
|
630
|
+
**How it works:**
|
|
631
|
+
- Uses Ruby's `did_you_mean` gem for intelligent suggestions
|
|
632
|
+
- Falls back to Levenshtein distance algorithm when needed
|
|
633
|
+
- For parameters: Parses method signatures directly from source files for accurate parameter detection
|
|
634
|
+
- Supports all parameter types: regular, keyword, splat, block, and default values
|
|
635
|
+
- For tags: Checks against all standard YARD tags and directives
|
|
636
|
+
|
|
531
637
|
### Quick Configuration Examples
|
|
532
638
|
|
|
533
639
|
```yaml
|
|
@@ -589,7 +695,16 @@ Options:
|
|
|
589
695
|
-f, --format FORMAT Output format (text, json)
|
|
590
696
|
-q, --quiet Quiet mode (only show summary)
|
|
591
697
|
--stats Show statistics summary
|
|
698
|
+
--min-coverage N Minimum documentation coverage required (0-100)
|
|
592
699
|
--[no-]progress Show progress indicator (default: auto-detect TTY)
|
|
700
|
+
--diff [REF] Lint only files changed since REF
|
|
701
|
+
--staged Lint only staged files
|
|
702
|
+
--changed Lint only uncommitted files
|
|
703
|
+
--only VALIDATORS Run only specified validators (comma-separated)
|
|
704
|
+
--init Generate .yard-lint.yml config file
|
|
705
|
+
--update Update .yard-lint.yml with new validators
|
|
706
|
+
--strict Generate strict config (use with --init or --update)
|
|
707
|
+
--force Force overwrite when using --init
|
|
593
708
|
-v, --version Show version
|
|
594
709
|
-h, --help Show this help
|
|
595
710
|
```
|
data/Rakefile
CHANGED
|
@@ -2,3 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
require 'bundler/setup'
|
|
4
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/bin/yard-lint
CHANGED
|
@@ -11,7 +11,7 @@ config_file = nil
|
|
|
11
11
|
diff_mode = nil
|
|
12
12
|
|
|
13
13
|
OptionParser.new do |opts|
|
|
14
|
-
opts.banner = 'Usage: yard-lint [options] PATH'
|
|
14
|
+
opts.banner = 'Usage: yard-lint [options] [PATH]'
|
|
15
15
|
|
|
16
16
|
opts.on('-c', '--config FILE', 'Path to config file (default: .yard-lint.yml)') do |file|
|
|
17
17
|
config_file = file
|
|
@@ -52,6 +52,13 @@ OptionParser.new do |opts|
|
|
|
52
52
|
diff_mode = { mode: :changed }
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
+
opts.separator ''
|
|
56
|
+
opts.separator 'Validator selection:'
|
|
57
|
+
|
|
58
|
+
opts.on('--only VALIDATORS', 'Run only specified validators (comma-separated)') do |validators|
|
|
59
|
+
options[:only] = validators.split(',').map(&:strip)
|
|
60
|
+
end
|
|
61
|
+
|
|
55
62
|
opts.separator ''
|
|
56
63
|
opts.separator 'Other options:'
|
|
57
64
|
|
|
@@ -59,6 +66,14 @@ OptionParser.new do |opts|
|
|
|
59
66
|
options[:init] = true
|
|
60
67
|
end
|
|
61
68
|
|
|
69
|
+
opts.on('--update', 'Update .yard-lint.yml to add new validators and remove obsolete ones') do
|
|
70
|
+
options[:update] = true
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
opts.on('--strict', 'Generate strict config (all Error severity, 100% coverage). Use with --init or --update') do
|
|
74
|
+
options[:strict] = true
|
|
75
|
+
end
|
|
76
|
+
|
|
62
77
|
opts.on('--force', 'Force overwrite when using --init') do
|
|
63
78
|
options[:force] = true
|
|
64
79
|
end
|
|
@@ -72,19 +87,29 @@ OptionParser.new do |opts|
|
|
|
72
87
|
puts opts
|
|
73
88
|
puts
|
|
74
89
|
puts 'Examples:'
|
|
75
|
-
puts ' yard-lint
|
|
76
|
-
puts ' yard-lint lib/
|
|
77
|
-
puts ' yard-lint lib/
|
|
78
|
-
puts ' yard-lint
|
|
79
|
-
puts ' yard-lint
|
|
90
|
+
puts ' yard-lint # Lint current directory'
|
|
91
|
+
puts ' yard-lint lib/ # Lint all files in lib/'
|
|
92
|
+
puts ' yard-lint --only Tags/TypeSyntax lib/ # Run only one validator on lib/'
|
|
93
|
+
puts ' yard-lint --only Tags/Order,Tags/TypeSyntax # Run specific validators'
|
|
94
|
+
puts ' yard-lint --diff main # Lint files changed since main branch'
|
|
95
|
+
puts ' yard-lint --staged # Lint only staged files'
|
|
96
|
+
puts ' yard-lint --changed # Lint only uncommitted files'
|
|
97
|
+
puts ' yard-lint --format json lib/ # Output in JSON format'
|
|
98
|
+
puts ' yard-lint --init # Generate default config'
|
|
99
|
+
puts ' yard-lint --init --strict # Generate strict config'
|
|
100
|
+
puts ' yard-lint --update # Update config with new validators'
|
|
80
101
|
exit
|
|
81
102
|
end
|
|
82
103
|
end.parse!
|
|
83
104
|
|
|
84
105
|
# Handle --init flag
|
|
85
106
|
if options[:init]
|
|
86
|
-
if Yard::Lint::ConfigGenerator.generate(force: options[:force])
|
|
87
|
-
|
|
107
|
+
if Yard::Lint::ConfigGenerator.generate(force: options[:force], strict: options[:strict])
|
|
108
|
+
if options[:strict]
|
|
109
|
+
puts 'Created .yard-lint.yml with strict configuration (all Error severity, 100% coverage)'
|
|
110
|
+
else
|
|
111
|
+
puts 'Created .yard-lint.yml with default configuration'
|
|
112
|
+
end
|
|
88
113
|
exit 0
|
|
89
114
|
else
|
|
90
115
|
puts 'Error: .yard-lint.yml already exists'
|
|
@@ -93,38 +118,35 @@ if options[:init]
|
|
|
93
118
|
end
|
|
94
119
|
end
|
|
95
120
|
|
|
96
|
-
#
|
|
97
|
-
|
|
121
|
+
# Handle --update flag
|
|
122
|
+
if options[:update]
|
|
123
|
+
begin
|
|
124
|
+
result = Yard::Lint::ConfigUpdater.update(strict: options[:strict])
|
|
98
125
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
126
|
+
if result[:added].any? || result[:removed].any?
|
|
127
|
+
puts 'Updated .yard-lint.yml:'
|
|
128
|
+
if result[:added].any?
|
|
129
|
+
puts " Added #{result[:added].size} new validator(s): #{result[:added].join(', ')}"
|
|
130
|
+
end
|
|
131
|
+
if result[:removed].any?
|
|
132
|
+
puts " Removed #{result[:removed].size} obsolete validator(s): #{result[:removed].join(', ')}"
|
|
133
|
+
end
|
|
134
|
+
puts " Preserved #{result[:preserved].size} existing validator(s)"
|
|
135
|
+
else
|
|
136
|
+
puts '.yard-lint.yml is already up to date'
|
|
137
|
+
end
|
|
138
|
+
exit 0
|
|
139
|
+
rescue Yard::Lint::Errors::ConfigFileNotFoundError => e
|
|
140
|
+
puts "Error: #{e.message}"
|
|
141
|
+
exit 1
|
|
142
|
+
end
|
|
103
143
|
end
|
|
104
144
|
|
|
105
|
-
#
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
#
|
|
109
|
-
|
|
110
|
-
# - The command cache stores results from YARD commands across validator instances
|
|
111
|
-
# - This cache is shared at the class level (Base.@shared_command_cache)
|
|
112
|
-
# - Without reset: Results from a previous CLI run could leak into the current run
|
|
113
|
-
# - Critical for CLI: Each `yard-lint` invocation should start with clean state
|
|
114
|
-
# - Not needed in-process: Within a single run, caching YARD results is beneficial
|
|
115
|
-
#
|
|
116
|
-
# 2. **YARD Database Clear** (`clear_yard_database!`)
|
|
117
|
-
# - YARD creates temp database directories for parsing documentation
|
|
118
|
-
# - Directories are isolated per-argument-set using SHA256 hash (see base.rb:84-97)
|
|
119
|
-
# - Base temp dir (YARDOC_BASE_TEMP_DIR) persists across CLI invocations
|
|
120
|
-
# - Without clear: Old databases accumulate in /tmp, wasting disk space
|
|
121
|
-
# - Database isolation prevents contamination within a single run, but doesn't
|
|
122
|
-
# clean up between runs
|
|
123
|
-
#
|
|
124
|
-
# In summary: These ensure each CLI invocation is independent and doesn't leak state
|
|
125
|
-
# from previous runs, while also preventing temp directory accumulation.
|
|
126
|
-
Yard::Lint::Validators::Base.reset_command_cache!
|
|
127
|
-
Yard::Lint::Validators::Base.clear_yard_database!
|
|
145
|
+
# Get path argument (defaults to current directory)
|
|
146
|
+
path = ARGV[0] || '.'
|
|
147
|
+
|
|
148
|
+
# Clear YARD registry to ensure fresh run on each CLI invocation
|
|
149
|
+
YARD::Registry.clear
|
|
128
150
|
|
|
129
151
|
# Load config and apply CLI overrides
|
|
130
152
|
config = if config_file
|
|
@@ -136,6 +158,24 @@ config = if config_file
|
|
|
136
158
|
# Apply CLI min_coverage override if provided
|
|
137
159
|
config.min_coverage = options[:min_coverage] if options[:min_coverage]
|
|
138
160
|
|
|
161
|
+
# Apply --only filter if provided
|
|
162
|
+
if options[:only]
|
|
163
|
+
unknown = options[:only] - Yard::Lint::ConfigLoader::ALL_VALIDATORS
|
|
164
|
+
if unknown.any?
|
|
165
|
+
checker = DidYouMean::SpellChecker.new(dictionary: Yard::Lint::ConfigLoader::ALL_VALIDATORS)
|
|
166
|
+
messages = unknown.map do |name|
|
|
167
|
+
suggestions = checker.correct(name)
|
|
168
|
+
suggestions.any? ? " #{name} (did you mean: #{suggestions.first}?)" : " #{name}"
|
|
169
|
+
end
|
|
170
|
+
puts "Error: Unknown validator(s):"
|
|
171
|
+
puts messages.join("\n")
|
|
172
|
+
puts "\nAvailable validators:"
|
|
173
|
+
Yard::Lint::ConfigLoader::ALL_VALIDATORS.each { |v| puts " #{v}" }
|
|
174
|
+
exit 1
|
|
175
|
+
end
|
|
176
|
+
config.only_validators = options[:only]
|
|
177
|
+
end
|
|
178
|
+
|
|
139
179
|
# Run the linter
|
|
140
180
|
begin
|
|
141
181
|
result = Yard::Lint.run(
|
|
@@ -147,6 +187,9 @@ begin
|
|
|
147
187
|
rescue Yard::Lint::Git::Error => e
|
|
148
188
|
puts "Git error: #{e.message}"
|
|
149
189
|
exit 1
|
|
190
|
+
rescue Yard::Lint::Errors::FileNotFoundError => e
|
|
191
|
+
puts "Error: #{e.message}"
|
|
192
|
+
exit 1
|
|
150
193
|
end
|
|
151
194
|
|
|
152
195
|
# Format and display results
|
data/lib/yard/lint/config.rb
CHANGED
|
@@ -6,6 +6,7 @@ module Yard
|
|
|
6
6
|
# Configuration object for YARD Lint
|
|
7
7
|
class Config
|
|
8
8
|
attr_reader :raw_config, :validators
|
|
9
|
+
attr_accessor :only_validators
|
|
9
10
|
|
|
10
11
|
# Default YAML config file name
|
|
11
12
|
DEFAULT_CONFIG_FILE = '.yard-lint.yml'
|
|
@@ -20,6 +21,7 @@ module Yard
|
|
|
20
21
|
def initialize(raw_config = {})
|
|
21
22
|
@raw_config = raw_config
|
|
22
23
|
@validators = build_validators_config
|
|
24
|
+
@only_validators = []
|
|
23
25
|
|
|
24
26
|
yield self if block_given?
|
|
25
27
|
end
|
|
@@ -146,6 +148,9 @@ module Yard
|
|
|
146
148
|
# @param validator_name [String] full validator name (e.g., 'Tags/Order')
|
|
147
149
|
# @return [Boolean] true if validator is enabled
|
|
148
150
|
def validator_enabled?(validator_name)
|
|
151
|
+
# If --only is specified, it takes full control
|
|
152
|
+
return only_validators.include?(validator_name) if only_validators.any?
|
|
153
|
+
|
|
149
154
|
validator_config = validators[validator_name] || {}
|
|
150
155
|
validator_config['Enabled'] != false # Default to true
|
|
151
156
|
end
|