yard-lint 1.13.0 → 1.14.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 +4 -4
- data/CHANGELOG.md +19 -0
- data/README.md +15 -8
- data/bin/yard-lint +24 -34
- data/lib/yard/lint/contracts/base.rb +20 -6
- data/lib/yard/lint/contracts/cli_options.rb +62 -0
- data/lib/yard/lint/contracts/config.rb +1 -1
- data/lib/yard/lint/executor/in_process_registry.rb +79 -9
- data/lib/yard/lint/formatters/relative_path.rb +32 -0
- data/lib/yard/lint/formatters/sarif.rb +2 -12
- data/lib/yard/lint/result_builder.rb +44 -15
- data/lib/yard/lint/results/aggregate.rb +4 -2
- data/lib/yard/lint/runner.rb +16 -14
- data/lib/yard/lint/stats_calculator.rb +59 -37
- data/lib/yard/lint/todo_generator.rb +33 -21
- data/lib/yard/lint/validators/base.rb +25 -10
- data/lib/yard/lint/validators/documentation/undocumented_boolean_methods/messages_builder.rb +23 -0
- data/lib/yard/lint/validators/documentation/undocumented_boolean_methods/result.rb +1 -2
- data/lib/yard/lint/validators/documentation/undocumented_method_arguments/messages_builder.rb +10 -3
- data/lib/yard/lint/validators/documentation/undocumented_method_arguments/parser.rb +22 -3
- data/lib/yard/lint/validators/documentation/undocumented_method_arguments/validator.rb +46 -8
- data/lib/yard/lint/validators/documentation/undocumented_objects/parser.rb +15 -13
- data/lib/yard/lint/validators/documentation/undocumented_objects/result.rb +6 -1
- data/lib/yard/lint/validators/documentation/undocumented_objects/validator.rb +25 -2
- data/lib/yard/lint/validators/tags/example_style/validator.rb +7 -2
- data/lib/yard/lint/version.rb +1 -1
- data/lib/yard/lint.rb +15 -14
- metadata +4 -1
|
@@ -17,17 +17,40 @@ module Yard
|
|
|
17
17
|
# @return [void]
|
|
18
18
|
def in_process_query(object, collector)
|
|
19
19
|
return if parent_class_allowed?(object)
|
|
20
|
-
# Check if docstring is empty
|
|
21
|
-
return unless object.docstring.all.empty?
|
|
22
20
|
|
|
23
21
|
if object.is_a?(YARD::CodeObjects::MethodObject)
|
|
22
|
+
return unless undocumented_method?(object)
|
|
23
|
+
|
|
24
24
|
# For methods, include arity (excluding splat and block params)
|
|
25
25
|
arity = object.parameters.reject { |p| p[0].to_s.start_with?('*', '&') }.size
|
|
26
26
|
collector.puts "#{object.file}:#{object.line}: #{object.title}|#{arity}"
|
|
27
27
|
else
|
|
28
|
+
return unless object.docstring.all.empty?
|
|
29
|
+
|
|
28
30
|
collector.puts "#{object.file}:#{object.line}: #{object.title}"
|
|
29
31
|
end
|
|
30
32
|
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
# A module_function pair is reported once, on its public module method.
|
|
37
|
+
# YARD gives one half of an undocumented `?` pair an inferred `@return`.
|
|
38
|
+
# @param object [YARD::CodeObjects::MethodObject] the method to check
|
|
39
|
+
# @return [Boolean] true when the method should be reported
|
|
40
|
+
def undocumented_method?(object)
|
|
41
|
+
if object.docstring.all.empty?
|
|
42
|
+
# A class cannot define module functions; skipping it saves the twin lookup.
|
|
43
|
+
# Visibility cannot skip it: the copy is public when `module_function :name`
|
|
44
|
+
# is parsed before the def
|
|
45
|
+
object.scope == :class ||
|
|
46
|
+
object.namespace.is_a?(YARD::CodeObjects::ClassObject) ||
|
|
47
|
+
module_function_twin(object).nil?
|
|
48
|
+
else
|
|
49
|
+
object.module_function? &&
|
|
50
|
+
object.name.end_with?('?') &&
|
|
51
|
+
module_function_twin(object)&.docstring&.all&.empty? == true
|
|
52
|
+
end
|
|
53
|
+
end
|
|
31
54
|
end
|
|
32
55
|
end
|
|
33
56
|
end
|
|
@@ -10,6 +10,11 @@ module Yard
|
|
|
10
10
|
# Enable in-process execution with all visibility
|
|
11
11
|
in_process visibility: :all
|
|
12
12
|
|
|
13
|
+
class << self
|
|
14
|
+
# @return [Boolean, nil] whether the missing linter warning was already printed
|
|
15
|
+
attr_accessor :warned_about_linter
|
|
16
|
+
end
|
|
17
|
+
|
|
13
18
|
# Execute query for a single object during in-process execution.
|
|
14
19
|
# Checks code style in @example tags using RuboCop or StandardRB.
|
|
15
20
|
# @param object [YARD::CodeObjects::Base] the code object to query
|
|
@@ -74,10 +79,10 @@ module Yard
|
|
|
74
79
|
|
|
75
80
|
# Warn once about missing linter (class-level tracking)
|
|
76
81
|
def warn_once_about_missing_linter
|
|
77
|
-
return if self.class.
|
|
82
|
+
return if self.class.warned_about_linter
|
|
78
83
|
|
|
79
84
|
warn '[YARD::Lint] ExampleStyle validator enabled but no linter (RuboCop/StandardRB) found. Skipping.'
|
|
80
|
-
self.class.
|
|
85
|
+
self.class.warned_about_linter = true
|
|
81
86
|
end
|
|
82
87
|
end
|
|
83
88
|
end
|
data/lib/yard/lint/version.rb
CHANGED
data/lib/yard/lint.rb
CHANGED
|
@@ -55,6 +55,21 @@ module Yard
|
|
|
55
55
|
runner.run
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
+
# Expand path/glob patterns into an array of files
|
|
59
|
+
# @api private
|
|
60
|
+
# @param path [String, Array<String>] path or array of paths
|
|
61
|
+
# @param config [Yard::Lint::Config] configuration object
|
|
62
|
+
# @return [Array<String>] array of absolute file paths
|
|
63
|
+
def expand_path(path, config)
|
|
64
|
+
files = discover_ruby_files(path)
|
|
65
|
+
|
|
66
|
+
# Convert to absolute paths for YARD
|
|
67
|
+
files = files.map { |file| File.expand_path(file) }
|
|
68
|
+
|
|
69
|
+
# Filter out excluded files
|
|
70
|
+
files.reject { |file| config.excluded_path?(file, config.exclude) }
|
|
71
|
+
end
|
|
72
|
+
|
|
58
73
|
private
|
|
59
74
|
|
|
60
75
|
# Load configuration from file or auto-detect
|
|
@@ -93,20 +108,6 @@ module Yard
|
|
|
93
108
|
git_files.reject { |file| config.excluded_path?(file, config.exclude) }
|
|
94
109
|
end
|
|
95
110
|
|
|
96
|
-
# Expand path/glob patterns into an array of files
|
|
97
|
-
# @param path [String, Array<String>] path or array of paths
|
|
98
|
-
# @param config [Yard::Lint::Config] configuration object
|
|
99
|
-
# @return [Array<String>] array of absolute file paths
|
|
100
|
-
def expand_path(path, config)
|
|
101
|
-
files = discover_ruby_files(path)
|
|
102
|
-
|
|
103
|
-
# Convert to absolute paths for YARD
|
|
104
|
-
files = files.map { |file| File.expand_path(file) }
|
|
105
|
-
|
|
106
|
-
# Filter out excluded files
|
|
107
|
-
files.reject { |file| config.excluded_path?(file, config.exclude) }
|
|
108
|
-
end
|
|
109
|
-
|
|
110
111
|
# Discover Ruby files from path/glob patterns
|
|
111
112
|
# @param path [String, Array<String>] path or array of paths
|
|
112
113
|
# @return [Array<String>] array of discovered Ruby file paths
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: yard-lint
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.14.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Maciej Mensfeld
|
|
@@ -62,6 +62,7 @@ files:
|
|
|
62
62
|
- lib/yard/lint/contractable/rule.rb
|
|
63
63
|
- lib/yard/lint/contracts/base.rb
|
|
64
64
|
- lib/yard/lint/contracts/category.rb
|
|
65
|
+
- lib/yard/lint/contracts/cli_options.rb
|
|
65
66
|
- lib/yard/lint/contracts/config.rb
|
|
66
67
|
- lib/yard/lint/contracts/validator.rb
|
|
67
68
|
- lib/yard/lint/errors.rb
|
|
@@ -72,6 +73,7 @@ files:
|
|
|
72
73
|
- lib/yard/lint/explainer.rb
|
|
73
74
|
- lib/yard/lint/ext/irb_notifier_shim.rb
|
|
74
75
|
- lib/yard/lint/formatters/progress.rb
|
|
76
|
+
- lib/yard/lint/formatters/relative_path.rb
|
|
75
77
|
- lib/yard/lint/formatters/sarif.rb
|
|
76
78
|
- lib/yard/lint/git.rb
|
|
77
79
|
- lib/yard/lint/parsers/base.rb
|
|
@@ -150,6 +152,7 @@ files:
|
|
|
150
152
|
- lib/yard/lint/validators/documentation/underfilled_lines/validator.rb
|
|
151
153
|
- lib/yard/lint/validators/documentation/undocumented_boolean_methods.rb
|
|
152
154
|
- lib/yard/lint/validators/documentation/undocumented_boolean_methods/config.rb
|
|
155
|
+
- lib/yard/lint/validators/documentation/undocumented_boolean_methods/messages_builder.rb
|
|
153
156
|
- lib/yard/lint/validators/documentation/undocumented_boolean_methods/parser.rb
|
|
154
157
|
- lib/yard/lint/validators/documentation/undocumented_boolean_methods/result.rb
|
|
155
158
|
- lib/yard/lint/validators/documentation/undocumented_boolean_methods/validator.rb
|