diff options
author | Austin Ziegler <austin@zieglers.ca> | 2021-12-23 10:43:29 -0500 |
---|---|---|
committer | Austin Ziegler <austin@zieglers.ca> | 2022-07-04 20:26:09 -0400 |
commit | 106d1749c965b8af857c976197814707b66cbef0 (patch) | |
tree | a888b76791ab6ffc32c147b97fbaa0c8661f5f74 | |
parent | 3062997fbbe19cb6099a65a5dbcd0aba7b9b17c7 (diff) | |
download | diff-lcs-106d1749c965b8af857c976197814707b66cbef0.tar.gz |
Fix issues reported by fasterer
-rw-r--r-- | .fasterer.yml | 5 | ||||
-rw-r--r-- | Gemfile | 8 | ||||
-rw-r--r-- | lib/diff/lcs.rb | 2 | ||||
-rw-r--r-- | lib/diff/lcs/hunk.rb | 2 | ||||
-rw-r--r-- | spec/spec_helper.rb | 4 |
5 files changed, 11 insertions, 10 deletions
diff --git a/.fasterer.yml b/.fasterer.yml index 821e02d..eef484f 100644 --- a/.fasterer.yml +++ b/.fasterer.yml @@ -1,4 +1,3 @@ exclude_paths: - - lib/diff/lcs.rb # sort_vs_sort_by on priority_compare - - Rakefile # each_with_index vs while - - spec/spec_helper.rb + - research/**/* + - pkg/**/* @@ -11,10 +11,14 @@ if RUBY_VERSION < '1.9' gem 'rdoc', '< 4' gem 'ruby-debug' -elsif RUBY_VERSION >= '2.0' +end + +if RUBY_VERSION >= '2.0' + gem 'standardrb' + gem 'fasterer' + if RUBY_ENGINE == 'ruby' gem 'simplecov', '~> 0.18' - gem 'byebug' end end diff --git a/lib/diff/lcs.rb b/lib/diff/lcs.rb index 288cfc2..234fd03 100644 --- a/lib/diff/lcs.rb +++ b/lib/diff/lcs.rb @@ -145,7 +145,7 @@ class << Diff::LCS matches = Diff::LCS::Internals.lcs(seq1, seq2) ret = [] string = seq1.kind_of? String - matches.each_with_index do |_e, i| + matches.each_index do |i| next if matches[i].nil? v = string ? seq1[i, 1] : seq1[i] diff --git a/lib/diff/lcs/hunk.rb b/lib/diff/lcs/hunk.rb index 49b520e..d27b024 100644 --- a/lib/diff/lcs/hunk.rb +++ b/lib/diff/lcs/hunk.rb @@ -22,7 +22,7 @@ class Diff::LCS::Hunk 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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 41e1f8e..79c4e45 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -355,9 +355,7 @@ module Diff::LCS::SpecHelper matcher :correctly_map_sequence do |s1| match do |actual| - actual.each_with_index { |ee, ii| - expect(ee).to be_nil_or_match_values(ii, s1, @s2) - } + actual.each_index { |ii| expect(actual[ii]).to be_nil_or_match_values(ii, s1, @s2) } end chain :to_other_sequence do |s2| |