Class: EagerEye::Fixers::AddIncludes
- Inherits:
-
Base
- Object
- Base
- EagerEye::Fixers::AddIncludes
show all
- Defined in:
- lib/eager_eye/fixers/add_includes.rb
Constant Summary
collapse
- ITERATION_METHODS_RE =
%w[
each map collect select find_all reject filter filter_map
flat_map find_each find_in_batches in_batches
].join("|")
- ITERATION_PATTERN =
/\.(#{ITERATION_METHODS_RE})\b/
Instance Attribute Summary
Attributes inherited from Base
#issue, #source_lines
Instance Method Summary
collapse
Methods inherited from Base
#fix, #initialize
Instance Method Details
#diff ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/eager_eye/fixers/add_includes.rb', line 18
def diff
return nil unless fixable?
idx = iteration_line_index
original_line = @source_lines[idx]
fixed_line = insert_includes(original_line)
return nil if original_line == fixed_line
{
file: issue.file_path,
line: idx + 1,
original: original_line.chomp,
fixed: fixed_line.chomp
}
end
|
#fixable? ⇒ Boolean
12
13
14
15
16
|
# File 'lib/eager_eye/fixers/add_includes.rb', line 12
def fixable?
issue.detector == :loop_association &&
!association_name.nil? &&
!iteration_line_index.nil?
end
|