Skip to content

Commit 5c75783

Browse files
committed
fix: result of running rake rubocop:autocorrect_all
1 parent 8f1e3bb commit 5c75783

34 files changed

+250
-247
lines changed

Rakefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'bundler/gem_tasks'
24
require 'English'
35

bin/command_line_test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ end
210210

211211
options = CommandLineParser.new.parse(*ARGV)
212212

213-
STDOUT.puts options.stdout if options.stdout
213+
$stdout.puts options.stdout if options.stdout
214214
warn options.stderr if options.stderr
215215
sleep options.duration unless options.duration.zero?
216216
Process.kill(options.signal, Process.pid) if options.signal

git.gemspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
$LOAD_PATH.unshift File.expand_path('lib', __dir__)
24
require 'git/version'
35

lib/git.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def self.bare(git_dir, options = {})
191191
# of the cloned local working copy or cloned repository.
192192
#
193193
def self.clone(repository_url, directory = nil, options = {})
194-
clone_to_options = options.select { |key, _value| %i[bare mirror].include?(key) }
194+
clone_to_options = options.slice(:bare, :mirror)
195195
directory ||= Git::URL.clone_to(repository_url, **clone_to_options)
196196
Base.clone(repository_url, directory, options)
197197
end

lib/git/author.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class Author
55
attr_accessor :name, :email, :date
66

77
def initialize(author_string)
8-
return unless m = /(.*?) <(.*?)> (\d+) (.*)/.match(author_string)
8+
return unless (m = /(.*?) <(.*?)> (\d+) (.*)/.match(author_string))
99

1010
@name = m[1]
1111
@email = m[2]

lib/git/base.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def self.binary_version(binary_path)
5252
raise "Failed to get git version: #{status}\n#{result}" unless status.success?
5353

5454
version = result[/\d+(\.\d+)+/]
55-
version_parts = version.split('.').collect { |i| i.to_i }
55+
version_parts = version.split('.').collect(&:to_i)
5656
version_parts.fill(0, version_parts.length...3)
5757
end
5858

@@ -67,7 +67,7 @@ def self.init(directory = '.', options = {})
6767
}
6868

6969
directory = options[:bare] ? options[:repository] : options[:working_directory]
70-
FileUtils.mkdir_p(directory) unless File.exist?(directory)
70+
FileUtils.mkdir_p(directory)
7171

7272
# TODO: this dance seems awkward: this creates a Git::Lib so we can call
7373
# init so we can create a new Git::Base which in turn (ultimately)
@@ -137,7 +137,7 @@ def self.open(working_dir, options = {})
137137
# of the opened working copy or bare repository
138138
#
139139
def initialize(options = {})
140-
if working_dir = options[:working_directory]
140+
if (working_dir = options[:working_directory])
141141
options[:repository] ||= File.join(working_dir, '.git')
142142
options[:index] ||= File.join(options[:repository], 'index')
143143
end
@@ -277,19 +277,19 @@ def set_working(work_dir, check = true)
277277

278278
# returns +true+ if the branch exists locally
279279
def is_local_branch?(branch)
280-
branch_names = branches.local.map { |b| b.name }
280+
branch_names = branches.local.map(&:name)
281281
branch_names.include?(branch)
282282
end
283283

284284
# returns +true+ if the branch exists remotely
285285
def is_remote_branch?(branch)
286-
branch_names = branches.remote.map { |b| b.name }
286+
branch_names = branches.remote.map(&:name)
287287
branch_names.include?(branch)
288288
end
289289

290290
# returns +true+ if the branch exists
291291
def is_branch?(branch)
292-
branch_names = branches.map { |b| b.name }
292+
branch_names = branches.map(&:name)
293293
branch_names.include?(branch)
294294
end
295295

@@ -874,7 +874,7 @@ def diff_path_status(objectish = 'HEAD', obj2 = nil)
874874
end
875875

876876
if File.file?(repository)
877-
repository = File.expand_path(File.read(repository)[8..-1].strip, options[:working_directory])
877+
repository = File.expand_path(File.read(repository)[8..].strip, options[:working_directory])
878878
end
879879

880880
options[:repository] = repository

lib/git/branches.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ def initialize(base)
1616
end
1717

1818
def local
19-
self.select { |b| !b.remote }
19+
reject(&:remote)
2020
end
2121

2222
def remote
23-
self.select { |b| b.remote }
23+
self.select(&:remote)
2424
end
2525

