Class: Pedant::CheckContainsNoTabs
- Inherits:
-
Check
- Object
- Check
- Pedant::CheckContainsNoTabs
show all
- Defined in:
- lib/pedant/checks/contains_no_tabs.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
.requires ⇒ Object
31
32
33
|
# File 'lib/pedant/checks/contains_no_tabs.rb', line 31
def self.requires
super + [:codes]
end
|
Instance Method Details
#check(file, code) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/pedant/checks/contains_no_tabs.rb', line 35
def check(file, code)
tab_lines = Hash.new
code.split("\n").each_with_index do |line, linenum|
tab_lines[linenum + 1] = line if line =~ /\t/
end
return if tab_lines.length == 0
report(:warn, "Tabs were found in #{file}, on these lines: #{tab_lines.keys.sort.join(', ')}")
report(:warn, "Showing up to five lines:")
tab_lines.keys.sort.first(5).each do |linenum|
report(:warn, "#{linenum}: #{tab_lines[linenum].gsub(/\t/, Rainbow(" ").background(:red))}")
end
warn
end
|
#run ⇒ Object
52
53
54
55
56
57
58
|
# File 'lib/pedant/checks/contains_no_tabs.rb', line 52
def run
pass
@kb[:codes].each { |file, code| check(file, code) }
end
|