Skip to content

Commit

Permalink
standardrb --only Style/StringLiteralsInInterpolation --fix and more
Browse files Browse the repository at this point in the history
  • Loading branch information
halostatue committed Jul 5, 2022
1 parent 8992d9c commit e5e7880
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions lib/diff/lcs/hunk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def initialize(data_old, data_new, piece, flag_context, file_length_difference)
end

if String.method_defined?(:encoding)
@preferred_data_encoding = data_old.fetch(0) { data_new.fetch(0) { "" } }.encoding
@preferred_data_encoding = data_old.fetch(0) { data_new.fetch(0, "") }.encoding
end

@data_old = data_old
Expand All @@ -33,7 +33,6 @@ def initialize(data_old, data_new, piece, flag_context, file_length_difference)
@file_length_difference = after # The caller must get this manually
@max_diff_size = @blocks.map { |e| e.diff_size.abs }.max


# Save the start & end of each array. If the array doesn't exist (e.g.,
# we're only adding items in this block), then figure out the line number
# based on the line number of the other file and the current difference in
Expand Down Expand Up @@ -140,7 +139,7 @@ def old_diff(_last = false)
# Calculate item number range. Old diff range is just like a context
# diff range, except the ranges are on one line with the action between
# them.
s = encode("#{context_range(:old, ',')}#{OLD_DIFF_OP_ACTION[block.op]}#{context_range(:new, ',')}\n")
s = encode("#{context_range(:old, ",")}#{OLD_DIFF_OP_ACTION[block.op]}#{context_range(:new, ",")}\n")
# If removing anything, just print out all the remove lines in the hunk
# which is just all the remove lines in the block.
unless block.remove.empty?
Expand Down Expand Up @@ -172,7 +171,7 @@ def unified_diff(last = false)
# file -- don't take removed items into account.
lo, hi, num_added, num_removed = @start_old, @end_old, 0, 0

outlist = @data_old[lo..hi].map { |e| String.new("#{encode(' ')}#{e.chomp}") }
outlist = @data_old[lo..hi].map { |e| String.new("#{encode(" ")}#{e.chomp}") }

last_block = blocks[-1]

Expand Down Expand Up @@ -212,7 +211,7 @@ def unified_diff(last = false)

def context_diff(last = false)
s = encode("***************\n")
s << encode("*** #{context_range(:old, ',', last)} ****\n")
s << encode("*** #{context_range(:old, ",", last)} ****\n")
r = context_range(:new, ",", last)

if last
Expand All @@ -226,7 +225,7 @@ def context_diff(last = false)
removes = @blocks.reject { |e| e.remove.empty? }

unless removes.empty?
outlist = @data_old[lo..hi].map { |e| String.new("#{encode(' ')}#{e.chomp}") }
outlist = @data_old[lo..hi].map { |e| String.new("#{encode(" ")}#{e.chomp}") }

last_block = removes[-1]

Expand All @@ -248,7 +247,7 @@ def context_diff(last = false)
inserts = @blocks.reject { |e| e.insert.empty? }

unless inserts.empty?
outlist = @data_new[lo..hi].map { |e| String.new("#{encode(' ')}#{e.chomp}") }
outlist = @data_new[lo..hi].map { |e| String.new("#{encode(" ")}#{e.chomp}") }

last_block = inserts[-1]

Expand All @@ -273,9 +272,9 @@ def ed_diff(format, _last = false)

s =
if format == :reverse_ed
encode("#{ED_DIFF_OP_ACTION[@blocks[0].op]}#{context_range(:old, ',')}\n")
encode("#{ED_DIFF_OP_ACTION[@blocks[0].op]}#{context_range(:old, ",")}\n")
else
encode("#{context_range(:old, ' ')}#{ED_DIFF_OP_ACTION[@blocks[0].op]}\n")
encode("#{context_range(:old, " ")}#{ED_DIFF_OP_ACTION[@blocks[0].op]}\n")
end

unless @blocks[0].insert.empty?
Expand Down

0 comments on commit e5e7880

Please sign in to comment.