Class: Yard::Lint::Validators::Documentation::BlankLineBeforeDefinition::MessagesBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/yard/lint/validators/documentation/blank_line_before_definition/messages_builder.rb

Overview

Builds human-readable messages for blank line before definition violations

Constant Summary collapse

ERROR_DESCRIPTIONS =

Maps violation types to human-readable descriptions

{
  'single' => 'Blank line between documentation and definition',
  'orphaned' => 'Documentation is orphaned (YARD ignores it due to blank lines)'
}.freeze

Class Method Summary collapse

Class Method Details

.call(offense) ⇒ String

Formats a violation message

Parameters:

  • offense (Hash)

    the offense details

Returns:

  • (String)

    formatted message



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

def call(offense)
  type = offense[:violation_type]
  object_name = offense[:object_name]
  blank_count = offense[:blank_count]

  description = ERROR_DESCRIPTIONS[type] || 'Blank line before definition'

  if type == 'orphaned'
    "#{description} for '#{object_name}' (#{blank_count} blank lines)"
  else
    "#{description} for '#{object_name}'"
  end
end