diff options
author | Austin Ziegler <austin@zieglers.ca> | 2021-12-23 10:50:34 -0500 |
---|---|---|
committer | Austin Ziegler <austin@zieglers.ca> | 2022-07-04 20:26:10 -0400 |
commit | 089f932537a540af9c27dd03caf30eff6b4a0306 (patch) | |
tree | 9107279885b3650b5c655840ea690c24c9683852 | |
parent | cb9bebb30477e815cdbe8f8460f227f0940599a1 (diff) | |
download | diff-lcs-089f932537a540af9c27dd03caf30eff6b4a0306.tar.gz |
standardrb --only Layout/ExtraSpacing --fix and ignore
-rw-r--r-- | lib/diff/lcs/htmldiff.rb | 6 | ||||
-rw-r--r-- | lib/diff/lcs/hunk.rb | 8 | ||||
-rw-r--r-- | lib/diff/lcs/internals.rb | 2 | ||||
-rw-r--r-- | lib/diff/lcs/ldiff.rb | 6 | ||||
-rw-r--r-- | spec/change_spec.rb | 52 | ||||
-rw-r--r-- | spec/hunk_spec.rb | 4 | ||||
-rw-r--r-- | spec/sdiff_spec.rb | 2 | ||||
-rw-r--r-- | spec/spec_helper.rb | 10 | ||||
-rw-r--r-- | spec/traverse_balanced_spec.rb | 2 |
9 files changed, 51 insertions, 41 deletions
diff --git a/lib/diff/lcs/htmldiff.rb b/lib/diff/lcs/htmldiff.rb index 41858d5..a66c9ed 100644 --- a/lib/diff/lcs/htmldiff.rb +++ b/lib/diff/lcs/htmldiff.rb @@ -88,9 +88,9 @@ h1 { margin-left: 2em; } CSS def initialize(left, right, options = nil) - @left = left - @right = right - @options = options + @left = left + @right = right + @options = options @options = DEFAULT_OPTIONS.dup if @options.nil? end diff --git a/lib/diff/lcs/hunk.rb b/lib/diff/lcs/hunk.rb index 2a9645d..3e4133d 100644 --- a/lib/diff/lcs/hunk.rb +++ b/lib/diff/lcs/hunk.rb @@ -54,8 +54,8 @@ class Diff::LCS::Hunk @start_old = a1 || (b1 - before) @start_new = b1 || (a1 + before) - @end_old = a2 || (b2 - after) - @end_new = b2 || (a2 + after) + @end_old = a2 || (b2 - after) + @end_new = b2 || (a2 + after) self.flag_context = flag_context end @@ -183,7 +183,7 @@ class Diff::LCS::Hunk @blocks.each do |block| block.remove.each do |item| - op = item.action.to_s # - + op = item.action.to_s # - offset = item.position - lo + num_added outlist[offset][0, 1] = encode(op) num_removed += 1 @@ -195,7 +195,7 @@ class Diff::LCS::Hunk end block.insert.each do |item| - op = item.action.to_s # + + op = item.action.to_s # + offset = item.position - @start_new + num_removed outlist[offset, 0] = encode(op) + @data_new[item.position].chomp num_added += 1 diff --git a/lib/diff/lcs/internals.rb b/lib/diff/lcs/internals.rb index 2ed713f..0454c8a 100644 --- a/lib/diff/lcs/internals.rb +++ b/lib/diff/lcs/internals.rb @@ -63,7 +63,7 @@ class << Diff::LCS::Internals b_matches = position_hash(b, b_start..b_finish) thresh = [] - links = [] + links = [] string = a.kind_of?(String) (a_start..a_finish).each do |i| diff --git a/lib/diff/lcs/ldiff.rb b/lib/diff/lcs/ldiff.rb index c4a60d0..2cbd704 100644 --- a/lib/diff/lcs/ldiff.rb +++ b/lib/diff/lcs/ldiff.rb @@ -34,14 +34,14 @@ class << Diff::LCS::Ldiff "Displays a context diff with LINES lines", "of context. Default 3 lines." ) do |ctx| @format = :context - @lines = ctx || 3 + @lines = ctx || 3 end o.on( "-u", "-U", "--unified [LINES]", Integer, "Displays a unified diff with LINES lines", "of context. Default 3 lines." ) do |ctx| @format = :unified - @lines = ctx || 3 + @lines = ctx || 3 end o.on("-e", "Creates an 'ed' script to change", "oldfile to newfile.") do |_ctx| @format = :ed @@ -81,7 +81,7 @@ class << Diff::LCS::Ldiff # Defaults are for old-style diff @format ||= :old - @lines ||= 0 + @lines ||= 0 file_old, file_new = *ARGV diff --git a/spec/change_spec.rb b/spec/change_spec.rb index 237f621..42533ae 100644 --- a/spec/change_spec.rb +++ b/spec/change_spec.rb @@ -5,62 +5,62 @@ require "spec_helper" describe Diff::LCS::Change do describe "an add" do subject { described_class.new("+", 0, "element") } - it { should_not be_deleting } - it { should be_adding } - it { should_not be_unchanged } - it { should_not be_changed } + it { should_not be_deleting } + it { should be_adding } + it { should_not be_unchanged } + it { should_not be_changed } it { should_not be_finished_a } it { should_not be_finished_b } end describe "a delete" do subject { described_class.new("-", 0, "element") } - it { should be_deleting } - it { should_not be_adding } - it { should_not be_unchanged } - it { should_not be_changed } + it { should be_deleting } + it { should_not be_adding } + it { should_not be_unchanged } + it { should_not be_changed } it { should_not be_finished_a } it { should_not be_finished_b } end describe "an unchanged" do subject { described_class.new("=", 0, "element") } - it { should_not be_deleting } - it { should_not be_adding } - it { should be_unchanged } - it { should_not be_changed } + it { should_not be_deleting } + it { should_not be_adding } + it { should be_unchanged } + it { should_not be_changed } it { should_not be_finished_a } it { should_not be_finished_b } end describe "a changed" do subject { described_class.new("!", 0, "element") } - it { should_not be_deleting } - it { should_not be_adding } - it { should_not be_unchanged } - it { should be_changed } + it { should_not be_deleting } + it { should_not be_adding } + it { should_not be_unchanged } + it { should be_changed } it { should_not be_finished_a } it { should_not be_finished_b } end describe "a finished_a" do subject { described_class.new(">", 0, "element") } - it { should_not be_deleting } - it { should_not be_adding } - it { should_not be_unchanged } - it { should_not be_changed } - it { should be_finished_a } + it { should_not be_deleting } + it { should_not be_adding } + it { should_not be_unchanged } + it { should_not be_changed } + it { should be_finished_a } it { should_not be_finished_b } end describe "a finished_b" do subject { described_class.new("<", 0, "element") } - it { should_not be_deleting } - it { should_not be_adding } - it { should_not be_unchanged } - it { should_not be_changed } + it { should_not be_deleting } + it { should_not be_adding } + it { should_not be_unchanged } + it { should_not be_changed } it { should_not be_finished_a } - it { should be_finished_b } + it { should be_finished_b } end describe "as array" do diff --git a/spec/hunk_spec.rb b/spec/hunk_spec.rb index 339f4ab..c52a6fd 100644 --- a/spec/hunk_spec.rb +++ b/spec/hunk_spec.rb @@ -8,8 +8,8 @@ if String.method_defined?(:encoding) describe Diff::LCS::Hunk do let(:old_data) { ["Tu a un carté avec {count} itéms".encode("UTF-16LE")] } let(:new_data) { ["Tu a un carte avec {count} items".encode("UTF-16LE")] } - let(:pieces) { Diff::LCS.diff old_data, new_data } - let(:hunk) { Diff::LCS::Hunk.new(old_data, new_data, pieces[0], 3, 0) } + let(:pieces) { Diff::LCS.diff old_data, new_data } + let(:hunk) { Diff::LCS::Hunk.new(old_data, new_data, pieces[0], 3, 0) } it "produces a unified diff from the two pieces" do expected = <<-EXPECTED.gsub(/^\s+/, "").encode("UTF-16LE").chomp diff --git a/spec/sdiff_spec.rb b/spec/sdiff_spec.rb index 9750519..aded301 100644 --- a/spec/sdiff_spec.rb +++ b/spec/sdiff_spec.rb @@ -27,6 +27,7 @@ describe "Diff::LCS.sdiff" do let(:s1) { %w[abc def yyy xxx ghi jkl] } let(:s2) { %w[abc dxf xxx ghi jkl] } let(:result) { + # standard:disable Layout/ExtraSpacing [ ["=", [0, "abc"], [0, "abc"]], ["!", [1, "def"], [1, "dxf"]], @@ -35,6 +36,7 @@ describe "Diff::LCS.sdiff" do ["=", [4, "ghi"], [3, "ghi"]], ["=", [5, "jkl"], [4, "jkl"]] ] + # standard:enable Layout/ExtraSpacing } it_has_behavior "compare sequences correctly" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index af5ec23..55a7773 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -32,8 +32,8 @@ if ENV["COVERAGE"] end end -file = Pathname.new(__FILE__).expand_path -path = file.parent +file = Pathname.new(__FILE__).expand_path +path = file.parent parent = path.parent $:.unshift parent.join("lib") @@ -107,6 +107,7 @@ module Diff::LCS::SpecHelper end def correct_forward_diff + # standard:disable Layout/ExtraSpacing [ [ ["-", 0, "a"] @@ -129,9 +130,11 @@ module Diff::LCS::SpecHelper ["+", 11, "t"] ] ] + # standard:enable Layout/ExtraSpacing end def correct_backward_diff + # standard:disable Layout/ExtraSpacing [ [ ["+", 0, "a"] @@ -154,9 +157,11 @@ module Diff::LCS::SpecHelper ["-", 11, "t"] ] ] + # standard:enable Layout/ExtraSpacing end def correct_forward_sdiff + # standard:disable Layout/ExtraSpacing [ ["-", [0, "a"], [0, nil]], ["=", [1, "b"], [0, "b"]], @@ -172,6 +177,7 @@ module Diff::LCS::SpecHelper ["!", [9, "p"], [10, "s"]], ["+", [10, nil], [11, "t"]] ] + # standard:enable Layout/ExtraSpacing end def reverse_sdiff(forward_sdiff) diff --git a/spec/traverse_balanced_spec.rb b/spec/traverse_balanced_spec.rb index 4956acf..3a3f677 100644 --- a/spec/traverse_balanced_spec.rb +++ b/spec/traverse_balanced_spec.rb @@ -272,6 +272,7 @@ describe "Diff::LCS.traverse_balanced" do describe "strings %q(abcd efgh ijkl mnopqrstuvwxyz) & %q()" do s1 = "abcd efgh ijkl mnopqrstuvwxyz" s2 = "" + # standard:disable Layout/ExtraSpacing result = [ ["<", 0, 0], ["<", 1, 0], @@ -303,6 +304,7 @@ describe "Diff::LCS.traverse_balanced" do ["<", 27, 0], ["<", 28, 0] ] + # standard:enable Layout/ExtraSpacing it_has_behavior "with a #change callback", s1, s2, result it_has_behavior "without a #change callback", s1, s2, result |