Class: Yard::Lint::Results::Base
- Inherits:
-
Object
- Object
- Yard::Lint::Results::Base
- Defined in:
- lib/yard/lint/results/base.rb
Overview
Base class for validator-specific result objects Each validator should subclass this and set class attributes
Direct Known Subclasses
Validators::Documentation::BlankLineBeforeDefinition::Result, Validators::Documentation::EmptyCommentLine::Result, Validators::Documentation::MarkdownSyntax::Result, Validators::Documentation::MissingReturn::Result, Validators::Documentation::UndocumentedBooleanMethods::Result, Validators::Documentation::UndocumentedMethodArguments::Result, Validators::Documentation::UndocumentedObjects::Result, Validators::Documentation::UndocumentedOptions::Result, Validators::Semantic::AbstractMethods::Result, Validators::Tags::ApiTags::Result, Validators::Tags::CollectionType::Result, Validators::Tags::ExampleStyle::Result, Validators::Tags::ExampleSyntax::Result, Validators::Tags::ForbiddenTags::Result, Validators::Tags::InformalNotation::Result, Validators::Tags::InvalidTypes::Result, Validators::Tags::MeaninglessTag::Result, Validators::Tags::NonAsciiType::Result, Validators::Tags::OptionTags::Result, Validators::Tags::Order::Result, Validators::Tags::RedundantParamDescription::Result, Validators::Tags::TagGroupSeparator::Result, Validators::Tags::TagTypePosition::Result, Validators::Tags::TypeSyntax::Result, Validators::Warnings::DuplicatedParameterName::Result, Validators::Warnings::InvalidDirectiveFormat::Result, Validators::Warnings::InvalidTagFormat::Result, Validators::Warnings::UnknownDirective::Result, Validators::Warnings::UnknownParameterName::Result, Validators::Warnings::UnknownTag::Result
Class Attribute Summary collapse
-
.default_severity ⇒ String
Get the default severity level for this validator.
-
.offense_name ⇒ String
Get the offense name for this validator.
-
.offense_type ⇒ String
Get the offense type for this validator.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#offenses ⇒ Object
Returns the value of attribute offenses.
Instance Method Summary collapse
-
#count ⇒ Integer
Count of offenses.
-
#each ⇒ Array
Delegate each to offenses.
-
#empty? ⇒ Boolean
Check if there are no offenses.
-
#initialize(parsed_data, config = nil) ⇒ Base
constructor
Initialize a result object with parsed validator data.
-
#map ⇒ Array
Delegate array methods to offenses for convenience.
-
#validator_name ⇒ String
Full validator name in format ‘Category/ValidatorName’ Extracted from the class path.
Constructor Details
#initialize(parsed_data, config = nil) ⇒ Base
Initialize a result object with parsed validator data
64 65 66 67 68 |
# File 'lib/yard/lint/results/base.rb', line 64 def initialize(parsed_data, config = nil) @parsed_data = Array(parsed_data) @config = config @offenses = build_offenses end |
Class Attribute Details
.default_severity ⇒ String
Get the default severity level for this validator
27 28 29 30 |
# File 'lib/yard/lint/results/base.rb', line 27 def default_severity @default_severity || (superclass.respond_to?(:default_severity) ? superclass.default_severity : nil) end |
.offense_name ⇒ String
Get the offense name for this validator
49 50 51 52 |
# File 'lib/yard/lint/results/base.rb', line 49 def offense_name @offense_name || (superclass.respond_to?(:offense_name) ? superclass.offense_name : nil) end |
.offense_type ⇒ String
Get the offense type for this validator
38 39 40 41 |
# File 'lib/yard/lint/results/base.rb', line 38 def offense_type @offense_type || (superclass.respond_to?(:offense_type) ? superclass.offense_type : nil) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
59 60 61 |
# File 'lib/yard/lint/results/base.rb', line 59 def config @config end |
#offenses ⇒ Object
Returns the value of attribute offenses.
58 59 60 |
# File 'lib/yard/lint/results/base.rb', line 58 def offenses @offenses end |
Instance Method Details
#count ⇒ Integer
Count of offenses
72 73 74 |
# File 'lib/yard/lint/results/base.rb', line 72 def count @offenses.count end |
#each ⇒ Array
Delegate each to offenses
90 91 92 |
# File 'lib/yard/lint/results/base.rb', line 90 def each(&) @offenses.each(&) end |
#empty? ⇒ Boolean
Check if there are no offenses
78 79 80 |
# File 'lib/yard/lint/results/base.rb', line 78 def empty? @offenses.empty? end |
#map ⇒ Array
Delegate array methods to offenses for convenience
84 85 86 |
# File 'lib/yard/lint/results/base.rb', line 84 def map(&) @offenses.map(&) end |
#validator_name ⇒ String
Full validator name in format ‘Category/ValidatorName’ Extracted from the class path
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/yard/lint/results/base.rb', line 97 def validator_name # Extract from class path: Validators::Tags::Order::Result => 'Tags/Order' parts = self.class.name.split('::') validators_index = parts.index('Validators') return '' unless validators_index category = parts[validators_index + 1] name = parts[validators_index + 2] "#{category}/#{name}" end |