Class: Pedant::CheckContainsNoCarriageReturns

Inherits:
Check
  • Object
show all
Defined in:
lib/pedant/checks/contains_no_carriage_returns.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, run_checks_in_dependency_order, #skip, #warn

Constructor Details

This class inherits a constructor from Pedant::Check

Class Method Details

.requiresObject



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

def self.requires
  super + [:codes]
end

Instance Method Details

#check(file, code) ⇒ Object



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

def check(file, code)
  return unless code =~ /\r/

  report(:warn, "Carriage returns were found in #{file}.")
  warn
end

#runObject



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

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