diff options
Diffstat (limited to 'lib/diff/lcs')
-rw-r--r-- | lib/diff/lcs/change.rb | 4 | ||||
-rw-r--r-- | lib/diff/lcs/hunk.rb | 2 | ||||
-rw-r--r-- | lib/diff/lcs/internals.rb | 8 | ||||
-rw-r--r-- | lib/diff/lcs/ldiff.rb | 4 |
4 files changed, 9 insertions, 9 deletions
diff --git a/lib/diff/lcs/change.rb b/lib/diff/lcs/change.rb index a82f3e6..f20d804 100644 --- a/lib/diff/lcs/change.rb +++ b/lib/diff/lcs/change.rb @@ -115,8 +115,8 @@ class Diff::LCS::ContextChange < Diff::LCS::Change @action, @old_position, @old_element, @new_position, @new_element = *args fail "Invalid Change Action '#{@action}'" unless Diff::LCS::Change.valid_action?(@action) - fail "Invalid (Old) Position Type" unless @old_position.nil? or @old_position.kind_of? IntClass - fail "Invalid (New) Position Type" unless @new_position.nil? or @new_position.kind_of? IntClass + fail "Invalid (Old) Position Type" unless @old_position.nil? || @old_position.kind_of?(IntClass) + fail "Invalid (New) Position Type" unless @new_position.nil? || @new_position.kind_of?(IntClass) end def to_a diff --git a/lib/diff/lcs/hunk.rb b/lib/diff/lcs/hunk.rb index 3e4133d..eccfc7a 100644 --- a/lib/diff/lcs/hunk.rb +++ b/lib/diff/lcs/hunk.rb @@ -70,7 +70,7 @@ class Diff::LCS::Hunk attr_accessor :flag_context # rubocop:disable Layout/EmptyLinesAroundAttributeAccessor undef :flag_context= def flag_context=(context) #:nodoc: # rubocop:disable Lint/DuplicateMethods - return if context.nil? or context.zero? + return if context.nil? || context.zero? add_start = context > @start_old ? @start_old : context diff --git a/lib/diff/lcs/internals.rb b/lib/diff/lcs/internals.rb index 0454c8a..b968917 100644 --- a/lib/diff/lcs/internals.rb +++ b/lib/diff/lcs/internals.rb @@ -45,14 +45,14 @@ class << Diff::LCS::Internals vector = [] # Collect any common elements at the beginning... - while (a_start <= a_finish) and (b_start <= b_finish) and (a[a_start] == b[b_start]) + while (a_start <= a_finish) && (b_start <= b_finish) && (a[a_start] == b[b_start]) vector[a_start] = b_start a_start += 1 b_start += 1 end # Now the end... - while (a_start <= a_finish) and (b_start <= b_finish) and (a[a_finish] == b[b_finish]) + while (a_start <= a_finish) && (b_start <= b_finish) && (a[a_finish] == b[b_finish]) vector[a_finish] = b_finish a_finish -= 1 b_finish -= 1 @@ -75,7 +75,7 @@ class << Diff::LCS::Internals # it may have an optimization purpose # An attempt to remove it: https://github.com/halostatue/diff-lcs/pull/72 # Why it is reintroduced: https://github.com/halostatue/diff-lcs/issues/78 - if k and (thresh[k] > j) and (thresh[k - 1] < j) + if k && (thresh[k] > j) && (thresh[k - 1] < j) thresh[k] = j else k = replace_next_larger(thresh, j, k) @@ -251,7 +251,7 @@ enumerable as either source or destination value." # This operation preserves the sort order. def replace_next_larger(enum, value, last_index = nil) # Off the end? - if enum.empty? or (value > enum[-1]) + if enum.empty? || (value > enum[-1]) enum << value return enum.size - 1 end diff --git a/lib/diff/lcs/ldiff.rb b/lib/diff/lcs/ldiff.rb index 59625aa..1896203 100644 --- a/lib/diff/lcs/ldiff.rb +++ b/lib/diff/lcs/ldiff.rb @@ -130,7 +130,7 @@ class << Diff::LCS::Ldiff return 1 end - if (@format == :unified) or (@format == :context) + if (@format == :unified) || (@format == :context) ft = File.stat(file_old).mtime.localtime.strftime("%Y-%m-%d %H:%M:%S.000000000 %z") output << "#{char_old} #{file_old}\t#{ft}\n" ft = File.stat(file_new).mtime.localtime.strftime("%Y-%m-%d %H:%M:%S.000000000 %z") @@ -152,7 +152,7 @@ class << Diff::LCS::Ldiff file_length_difference = hunk.file_length_difference next unless oldhunk - next if @lines.positive? and hunk.merge(oldhunk) + next if @lines.positive? && hunk.merge(oldhunk) output << oldhunk.diff(@format) output << "\n" if @format == :unified |