2626
# array like methods
@@ -58,7 +58,7 @@ def [](branch_name)
5858

5959
def to_s
6060
out = ''
61-
@branches.each do |_k, b|
61+
@branches.each_value do |b|
6262
out << (b.current ? '* ' : ' ') << b.to_s << "\n"
6363
end
6464
out

lib/git/command_line.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ def run(*args, normalize:, chomp:, merge:, out: nil, err: nil, chdir: nil, timeo
211211
# @api private
212212
#
213213
def build_git_cmd(args)
214-
raise ArgumentError.new('The args array can not contain an array') if args.any? { |a| a.is_a?(Array) }
214+
raise ArgumentError, 'The args array can not contain an array' if args.any? { |a| a.is_a?(Array) }
215215

216-
[binary_path, *global_opts, *args].map { |e| e.to_s }
216+
[binary_path, *global_opts, *args].map(&:to_s)
217217
end
218218

219219
# Process the result of the command and return a Git::CommandLineResult
@@ -242,8 +242,8 @@ def process_result(result, normalize, chomp, timeout)
242242
logger.debug { "stdout:\n#{processed_out.inspect}\nstderr:\n#{processed_err.inspect}" }
243243
Git::CommandLineResult.new(command, result, processed_out, processed_err).tap do |processed_result|
244244
raise Git::TimeoutError.new(processed_result, timeout) if result.timeout?
245-
raise Git::SignaledError.new(processed_result) if result.signaled?
246-
raise Git::FailedError.new(processed_result) unless result.success?
245+
raise Git::SignaledError, processed_result if result.signaled?
246+
raise Git::FailedError, processed_result unless result.success?
247247
end
248248
end
249249

@@ -258,9 +258,7 @@ def process_result(result, normalize, chomp, timeout)
258258
# @api private
259259
#
260260
def post_process_all(raw_outputs, normalize, chomp)
261-
[].tap do |result|
262-
raw_outputs.each { |raw_output| result << post_process(raw_output, normalize, chomp) }
263-
end
261+
raw_outputs.map { |raw_output| post_process(raw_output, normalize, chomp) }
264262
end
265263

266264
# Determine the output to return in the `CommandLineResult`

lib/git/diff.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ class Diff
1010

1111
def initialize(base, from = nil, to = nil)
1212
@base = base
13-
@from = from && from.to_s
14-
@to = to && to.to_s
13+
@from = from&.to_s
14+
@to = to&.to_s
1515

1616
@path = nil
1717
@full_diff_files = nil
@@ -131,21 +131,21 @@ def process_full_diff
131131
final = {}
132132
current_file = nil
133133
patch.split("\n").each do |line|
134-
if m = %r{\Adiff --git ("?)a/(.+?)\1 ("?)b/(.+?)\3\z}.match(line)
134+
if (m = %r{\Adiff --git ("?)a/(.+?)\1 ("?)b/(.+?)\3\z}.match(line))
135135
current_file = Git::EscapedPath.new(m[2]).unescape
136136
final[current_file] = defaults.merge({ patch: line, path: current_file })
137137
else
138-
if m = /^index ([0-9a-f]{4,40})\.\.([0-9a-f]{4,40})( ......)*/.match(line)
138+
if (m = /^index ([0-9a-f]{4,40})\.\.([0-9a-f]{4,40})( ......)*/.match(line))
139139
final[current_file][:src] = m[1]
140140
final[current_file][:dst] = m[2]
141141
final[current_file][:mode] = m[3].strip if m[3]
142142
end
143-
if m = /^([[:alpha:]]*?) file mode (......)/.match(line)
143+
if (m = /^([[:alpha:]]*?) file mode (......)/.match(line))
144144
final[current_file][:type] = m[1]
145145
final[current_file][:mode] = m[2]
146146
end
147147
final[current_file][:binary] = true if /^Binary files /.match(line)
148-
final[current_file][:patch] << ("\n" + line)
148+
final[current_file][:patch] << "\n#{line}"
149149
end
150150
end
151151
final.map { |e| [e[0], DiffFile.new(@base, e[1])] }

lib/git/diff_path_status.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def to_h
3737

3838
# Lazily fetches and caches the path status from the git lib.
3939
def fetch_path_status
40-
@path_status ||= @base.lib.diff_path_status(
40+
@fetch_path_status ||= @base.lib.diff_path_status(
4141
@from, @to, { path: @path_limiter }
4242
)
4343
end

0 commit comments

Comments
 (0)