diff options
author | Austin Ziegler <austin@zieglers.ca> | 2021-12-23 10:58:14 -0500 |
---|---|---|
committer | Austin Ziegler <austin@zieglers.ca> | 2021-12-23 11:45:41 -0500 |
commit | 639e220ddf79c9c69af2c7d582df428a30b35c11 (patch) | |
tree | 8da12ffa8a190ff728bee7dfceb26a792bd18636 /lib | |
parent | 57b361ee64d4e43a9f0d5f5e84afd1af3e53ecae (diff) | |
download | diff-lcs-639e220ddf79c9c69af2c7d582df428a30b35c11.tar.gz |
Fix Style/AndOr
Diffstat (limited to 'lib')
-rw-r--r-- | lib/diff/lcs.rb | 16 | ||||
-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 |
5 files changed, 17 insertions, 17 deletions
diff --git a/lib/diff/lcs.rb b/lib/diff/lcs.rb index e6d817b..bd0147e 100644 --- a/lib/diff/lcs.rb +++ b/lib/diff/lcs.rb @@ -326,10 +326,10 @@ class << Diff::LCS # The last entry (if any) processed was a match. +ai+ and +bj+ point just # past the last matching lines in their sequences. - while (ai < a_size) or (bj < b_size) + while (ai < a_size) || (bj < b_size) # last A? - if ai == a_size and bj < b_size - if callbacks.respond_to?(:finished_a) and !run_finished_a + if ai == a_size && bj < b_size + if callbacks.respond_to?(:finished_a) && !run_finished_a ax = string ? seq1[-1, 1] : seq1[-1] bx = string ? seq2[bj, 1] : seq2[bj] event = Diff::LCS::ContextChange.new(">", (a_size - 1), ax, bj, bx) @@ -350,8 +350,8 @@ class << Diff::LCS end # last B? - if bj == b_size and ai < a_size - if callbacks.respond_to?(:finished_b) and !run_finished_b + if bj == b_size && ai < a_size + if callbacks.respond_to?(:finished_b) && !run_finished_b ax = string ? seq1[ai, 1] : seq1[ai] bx = string ? seq2[-1, 1] : seq2[-1] event = Diff::LCS::ContextChange.new("<", ai, ax, (b_size - 1), bx) @@ -485,7 +485,7 @@ class << Diff::LCS # Find next match indices +ma+ and +mb+ loop do ma += 1 - break unless ma < matches.size and matches[ma].nil? + break unless ma < matches.size && matches[ma].nil? end break if ma >= matches.size # end of matches? @@ -493,7 +493,7 @@ class << Diff::LCS mb = matches[ma] # Change(seq2) - while (ai < ma) or (bj < mb) + while (ai < ma) || (bj < mb) ax = string ? seq1[ai, 1] : seq1[ai] bx = string ? seq2[bj, 1] : seq2[bj] @@ -539,7 +539,7 @@ class << Diff::LCS bj += 1 end - while (ai < a_size) or (bj < b_size) + while (ai < a_size) || (bj < b_size) ax = string ? seq1[ai, 1] : seq1[ai] bx = string ? seq2[bj, 1] : seq2[bj] 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 |