Fix warnings spy so it doesn't capture more things than necessary
This commit is contained in:
parent
76c2f6630c
commit
b028927815
|
@ -5,7 +5,6 @@ class WarningsSpy
|
|||
def initialize(filesystem)
|
||||
@warnings_file = filesystem.warnings_file
|
||||
|
||||
@recording = false
|
||||
@current_group = []
|
||||
@warning_groups = []
|
||||
end
|
||||
|
@ -27,37 +26,16 @@ class WarningsSpy
|
|||
private
|
||||
|
||||
def process_line(line)
|
||||
if backtrace_line?(line)
|
||||
unless recording?
|
||||
start_of_error = find_start_of_error
|
||||
|
||||
if start_of_error
|
||||
_, start_of_error_index = start_of_error
|
||||
@current_group = current_group[start_of_error_index..-1]
|
||||
end
|
||||
|
||||
@recording = true
|
||||
end
|
||||
else
|
||||
if recording?
|
||||
add_group(current_group)
|
||||
current_group.clear
|
||||
end
|
||||
|
||||
@recording = false
|
||||
if start_of_group?(line)
|
||||
add_group(current_group)
|
||||
current_group.clear
|
||||
end
|
||||
|
||||
current_group << line
|
||||
end
|
||||
|
||||
def find_start_of_error
|
||||
current_group.each_with_index.to_a.reverse.detect do |line, _|
|
||||
start_of_error?(line)
|
||||
end
|
||||
end
|
||||
|
||||
def start_of_error?(line)
|
||||
line =~ /^.+?:\d+:in `[^']+':/
|
||||
def start_of_group?(line)
|
||||
line =~ /^\W/
|
||||
end
|
||||
|
||||
def add_group(group)
|
||||
|
@ -71,13 +49,5 @@ class WarningsSpy
|
|||
group == group_to_be_added
|
||||
end
|
||||
end
|
||||
|
||||
def backtrace_line?(line)
|
||||
line =~ /^\s+/
|
||||
end
|
||||
|
||||
def recording?
|
||||
@recording
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue