Class: Yard::Lint::Validators::Documentation::UndocumentedBooleanMethods::Validator

Inherits:
Base
  • Object
show all
Defined in:
lib/yard/lint/validators/documentation/undocumented_boolean_methods/validator.rb

Overview

Runs a query that will pick all the boolean methods (ending with ?) that do not have a return type or return description documented

Instance Attribute Summary

Attributes inherited from Base

#config, #selection

Instance Method Summary collapse

Methods inherited from Base

in_process, in_process?, in_process_visibility, #initialize, validator_name

Constructor Details

This class inherits a constructor from Yard::Lint::Validators::Base

Instance Method Details

#in_process_query(object, collector) ⇒ void

This method returns an undefined value.

Execute query for a single object during in-process execution. Finds boolean methods (ending with ?) without @return tag or return types.

Parameters:

  • object (YARD::CodeObjects::Base)

    the code object to query

  • collector (Executor::ResultCollector)

    collector for output



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/yard/lint/validators/documentation/undocumented_boolean_methods/validator.rb', line 19

def in_process_query(object, collector)
  # Only check methods
  return unless object.type == :method
  # Skip aliases and implicit methods
  return if object.is_alias?
  return unless object.is_explicit?
  # Only check boolean methods (ending with ?)
  return unless object.name.to_s.end_with?('?')

  # Check if @return tag is missing or has no types
  return_tag = object.tag(:return)
  return unless return_tag.nil? || return_tag.types.to_a.empty?

  collector.puts "#{object.file}:#{object.line}: #{object.title}"
end