solargraph-yard-lint 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +27 -0
- data/.solargraph.yml +21 -0
- data/.yard-lint.yml +313 -0
- data/CHANGELOG.md +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +47 -0
- data/Rakefile +12 -0
- data/lib/solargraph/yard_lint/diagnostic.rb +90 -0
- data/lib/solargraph/yard_lint/helpers.rb +35 -0
- data/lib/solargraph/yard_lint/version.rb +10 -0
- data/lib/solargraph-yard-lint.rb +11 -0
- data/solargraph-yard-lint.gemspec +30 -0
- metadata +83 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 61f4706a15a10a7daf1a6799bcf2b34a6399d52287055c3764eb6d4d23bbf88d
|
|
4
|
+
data.tar.gz: 8ab135ecc1779da62b5bb122c300d8e2c01e967483b563da88b280c6be103a62
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 49a4f3cef512e8dbe65691d122154a46ca068b7226a8b0f27ade5e667cbbe9ca9a18d859acc3f01ed94d177950bb4af1eb81094686b1d78ba4539a53c4548970
|
|
7
|
+
data.tar.gz: 431848919af29a62c0931ba4bba1a3d5ec1672dc3e16107731a9f73e3874a8fa197e6d8ac1528879258ada826e5deb6163d7cb72ce12e70a526190a54d8e6db8
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
plugins:
|
|
2
|
+
- rubocop-rspec
|
|
3
|
+
|
|
4
|
+
AllCops:
|
|
5
|
+
NewCops: enable
|
|
6
|
+
TargetRubyVersion: 3.2
|
|
7
|
+
Exclude:
|
|
8
|
+
- 'spec/fixtures/**/*'
|
|
9
|
+
- 'vendor/**/*'
|
|
10
|
+
|
|
11
|
+
Style/Documentation:
|
|
12
|
+
Enabled: false
|
|
13
|
+
|
|
14
|
+
Style/MethodDefParentheses:
|
|
15
|
+
EnforcedStyle: require_no_parentheses
|
|
16
|
+
|
|
17
|
+
Metrics/MethodLength:
|
|
18
|
+
Max: 20
|
|
19
|
+
|
|
20
|
+
RSpec/SpecFilePathFormat:
|
|
21
|
+
Enabled: false
|
|
22
|
+
|
|
23
|
+
RSpec/ExampleLength:
|
|
24
|
+
Max: 15
|
|
25
|
+
|
|
26
|
+
RSpec/MultipleExpectations:
|
|
27
|
+
Max: 10
|
data/.solargraph.yml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
include:
|
|
3
|
+
- "**/*.rb"
|
|
4
|
+
exclude:
|
|
5
|
+
- "**/spec/**/*"
|
|
6
|
+
- test/**/*
|
|
7
|
+
- vendor/**/*
|
|
8
|
+
- ".bundle/**/*"
|
|
9
|
+
require: []
|
|
10
|
+
domains: []
|
|
11
|
+
plugins:
|
|
12
|
+
- solargraph-yard-lint
|
|
13
|
+
reporters:
|
|
14
|
+
- typecheck:strict
|
|
15
|
+
- rubocop
|
|
16
|
+
- require_not_found
|
|
17
|
+
- yard_lint
|
|
18
|
+
formatter:
|
|
19
|
+
rubocop:
|
|
20
|
+
cops: all
|
|
21
|
+
max_files: 20000
|
data/.yard-lint.yml
ADDED
|
@@ -0,0 +1,313 @@
|
|
|
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/MissingReturn:
|
|
56
|
+
Description: 'Requires @return tags on all methods (opt-in for strict documentation).'
|
|
57
|
+
Enabled: false # Opt-in validator
|
|
58
|
+
Severity: warning
|
|
59
|
+
ExcludedMethods:
|
|
60
|
+
- 'initialize' # Exclude all initialize methods
|
|
61
|
+
# - '/^_/' # Uncomment to exclude private methods (by convention)
|
|
62
|
+
|
|
63
|
+
Documentation/MarkdownSyntax:
|
|
64
|
+
Description: 'Detects common markdown syntax errors in documentation.'
|
|
65
|
+
Enabled: true
|
|
66
|
+
Severity: warning
|
|
67
|
+
|
|
68
|
+
Documentation/EmptyCommentLine:
|
|
69
|
+
Description: 'Detects empty comment lines at the start or end of documentation blocks.'
|
|
70
|
+
Enabled: true
|
|
71
|
+
Severity: convention
|
|
72
|
+
EnabledPatterns:
|
|
73
|
+
Leading: true
|
|
74
|
+
Trailing: true
|
|
75
|
+
|
|
76
|
+
Documentation/BlankLineBeforeDefinition:
|
|
77
|
+
Description: 'Detects blank lines between YARD documentation and method definition.'
|
|
78
|
+
Enabled: true
|
|
79
|
+
Severity: convention
|
|
80
|
+
OrphanedSeverity: convention
|
|
81
|
+
EnabledPatterns:
|
|
82
|
+
SingleBlankLine: true
|
|
83
|
+
OrphanedDocs: true
|
|
84
|
+
|
|
85
|
+
# Tags validators
|
|
86
|
+
Tags/Order:
|
|
87
|
+
Description: 'Enforces consistent ordering of YARD tags.'
|
|
88
|
+
Enabled: true
|
|
89
|
+
Severity: convention
|
|
90
|
+
EnforcedOrder:
|
|
91
|
+
- param
|
|
92
|
+
- option
|
|
93
|
+
- yield
|
|
94
|
+
- yieldparam
|
|
95
|
+
- yieldreturn
|
|
96
|
+
- return
|
|
97
|
+
- raise
|
|
98
|
+
- see
|
|
99
|
+
- example
|
|
100
|
+
- note
|
|
101
|
+
- todo
|
|
102
|
+
|
|
103
|
+
Tags/InvalidTypes:
|
|
104
|
+
Description: 'Validates type definitions in @param, @return, @option tags.'
|
|
105
|
+
# Disabled: we use YARD shorthand like `Hash{:a, :b => String; :c => Integer}`
|
|
106
|
+
# to document fixed-shape hashes; this validator rejects the semicolon form.
|
|
107
|
+
# See https://github.com/mensfeld/yard-lint/issues/171
|
|
108
|
+
Enabled: false
|
|
109
|
+
Severity: warning
|
|
110
|
+
ValidatedTags:
|
|
111
|
+
- param
|
|
112
|
+
- option
|
|
113
|
+
- return
|
|
114
|
+
|
|
115
|
+
Tags/TypeSyntax:
|
|
116
|
+
Description: 'Validates YARD type syntax using YARD parser.'
|
|
117
|
+
Enabled: true
|
|
118
|
+
Severity: warning
|
|
119
|
+
ValidatedTags:
|
|
120
|
+
- param
|
|
121
|
+
- option
|
|
122
|
+
- return
|
|
123
|
+
- yieldreturn
|
|
124
|
+
|
|
125
|
+
Tags/MeaninglessTag:
|
|
126
|
+
Description: 'Detects @param/@option tags on classes, modules, or constants.'
|
|
127
|
+
Enabled: true
|
|
128
|
+
Severity: warning
|
|
129
|
+
CheckedTags:
|
|
130
|
+
- param
|
|
131
|
+
- option
|
|
132
|
+
InvalidObjectTypes:
|
|
133
|
+
- class
|
|
134
|
+
- module
|
|
135
|
+
- constant
|
|
136
|
+
|
|
137
|
+
Tags/CollectionType:
|
|
138
|
+
Description: 'Validates Hash collection syntax consistency.'
|
|
139
|
+
Enabled: true
|
|
140
|
+
Severity: convention
|
|
141
|
+
EnforcedStyle: long # 'long' for Hash{K => V} (YARD standard), 'short' for {K => V}
|
|
142
|
+
ValidatedTags:
|
|
143
|
+
- param
|
|
144
|
+
- option
|
|
145
|
+
- return
|
|
146
|
+
- yieldreturn
|
|
147
|
+
|
|
148
|
+
Tags/TagTypePosition:
|
|
149
|
+
Description: 'Validates type annotation position in tags.'
|
|
150
|
+
Enabled: true
|
|
151
|
+
Severity: convention
|
|
152
|
+
CheckedTags:
|
|
153
|
+
- param
|
|
154
|
+
- option
|
|
155
|
+
# EnforcedStyle: 'type_after_name' (YARD standard: @param name [Type])
|
|
156
|
+
# or 'type_first' (@param [Type] name)
|
|
157
|
+
EnforcedStyle: type_after_name
|
|
158
|
+
|
|
159
|
+
Tags/ApiTags:
|
|
160
|
+
Description: 'Enforces @api tags on public objects.'
|
|
161
|
+
Enabled: false # Opt-in validator
|
|
162
|
+
Severity: warning
|
|
163
|
+
AllowedApis:
|
|
164
|
+
- public
|
|
165
|
+
- private
|
|
166
|
+
- internal
|
|
167
|
+
|
|
168
|
+
Tags/OptionTags:
|
|
169
|
+
Description: 'Requires @option tags for methods with options parameters.'
|
|
170
|
+
Enabled: true
|
|
171
|
+
Severity: warning
|
|
172
|
+
|
|
173
|
+
Tags/ExampleSyntax:
|
|
174
|
+
Description: 'Validates Ruby syntax in @example tags.'
|
|
175
|
+
Enabled: true
|
|
176
|
+
Severity: warning
|
|
177
|
+
|
|
178
|
+
Tags/ExampleStyle:
|
|
179
|
+
Description: 'Validates code style in @example tags using RuboCop/StandardRB.'
|
|
180
|
+
Enabled: false # Opt-in validator (requires RuboCop or StandardRB)
|
|
181
|
+
Severity: convention
|
|
182
|
+
# Linter: auto # Uncomment to explicitly configure: 'auto', 'rubocop', 'standard', 'none'
|
|
183
|
+
# SkipPatterns: # Uncomment to skip examples matching patterns
|
|
184
|
+
# - '/skip-lint/i'
|
|
185
|
+
# - '/bad code/i'
|
|
186
|
+
|
|
187
|
+
Tags/RedundantParamDescription:
|
|
188
|
+
Description: 'Detects meaningless parameter descriptions that add no value.'
|
|
189
|
+
Enabled: true
|
|
190
|
+
Severity: convention
|
|
191
|
+
CheckedTags:
|
|
192
|
+
- param
|
|
193
|
+
- option
|
|
194
|
+
Articles:
|
|
195
|
+
- The
|
|
196
|
+
- the
|
|
197
|
+
- A
|
|
198
|
+
- a
|
|
199
|
+
- An
|
|
200
|
+
- an
|
|
201
|
+
MaxRedundantWords: 6
|
|
202
|
+
GenericTerms:
|
|
203
|
+
- object
|
|
204
|
+
- instance
|
|
205
|
+
- value
|
|
206
|
+
- data
|
|
207
|
+
- item
|
|
208
|
+
- element
|
|
209
|
+
EnabledPatterns:
|
|
210
|
+
ArticleParam: true
|
|
211
|
+
PossessiveParam: true
|
|
212
|
+
TypeRestatement: true
|
|
213
|
+
ParamToVerb: true
|
|
214
|
+
IdPattern: true
|
|
215
|
+
DirectionalDate: true
|
|
216
|
+
TypeGeneric: true
|
|
217
|
+
|
|
218
|
+
Tags/InformalNotation:
|
|
219
|
+
Description: 'Detects informal tag notation patterns like "Note:" instead of @note.'
|
|
220
|
+
Enabled: true
|
|
221
|
+
Severity: warning
|
|
222
|
+
CaseSensitive: false
|
|
223
|
+
RequireStartOfLine: true
|
|
224
|
+
Patterns:
|
|
225
|
+
Note: '@note'
|
|
226
|
+
Todo: '@todo'
|
|
227
|
+
TODO: '@todo'
|
|
228
|
+
FIXME: '@todo'
|
|
229
|
+
See: '@see'
|
|
230
|
+
See also: '@see'
|
|
231
|
+
Warning: '@deprecated'
|
|
232
|
+
Deprecated: '@deprecated'
|
|
233
|
+
Author: '@author'
|
|
234
|
+
Version: '@version'
|
|
235
|
+
Since: '@since'
|
|
236
|
+
Returns: '@return'
|
|
237
|
+
Raises: '@raise'
|
|
238
|
+
Example: '@example'
|
|
239
|
+
|
|
240
|
+
Tags/NonAsciiType:
|
|
241
|
+
Description: 'Detects non-ASCII characters in type annotations.'
|
|
242
|
+
Enabled: true
|
|
243
|
+
Severity: warning
|
|
244
|
+
ValidatedTags:
|
|
245
|
+
- param
|
|
246
|
+
- option
|
|
247
|
+
- return
|
|
248
|
+
- yieldreturn
|
|
249
|
+
- yieldparam
|
|
250
|
+
|
|
251
|
+
Tags/TagGroupSeparator:
|
|
252
|
+
Description: 'Enforces blank line separators between different YARD tag groups.'
|
|
253
|
+
Enabled: false # Opt-in validator
|
|
254
|
+
Severity: convention
|
|
255
|
+
TagGroups:
|
|
256
|
+
param: [param, option]
|
|
257
|
+
return: [return]
|
|
258
|
+
error: [raise, throws]
|
|
259
|
+
example: [example]
|
|
260
|
+
meta: [see, note, todo, deprecated, since, version, api]
|
|
261
|
+
yield: [yield, yieldparam, yieldreturn]
|
|
262
|
+
RequireAfterDescription: false
|
|
263
|
+
|
|
264
|
+
Tags/ForbiddenTags:
|
|
265
|
+
Description: 'Detects forbidden tag and type combinations.'
|
|
266
|
+
Enabled: false # Opt-in validator
|
|
267
|
+
Severity: convention
|
|
268
|
+
ForbiddenPatterns: []
|
|
269
|
+
# Example patterns:
|
|
270
|
+
# - Tag: return
|
|
271
|
+
# Types:
|
|
272
|
+
# - void
|
|
273
|
+
# - Tag: param
|
|
274
|
+
# Types:
|
|
275
|
+
# - Object
|
|
276
|
+
# - Tag: api # Forbids @api tag entirely (no Types = any occurrence)
|
|
277
|
+
|
|
278
|
+
# Warnings validators - catches YARD parser errors
|
|
279
|
+
Warnings/UnknownTag:
|
|
280
|
+
Description: 'Detects unknown YARD tags.'
|
|
281
|
+
Enabled: true
|
|
282
|
+
Severity: error
|
|
283
|
+
|
|
284
|
+
Warnings/UnknownDirective:
|
|
285
|
+
Description: 'Detects unknown YARD directives.'
|
|
286
|
+
Enabled: true
|
|
287
|
+
Severity: error
|
|
288
|
+
|
|
289
|
+
Warnings/InvalidTagFormat:
|
|
290
|
+
Description: 'Detects malformed tag syntax.'
|
|
291
|
+
Enabled: true
|
|
292
|
+
Severity: error
|
|
293
|
+
|
|
294
|
+
Warnings/InvalidDirectiveFormat:
|
|
295
|
+
Description: 'Detects malformed directive syntax.'
|
|
296
|
+
Enabled: true
|
|
297
|
+
Severity: error
|
|
298
|
+
|
|
299
|
+
Warnings/DuplicatedParameterName:
|
|
300
|
+
Description: 'Detects duplicate @param tags.'
|
|
301
|
+
Enabled: true
|
|
302
|
+
Severity: error
|
|
303
|
+
|
|
304
|
+
Warnings/UnknownParameterName:
|
|
305
|
+
Description: 'Detects @param tags for non-existent parameters.'
|
|
306
|
+
Enabled: true
|
|
307
|
+
Severity: error
|
|
308
|
+
|
|
309
|
+
# Semantic validators
|
|
310
|
+
Semantic/AbstractMethods:
|
|
311
|
+
Description: 'Ensures @abstract methods do not have real implementations.'
|
|
312
|
+
Enabled: true
|
|
313
|
+
Severity: warning
|
data/CHANGELOG.md
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Lekë Mula
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# solargraph-yard-lint
|
|
2
|
+
|
|
3
|
+
A [Solargraph](https://github.com/castwide/solargraph) plugin that surfaces
|
|
4
|
+
[yard-lint](https://github.com/mensfeld/yard-lint) offenses as LSP diagnostics
|
|
5
|
+
in your editor.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add to your project's `Gemfile`:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
group :development do
|
|
13
|
+
gem 'solargraph'
|
|
14
|
+
gem 'solargraph-yard-lint'
|
|
15
|
+
end
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Then `bundle install`.
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
Add to your project's `.solargraph.yml`:
|
|
23
|
+
|
|
24
|
+
```yaml
|
|
25
|
+
plugins:
|
|
26
|
+
- solargraph-yard-lint
|
|
27
|
+
reporters:
|
|
28
|
+
- rubocop
|
|
29
|
+
- require_not_found
|
|
30
|
+
- yard_lint
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Restart your Solargraph language server. YARD documentation offenses will
|
|
34
|
+
appear as diagnostics in your editor.
|
|
35
|
+
|
|
36
|
+
Configure yard-lint itself via `.yard-lint.yml` in your project root — see
|
|
37
|
+
[yard-lint's documentation](https://github.com/mensfeld/yard-lint) for details.
|
|
38
|
+
|
|
39
|
+
## Notes
|
|
40
|
+
|
|
41
|
+
yard-lint reads files from disk and does not accept stdin, so this reporter
|
|
42
|
+
only lints sources whose buffer contents match the on-disk file. Unsaved
|
|
43
|
+
edits will not produce yard-lint diagnostics until the file is saved.
|
|
44
|
+
|
|
45
|
+
## License
|
|
46
|
+
|
|
47
|
+
MIT
|
data/Rakefile
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Solargraph language server.
|
|
4
|
+
module Solargraph
|
|
5
|
+
# yard-lint diagnostics plugin for Solargraph.
|
|
6
|
+
module YardLint
|
|
7
|
+
# Solargraph diagnostic reporter backed by yard-lint.
|
|
8
|
+
class Diagnostic < Solargraph::Diagnostics::Base
|
|
9
|
+
include Helpers
|
|
10
|
+
|
|
11
|
+
# Conversion of yard-lint severity names to LSP constants
|
|
12
|
+
SEVERITIES = {
|
|
13
|
+
'convention' => Solargraph::Diagnostics::Severities::INFORMATION,
|
|
14
|
+
'warning' => Solargraph::Diagnostics::Severities::WARNING,
|
|
15
|
+
'error' => Solargraph::Diagnostics::Severities::ERROR
|
|
16
|
+
}.freeze
|
|
17
|
+
|
|
18
|
+
# @param source [Solargraph::Source]
|
|
19
|
+
# @param _api_map [Solargraph::ApiMap]
|
|
20
|
+
# @return [Array<Hash{:range => Hash; :severity => Integer; :source, :code, :message => String}>]
|
|
21
|
+
def diagnose source, _api_map
|
|
22
|
+
@source = source
|
|
23
|
+
return [] unless lintable?(source)
|
|
24
|
+
|
|
25
|
+
require_yard_lint(yard_lint_version)
|
|
26
|
+
result = Solargraph::CHDIR_MUTEX.synchronize do
|
|
27
|
+
::Yard::Lint.run(path: source.filename, progress: false)
|
|
28
|
+
end
|
|
29
|
+
return [] if result.clean?
|
|
30
|
+
|
|
31
|
+
result.offenses.map { |off| offense_to_diagnostic(off) }
|
|
32
|
+
rescue InvalidVersionError
|
|
33
|
+
raise
|
|
34
|
+
rescue StandardError => e
|
|
35
|
+
raise Solargraph::DiagnosticsError, "Error running yard-lint: #{e.message}"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
# yard-lint reads from disk and cannot accept unsaved buffer contents,
|
|
41
|
+
# so only lint when the source is backed by an on-disk file.
|
|
42
|
+
#
|
|
43
|
+
# @param source [Solargraph::Source]
|
|
44
|
+
# @return [Boolean]
|
|
45
|
+
def lintable? source
|
|
46
|
+
filename = source.filename
|
|
47
|
+
return false if filename.nil? || filename.empty?
|
|
48
|
+
|
|
49
|
+
File.file?(filename)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# @return [String]
|
|
53
|
+
def yard_lint_version
|
|
54
|
+
args.find { |a| a =~ /version=/ }.to_s.split('=').last
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Convert a yard-lint offense to an LSP diagnostic
|
|
58
|
+
#
|
|
59
|
+
# rubocop:disable Layout/LineLength
|
|
60
|
+
# @param off [Hash{:name, :message, :location, :severity, :type => String; :line, :location_line => Integer}] Offense received from yard-lint
|
|
61
|
+
# @return [Hash{:range => Hash; :severity => Integer; :source, :code, :message => String}] LSP diagnostic
|
|
62
|
+
# rubocop:enable Layout/LineLength
|
|
63
|
+
def offense_to_diagnostic off
|
|
64
|
+
{
|
|
65
|
+
range: offense_range(off).to_hash,
|
|
66
|
+
severity: SEVERITIES[off[:severity]] || Solargraph::Diagnostics::Severities::WARNING,
|
|
67
|
+
source: 'yard-lint',
|
|
68
|
+
code: off[:name],
|
|
69
|
+
message: off[:message]
|
|
70
|
+
}
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# yard-lint reports offenses at line granularity only (no column),
|
|
74
|
+
# so the range spans the entire reported line.
|
|
75
|
+
#
|
|
76
|
+
# @param off [Hash{:line, :location_line => Integer}]
|
|
77
|
+
# @return [Solargraph::Range]
|
|
78
|
+
def offense_range off
|
|
79
|
+
line = (off[:location_line] || off[:line] || 1).to_i - 1
|
|
80
|
+
line = 0 if line.negative?
|
|
81
|
+
line_text = @source.code.lines[line] || ''
|
|
82
|
+
end_col = line_text.chomp.length
|
|
83
|
+
Solargraph::Range.new(
|
|
84
|
+
Solargraph::Position.new(line, 0),
|
|
85
|
+
Solargraph::Position.new(line, end_col)
|
|
86
|
+
)
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Solargraph language server.
|
|
4
|
+
module Solargraph
|
|
5
|
+
# yard-lint diagnostics plugin for Solargraph.
|
|
6
|
+
module YardLint
|
|
7
|
+
# Raised when a requested yard-lint version is not installed.
|
|
8
|
+
class InvalidVersionError < RuntimeError; end
|
|
9
|
+
|
|
10
|
+
# Utility methods for the yard-lint diagnostics reporter.
|
|
11
|
+
module Helpers
|
|
12
|
+
module_function
|
|
13
|
+
|
|
14
|
+
# Requires a specific version of yard-lint, or the latest installed
|
|
15
|
+
# version if _version_ is `nil`.
|
|
16
|
+
#
|
|
17
|
+
# @param version [String, nil]
|
|
18
|
+
# @return [void]
|
|
19
|
+
# @raise [InvalidVersionError] if _version_ is not installed
|
|
20
|
+
def require_yard_lint version = nil
|
|
21
|
+
begin
|
|
22
|
+
gem_path = Gem::Specification.find_by_name('yard-lint', version).full_gem_path
|
|
23
|
+
gem_lib_path = File.join(gem_path, 'lib')
|
|
24
|
+
$LOAD_PATH.unshift(gem_lib_path) unless $LOAD_PATH.include?(gem_lib_path)
|
|
25
|
+
rescue Gem::MissingSpecVersionError => e
|
|
26
|
+
specs = e.specs
|
|
27
|
+
raise InvalidVersionError,
|
|
28
|
+
"could not find '#{e.name}' (#{e.requirement}) - " \
|
|
29
|
+
"did find: [#{specs.map { |s| s.version.version }.join(', ')}]"
|
|
30
|
+
end
|
|
31
|
+
require 'yard-lint'
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# rubocop:disable Naming/FileName
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require 'solargraph'
|
|
5
|
+
|
|
6
|
+
require_relative 'solargraph/yard_lint/version'
|
|
7
|
+
require_relative 'solargraph/yard_lint/helpers'
|
|
8
|
+
require_relative 'solargraph/yard_lint/diagnostic'
|
|
9
|
+
|
|
10
|
+
Solargraph::Diagnostics.register('yard_lint', Solargraph::YardLint::Diagnostic)
|
|
11
|
+
# rubocop:enable Naming/FileName
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'lib/solargraph/yard_lint/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'solargraph-yard-lint'
|
|
7
|
+
spec.version = Solargraph::YardLint::VERSION
|
|
8
|
+
spec.authors = ['Lekë Mula']
|
|
9
|
+
spec.email = ['leke.mula@gmail.com']
|
|
10
|
+
|
|
11
|
+
spec.summary = 'Solargraph plugin that surfaces yard-lint offenses as LSP diagnostics'
|
|
12
|
+
spec.description = 'Adds a yard_lint diagnostic reporter to Solargraph, powered by the ' \
|
|
13
|
+
'yard-lint gem. Surfaces YARD documentation issues in your editor.'
|
|
14
|
+
spec.license = 'MIT'
|
|
15
|
+
spec.required_ruby_version = '>= 3.2'
|
|
16
|
+
|
|
17
|
+
spec.metadata['source_code_uri'] = 'https://github.com/lekemula/solargraph-yard-lint'
|
|
18
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
19
|
+
|
|
20
|
+
spec.files = Dir.chdir(__dir__) do
|
|
21
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
|
22
|
+
(File.expand_path(f) == __FILE__) ||
|
|
23
|
+
f.start_with?(*%w[bin/ test/ spec/ features/ doc/ .git .github Gemfile])
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
spec.require_paths = ['lib']
|
|
27
|
+
|
|
28
|
+
spec.add_dependency 'solargraph', '>= 0.52.0'
|
|
29
|
+
spec.add_dependency 'yard-lint', '~> 1.5'
|
|
30
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: solargraph-yard-lint
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Lekë Mula
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: solargraph
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: 0.52.0
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: 0.52.0
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: yard-lint
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '1.5'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '1.5'
|
|
40
|
+
description: Adds a yard_lint diagnostic reporter to Solargraph, powered by the yard-lint
|
|
41
|
+
gem. Surfaces YARD documentation issues in your editor.
|
|
42
|
+
email:
|
|
43
|
+
- leke.mula@gmail.com
|
|
44
|
+
executables: []
|
|
45
|
+
extensions: []
|
|
46
|
+
extra_rdoc_files: []
|
|
47
|
+
files:
|
|
48
|
+
- ".rspec"
|
|
49
|
+
- ".rubocop.yml"
|
|
50
|
+
- ".solargraph.yml"
|
|
51
|
+
- ".yard-lint.yml"
|
|
52
|
+
- CHANGELOG.md
|
|
53
|
+
- LICENSE.txt
|
|
54
|
+
- README.md
|
|
55
|
+
- Rakefile
|
|
56
|
+
- lib/solargraph-yard-lint.rb
|
|
57
|
+
- lib/solargraph/yard_lint/diagnostic.rb
|
|
58
|
+
- lib/solargraph/yard_lint/helpers.rb
|
|
59
|
+
- lib/solargraph/yard_lint/version.rb
|
|
60
|
+
- solargraph-yard-lint.gemspec
|
|
61
|
+
licenses:
|
|
62
|
+
- MIT
|
|
63
|
+
metadata:
|
|
64
|
+
source_code_uri: https://github.com/lekemula/solargraph-yard-lint
|
|
65
|
+
rubygems_mfa_required: 'true'
|
|
66
|
+
rdoc_options: []
|
|
67
|
+
require_paths:
|
|
68
|
+
- lib
|
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
70
|
+
requirements:
|
|
71
|
+
- - ">="
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
version: '3.2'
|
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
|
+
requirements:
|
|
76
|
+
- - ">="
|
|
77
|
+
- !ruby/object:Gem::Version
|
|
78
|
+
version: '0'
|
|
79
|
+
requirements: []
|
|
80
|
+
rubygems_version: 4.0.12
|
|
81
|
+
specification_version: 4
|
|
82
|
+
summary: Solargraph plugin that surfaces yard-lint offenses as LSP diagnostics
|
|
83
|
+
test_files: []
|