yard-lint 0.2.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/.coditsu/ci.yml +3 -0
- data/CHANGELOG.md +28 -0
- data/LICENSE.txt +21 -0
- data/README.md +454 -0
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/bin/yard-lint +109 -0
- data/lib/yard/lint/command_cache.rb +77 -0
- data/lib/yard/lint/config.rb +255 -0
- data/lib/yard/lint/config_loader.rb +198 -0
- data/lib/yard/lint/errors.rb +17 -0
- data/lib/yard/lint/formatters/progress.rb +50 -0
- data/lib/yard/lint/parsers/base.rb +23 -0
- data/lib/yard/lint/parsers/one_line_base.rb +35 -0
- data/lib/yard/lint/parsers/two_line_base.rb +45 -0
- data/lib/yard/lint/result_builder.rb +130 -0
- data/lib/yard/lint/results/aggregate.rb +86 -0
- data/lib/yard/lint/results/base.rb +156 -0
- data/lib/yard/lint/runner.rb +125 -0
- data/lib/yard/lint/validators/base.rb +120 -0
- data/lib/yard/lint/validators/config.rb +30 -0
- data/lib/yard/lint/validators/documentation/undocumented_boolean_methods/config.rb +20 -0
- data/lib/yard/lint/validators/documentation/undocumented_boolean_methods/parser.rb +43 -0
- data/lib/yard/lint/validators/documentation/undocumented_boolean_methods/result.rb +26 -0
- data/lib/yard/lint/validators/documentation/undocumented_boolean_methods/validator.rb +48 -0
- data/lib/yard/lint/validators/documentation/undocumented_boolean_methods.rb +13 -0
- data/lib/yard/lint/validators/documentation/undocumented_method_arguments/config.rb +20 -0
- data/lib/yard/lint/validators/documentation/undocumented_method_arguments/messages_builder.rb +24 -0
- data/lib/yard/lint/validators/documentation/undocumented_method_arguments/parser.rb +45 -0
- data/lib/yard/lint/validators/documentation/undocumented_method_arguments/result.rb +25 -0
- data/lib/yard/lint/validators/documentation/undocumented_method_arguments/validator.rb +55 -0
- data/lib/yard/lint/validators/documentation/undocumented_method_arguments.rb +13 -0
- data/lib/yard/lint/validators/documentation/undocumented_objects/config.rb +21 -0
- data/lib/yard/lint/validators/documentation/undocumented_objects/messages_builder.rb +23 -0
- data/lib/yard/lint/validators/documentation/undocumented_objects/parser.rb +39 -0
- data/lib/yard/lint/validators/documentation/undocumented_objects/result.rb +25 -0
- data/lib/yard/lint/validators/documentation/undocumented_objects/validator.rb +39 -0
- data/lib/yard/lint/validators/documentation/undocumented_objects.rb +14 -0
- data/lib/yard/lint/validators/semantic/abstract_methods/config.rb +24 -0
- data/lib/yard/lint/validators/semantic/abstract_methods/messages_builder.rb +25 -0
- data/lib/yard/lint/validators/semantic/abstract_methods/parser.rb +45 -0
- data/lib/yard/lint/validators/semantic/abstract_methods/result.rb +42 -0
- data/lib/yard/lint/validators/semantic/abstract_methods/validator.rb +65 -0
- data/lib/yard/lint/validators/semantic/abstract_methods.rb +13 -0
- data/lib/yard/lint/validators/tags/api_tags/config.rb +21 -0
- data/lib/yard/lint/validators/tags/api_tags/messages_builder.rb +29 -0
- data/lib/yard/lint/validators/tags/api_tags/parser.rb +50 -0
- data/lib/yard/lint/validators/tags/api_tags/result.rb +42 -0
- data/lib/yard/lint/validators/tags/api_tags/validator.rb +69 -0
- data/lib/yard/lint/validators/tags/api_tags.rb +13 -0
- data/lib/yard/lint/validators/tags/invalid_types/config.rb +22 -0
- data/lib/yard/lint/validators/tags/invalid_types/messages_builder.rb +24 -0
- data/lib/yard/lint/validators/tags/invalid_types/parser.rb +16 -0
- data/lib/yard/lint/validators/tags/invalid_types/result.rb +25 -0
- data/lib/yard/lint/validators/tags/invalid_types/validator.rb +106 -0
- data/lib/yard/lint/validators/tags/invalid_types.rb +13 -0
- data/lib/yard/lint/validators/tags/option_tags/config.rb +21 -0
- data/lib/yard/lint/validators/tags/option_tags/messages_builder.rb +24 -0
- data/lib/yard/lint/validators/tags/option_tags/parser.rb +45 -0
- data/lib/yard/lint/validators/tags/option_tags/result.rb +42 -0
- data/lib/yard/lint/validators/tags/option_tags/validator.rb +61 -0
- data/lib/yard/lint/validators/tags/option_tags.rb +13 -0
- data/lib/yard/lint/validators/tags/order/config.rb +33 -0
- data/lib/yard/lint/validators/tags/order/messages_builder.rb +30 -0
- data/lib/yard/lint/validators/tags/order/parser.rb +66 -0
- data/lib/yard/lint/validators/tags/order/result.rb +26 -0
- data/lib/yard/lint/validators/tags/order/validator.rb +89 -0
- data/lib/yard/lint/validators/tags/order.rb +13 -0
- data/lib/yard/lint/validators/warnings/duplicated_parameter_name/config.rb +22 -0
- data/lib/yard/lint/validators/warnings/duplicated_parameter_name/parser.rb +22 -0
- data/lib/yard/lint/validators/warnings/duplicated_parameter_name/result.rb +25 -0
- data/lib/yard/lint/validators/warnings/duplicated_parameter_name/validator.rb +33 -0
- data/lib/yard/lint/validators/warnings/duplicated_parameter_name.rb +14 -0
- data/lib/yard/lint/validators/warnings/invalid_directive_format/config.rb +22 -0
- data/lib/yard/lint/validators/warnings/invalid_directive_format/parser.rb +22 -0
- data/lib/yard/lint/validators/warnings/invalid_directive_format/result.rb +25 -0
- data/lib/yard/lint/validators/warnings/invalid_directive_format/validator.rb +33 -0
- data/lib/yard/lint/validators/warnings/invalid_directive_format.rb +14 -0
- data/lib/yard/lint/validators/warnings/invalid_tag_format/config.rb +22 -0
- data/lib/yard/lint/validators/warnings/invalid_tag_format/parser.rb +22 -0
- data/lib/yard/lint/validators/warnings/invalid_tag_format/result.rb +25 -0
- data/lib/yard/lint/validators/warnings/invalid_tag_format/validator.rb +33 -0
- data/lib/yard/lint/validators/warnings/invalid_tag_format.rb +14 -0
- data/lib/yard/lint/validators/warnings/unknown_directive/config.rb +22 -0
- data/lib/yard/lint/validators/warnings/unknown_directive/parser.rb +22 -0
- data/lib/yard/lint/validators/warnings/unknown_directive/result.rb +25 -0
- data/lib/yard/lint/validators/warnings/unknown_directive/validator.rb +33 -0
- data/lib/yard/lint/validators/warnings/unknown_directive.rb +14 -0
- data/lib/yard/lint/validators/warnings/unknown_parameter_name/config.rb +22 -0
- data/lib/yard/lint/validators/warnings/unknown_parameter_name/parser.rb +22 -0
- data/lib/yard/lint/validators/warnings/unknown_parameter_name/result.rb +25 -0
- data/lib/yard/lint/validators/warnings/unknown_parameter_name/validator.rb +33 -0
- data/lib/yard/lint/validators/warnings/unknown_parameter_name.rb +14 -0
- data/lib/yard/lint/validators/warnings/unknown_tag/config.rb +22 -0
- data/lib/yard/lint/validators/warnings/unknown_tag/parser.rb +24 -0
- data/lib/yard/lint/validators/warnings/unknown_tag/result.rb +25 -0
- data/lib/yard/lint/validators/warnings/unknown_tag/validator.rb +33 -0
- data/lib/yard/lint/validators/warnings/unknown_tag.rb +14 -0
- data/lib/yard/lint/version.rb +8 -0
- data/lib/yard/lint.rb +76 -0
- data/lib/yard-lint.rb +11 -0
- data/renovate.json +22 -0
- metadata +178 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Yard
|
|
4
|
+
module Lint
|
|
5
|
+
module Validators
|
|
6
|
+
module Warnings
|
|
7
|
+
module InvalidTagFormat
|
|
8
|
+
# Runs YARD stats command to check for invalidtagformat
|
|
9
|
+
class Validator < Base
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
# Runs YARD stats command with proper settings on a given dir and files
|
|
13
|
+
# @param dir [String] dir where we should generate the temp docs
|
|
14
|
+
# @param escaped_file_names [String] files for which we want to run YARD stats
|
|
15
|
+
# @return [Hash] shell command execution hash results
|
|
16
|
+
def yard_cmd(dir, escaped_file_names)
|
|
17
|
+
cmd = <<~CMD
|
|
18
|
+
yard stats \
|
|
19
|
+
#{shell_arguments} \
|
|
20
|
+
--compact \
|
|
21
|
+
-b #{Shellwords.escape(dir)} \
|
|
22
|
+
#{escaped_file_names}
|
|
23
|
+
CMD
|
|
24
|
+
cmd = cmd.tr("\n", ' ')
|
|
25
|
+
|
|
26
|
+
shell(cmd)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Yard
|
|
4
|
+
module Lint
|
|
5
|
+
module Validators
|
|
6
|
+
# Validators for checking YARD warnings
|
|
7
|
+
module Warnings
|
|
8
|
+
# Validator for detecting unknown directives
|
|
9
|
+
module UnknownDirective
|
|
10
|
+
# Configuration for UnknownDirective validator
|
|
11
|
+
class Config < ::Yard::Lint::Validators::Config
|
|
12
|
+
self.id = :unknown_directive
|
|
13
|
+
self.defaults = {
|
|
14
|
+
'Enabled' => true,
|
|
15
|
+
'Severity' => 'error'
|
|
16
|
+
}.freeze
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Yard
|
|
4
|
+
module Lint
|
|
5
|
+
module Validators
|
|
6
|
+
module Warnings
|
|
7
|
+
module UnknownDirective
|
|
8
|
+
# Parser for UnknownDirective warnings
|
|
9
|
+
class Parser < ::Yard::Lint::Parsers::OneLineBase
|
|
10
|
+
# Set of regexps for detecting warnings reported by YARD stats
|
|
11
|
+
self.regexps = {
|
|
12
|
+
general: /^\[warn\]: Unknown directive.*@!.*near line/,
|
|
13
|
+
message: /\[warn\]: (.*) in file/,
|
|
14
|
+
location: /in file `(.*)`/,
|
|
15
|
+
line: /line (\d*)/
|
|
16
|
+
}.freeze
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Yard
|
|
4
|
+
module Lint
|
|
5
|
+
module Validators
|
|
6
|
+
module Warnings
|
|
7
|
+
module UnknownDirective
|
|
8
|
+
# Result object for UnknownDirective validation
|
|
9
|
+
class Result < Results::Base
|
|
10
|
+
self.default_severity = 'error'
|
|
11
|
+
self.offense_type = 'line'
|
|
12
|
+
self.offense_name = 'UnknownDirective'
|
|
13
|
+
|
|
14
|
+
# Build human-readable message for UnknownDirective offense
|
|
15
|
+
# @param offense [Hash] offense data with :message key
|
|
16
|
+
# @return [String] formatted message
|
|
17
|
+
def build_message(offense)
|
|
18
|
+
offense[:message] || 'UnknownDirective detected'
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Yard
|
|
4
|
+
module Lint
|
|
5
|
+
module Validators
|
|
6
|
+
module Warnings
|
|
7
|
+
module UnknownDirective
|
|
8
|
+
# Runs YARD stats command to check for unknowndirective
|
|
9
|
+
class Validator < Base
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
# Runs YARD stats command with proper settings on a given dir and files
|
|
13
|
+
# @param dir [String] dir where we should generate the temp docs
|
|
14
|
+
# @param escaped_file_names [String] files for which we want to run YARD stats
|
|
15
|
+
# @return [Hash] shell command execution hash results
|
|
16
|
+
def yard_cmd(dir, escaped_file_names)
|
|
17
|
+
cmd = <<~CMD
|
|
18
|
+
yard stats \
|
|
19
|
+
#{shell_arguments} \
|
|
20
|
+
--compact \
|
|
21
|
+
-b #{Shellwords.escape(dir)} \
|
|
22
|
+
#{escaped_file_names}
|
|
23
|
+
CMD
|
|
24
|
+
cmd = cmd.tr("\n", ' ')
|
|
25
|
+
|
|
26
|
+
shell(cmd)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Yard
|
|
4
|
+
module Lint
|
|
5
|
+
module Validators
|
|
6
|
+
# Validators for checking YARD warnings
|
|
7
|
+
module Warnings
|
|
8
|
+
# Validator for detecting unknown parameter names in @param tags
|
|
9
|
+
module UnknownParameterName
|
|
10
|
+
# Configuration for UnknownParameterName validator
|
|
11
|
+
class Config < ::Yard::Lint::Validators::Config
|
|
12
|
+
self.id = :unknown_parameter_name
|
|
13
|
+
self.defaults = {
|
|
14
|
+
'Enabled' => true,
|
|
15
|
+
'Severity' => 'error'
|
|
16
|
+
}.freeze
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Yard
|
|
4
|
+
module Lint
|
|
5
|
+
module Validators
|
|
6
|
+
module Warnings
|
|
7
|
+
module UnknownParameterName
|
|
8
|
+
# Parser for UnknownParameterName warnings
|
|
9
|
+
class Parser < ::Yard::Lint::Parsers::TwoLineBase
|
|
10
|
+
# Set of regexps for detecting warnings reported by YARD stats
|
|
11
|
+
self.regexps = {
|
|
12
|
+
general: /^\[warn\]: @param tag has unknown parameter name/,
|
|
13
|
+
message: /\[warn\]: (.*)$/,
|
|
14
|
+
location: /in file `(.*?)'\?\s*near/,
|
|
15
|
+
line: /near line (\d+)/
|
|
16
|
+
}.freeze
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Yard
|
|
4
|
+
module Lint
|
|
5
|
+
module Validators
|
|
6
|
+
module Warnings
|
|
7
|
+
module UnknownParameterName
|
|
8
|
+
# Result object for UnknownParameterName validation
|
|
9
|
+
class Result < Results::Base
|
|
10
|
+
self.default_severity = 'error'
|
|
11
|
+
self.offense_type = 'line'
|
|
12
|
+
self.offense_name = 'UnknownParameterName'
|
|
13
|
+
|
|
14
|
+
# Build human-readable message for UnknownParameterName offense
|
|
15
|
+
# @param offense [Hash] offense data with :message key
|
|
16
|
+
# @return [String] formatted message
|
|
17
|
+
def build_message(offense)
|
|
18
|
+
offense[:message] || 'UnknownParameterName detected'
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Yard
|
|
4
|
+
module Lint
|
|
5
|
+
module Validators
|
|
6
|
+
module Warnings
|
|
7
|
+
module UnknownParameterName
|
|
8
|
+
# Runs YARD stats command to check for unknownparametername
|
|
9
|
+
class Validator < Base
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
# Runs YARD stats command with proper settings on a given dir and files
|
|
13
|
+
# @param dir [String] dir where we should generate the temp docs
|
|
14
|
+
# @param escaped_file_names [String] files for which we want to run YARD stats
|
|
15
|
+
# @return [Hash] shell command execution hash results
|
|
16
|
+
def yard_cmd(dir, escaped_file_names)
|
|
17
|
+
cmd = <<~CMD
|
|
18
|
+
yard stats \
|
|
19
|
+
#{shell_arguments} \
|
|
20
|
+
--compact \
|
|
21
|
+
-b #{Shellwords.escape(dir)} \
|
|
22
|
+
#{escaped_file_names}
|
|
23
|
+
CMD
|
|
24
|
+
cmd = cmd.tr("\n", ' ')
|
|
25
|
+
|
|
26
|
+
shell(cmd)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Yard
|
|
4
|
+
module Lint
|
|
5
|
+
module Validators
|
|
6
|
+
# Validators for checking YARD warnings
|
|
7
|
+
module Warnings
|
|
8
|
+
# Validator for detecting unknown tags in documentation
|
|
9
|
+
module UnknownTag
|
|
10
|
+
# Configuration for UnknownTag validator
|
|
11
|
+
class Config < ::Yard::Lint::Validators::Config
|
|
12
|
+
self.id = :unknown_tag
|
|
13
|
+
self.defaults = {
|
|
14
|
+
'Enabled' => true,
|
|
15
|
+
'Severity' => 'error'
|
|
16
|
+
}.freeze
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Yard
|
|
4
|
+
module Lint
|
|
5
|
+
module Validators
|
|
6
|
+
module Warnings
|
|
7
|
+
module UnknownTag
|
|
8
|
+
# Parser used to extract warnings details that are related to yard unknown tags
|
|
9
|
+
# @example
|
|
10
|
+
# [warn]: Unknown tag @example1 in file `/builds/path/engine.rb` near line 32
|
|
11
|
+
class Parser < ::Yard::Lint::Parsers::OneLineBase
|
|
12
|
+
# Set of regexps for detecting warnings reported by YARD stats
|
|
13
|
+
self.regexps = {
|
|
14
|
+
general: /^\[warn\]: Unknown tag.*@.*near line/,
|
|
15
|
+
message: /\[warn\]: (.*) in file/,
|
|
16
|
+
location: /in file `(.*)`/,
|
|
17
|
+
line: /line (\d*)/
|
|
18
|
+
}.freeze
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Yard
|
|
4
|
+
module Lint
|
|
5
|
+
module Validators
|
|
6
|
+
module Warnings
|
|
7
|
+
module UnknownTag
|
|
8
|
+
# Result object for unknown YARD tags validation
|
|
9
|
+
class Result < Results::Base
|
|
10
|
+
self.default_severity = 'error'
|
|
11
|
+
self.offense_type = 'line'
|
|
12
|
+
self.offense_name = 'UnknownTag'
|
|
13
|
+
|
|
14
|
+
# Build human-readable message for unknown tag offense
|
|
15
|
+
# @param offense [Hash] offense data with :message key
|
|
16
|
+
# @return [String] formatted message
|
|
17
|
+
def build_message(offense)
|
|
18
|
+
offense[:message] || 'Unknown tag detected'
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Yard
|
|
4
|
+
module Lint
|
|
5
|
+
module Validators
|
|
6
|
+
module Warnings
|
|
7
|
+
module UnknownTag
|
|
8
|
+
# Runs YARD stats command to check for unknown YARD tags
|
|
9
|
+
class Validator < Base
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
# Runs YARD stats command with proper settings on a given dir and files
|
|
13
|
+
# @param dir [String] dir where we should generate the temp docs
|
|
14
|
+
# @param escaped_file_names [String] files for which we want to run YARD stats
|
|
15
|
+
# @return [Hash] shell command execution hash results
|
|
16
|
+
def yard_cmd(dir, escaped_file_names)
|
|
17
|
+
cmd = <<~CMD
|
|
18
|
+
yard stats \
|
|
19
|
+
#{shell_arguments} \
|
|
20
|
+
--compact \
|
|
21
|
+
-b #{Shellwords.escape(dir)} \
|
|
22
|
+
#{escaped_file_names}
|
|
23
|
+
CMD
|
|
24
|
+
cmd = cmd.tr("\n", ' ')
|
|
25
|
+
|
|
26
|
+
shell(cmd)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
data/lib/yard/lint.rb
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'yaml'
|
|
4
|
+
require 'shellwords'
|
|
5
|
+
require 'open3'
|
|
6
|
+
require 'tmpdir'
|
|
7
|
+
require 'digest'
|
|
8
|
+
require 'net/http'
|
|
9
|
+
require 'uri'
|
|
10
|
+
|
|
11
|
+
module Yard
|
|
12
|
+
# YARD Lint module providing linting functionality for YARD documentation
|
|
13
|
+
module Lint
|
|
14
|
+
class << self
|
|
15
|
+
# Main entry point for running YARD lint
|
|
16
|
+
# @param path [String, Array<String>] file or glob pattern to check
|
|
17
|
+
# @param config [Yard::Lint::Config, nil] configuration object
|
|
18
|
+
# @param config_file [String, nil] path to config file
|
|
19
|
+
# (auto-loads .yard-lint.yml if not specified)
|
|
20
|
+
# @param progress [Boolean] show progress indicator (default: true for TTY)
|
|
21
|
+
# @return [Yard::Lint::Result] result object with offenses
|
|
22
|
+
def run(path:, config: nil, config_file: nil, progress: nil)
|
|
23
|
+
config ||= load_config(config_file)
|
|
24
|
+
files = expand_path(path, config)
|
|
25
|
+
runner = Runner.new(files, config)
|
|
26
|
+
|
|
27
|
+
# Enable progress by default if output is a TTY
|
|
28
|
+
show_progress = progress.nil? ? $stdout.tty? : progress
|
|
29
|
+
runner.progress_formatter = Formatters::Progress.new if show_progress
|
|
30
|
+
|
|
31
|
+
runner.run
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
# Load configuration from file or auto-detect
|
|
37
|
+
# @param config_file [String, nil] path to config file
|
|
38
|
+
# @return [Yard::Lint::Config] configuration object
|
|
39
|
+
def load_config(config_file)
|
|
40
|
+
if config_file
|
|
41
|
+
Config.from_file(config_file)
|
|
42
|
+
else
|
|
43
|
+
Config.load || Config.new
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Expand path/glob patterns into an array of files
|
|
48
|
+
# @param path [String, Array<String>] path or array of paths
|
|
49
|
+
# @param config [Yard::Lint::Config] configuration object
|
|
50
|
+
# @return [Array<String>] array of absolute file paths
|
|
51
|
+
def expand_path(path, config)
|
|
52
|
+
files = Array(path).flat_map do |p|
|
|
53
|
+
if p.include?('*')
|
|
54
|
+
Dir.glob(p)
|
|
55
|
+
elsif File.directory?(p)
|
|
56
|
+
Dir.glob(File.join(p, '**/*.rb'))
|
|
57
|
+
else
|
|
58
|
+
p
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
files = files.select { |f| File.file?(f) && f.end_with?('.rb') }
|
|
63
|
+
|
|
64
|
+
# Convert to absolute paths for YARD
|
|
65
|
+
files = files.map { |f| File.expand_path(f) }
|
|
66
|
+
|
|
67
|
+
# Filter out excluded files
|
|
68
|
+
files.reject do |file|
|
|
69
|
+
config.exclude.any? do |pattern|
|
|
70
|
+
File.fnmatch(pattern, file, File::FNM_PATHNAME | File::FNM_EXTGLOB)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
data/lib/yard-lint.rb
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'zeitwerk'
|
|
4
|
+
|
|
5
|
+
# Setup Zeitwerk loader for gem
|
|
6
|
+
loader = Zeitwerk::Loader.for_gem(warn_on_extra_files: false)
|
|
7
|
+
loader.ignore(__FILE__)
|
|
8
|
+
loader.setup
|
|
9
|
+
|
|
10
|
+
# Manually load the main module since it contains class-level methods
|
|
11
|
+
require_relative 'yard/lint'
|
data/renovate.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
|
3
|
+
"extends": [
|
|
4
|
+
"config:recommended"
|
|
5
|
+
],
|
|
6
|
+
"github-actions": {
|
|
7
|
+
"enabled": true,
|
|
8
|
+
"pinDigests": true
|
|
9
|
+
},
|
|
10
|
+
"includePaths": [
|
|
11
|
+
"Gemfile",
|
|
12
|
+
"yard-lint.gemspec"
|
|
13
|
+
],
|
|
14
|
+
"packageRules": [
|
|
15
|
+
{
|
|
16
|
+
"matchManagers": [
|
|
17
|
+
"github-actions"
|
|
18
|
+
],
|
|
19
|
+
"minimumReleaseAge": "7 days"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|