Skip to content

Commit

Permalink
Fix issues reported by fasterer
Browse files Browse the repository at this point in the history
  • Loading branch information
halostatue committed Jul 5, 2022
1 parent 3062997 commit 106d174
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
5 changes: 2 additions & 3 deletions .fasterer.yml
Original file line number Diff line number Diff line change
@@ -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/**/*
8 changes: 6 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/diff/lcs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def lcs(seq1, seq2, &block) #:yields seq1[i] for each matched:
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]
Expand Down
2 changes: 1 addition & 1 deletion 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 Down
4 changes: 1 addition & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,7 @@ module Matchers

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|
Expand Down

0 comments on commit 106d174

Please sign in to comment.