Class: Pedant::CheckEndsWithNewline

Inherits:
Check
  • Object
show all
Defined in:
lib/pedant/checks/ends_with_newline.rb

Instance Attribute Summary

Attributes inherited from Check

#result

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Check

all, depends, #fail, #fatal, friendly_name, inherited, #initialize, initialize!, list, #pass, provides, ready?, #report, #skip, #warn

Constructor Details

This class inherits a constructor from Pedant::Check

Class Method Details

.requiresObject



29
30
31
# File 'lib/pedant/checks/ends_with_newline.rb', line 29

def self.requires
  super + [:codes]
end

Instance Method Details

#check(file, code) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/pedant/checks/ends_with_newline.rb', line 33

def check(file, code)
  return if code[-1] == "\n"

  warn

  report(:warn, "#{file} does not end with a newline.")
end

#runObject



41
42
43
44
45
46
47
# File 'lib/pedant/checks/ends_with_newline.rb', line 41

def run
  # This check will pass by default.
  pass

  # Run this check on the code in every file.
  @kb[:codes].each { |file, code| check(file, code) }
end