From c70147ad192eb457d5116d7b5e28601a6c19d8fd Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Sat, 14 Mar 2020 22:29:23 +0100 Subject: [PATCH] Rely on implicit return statements --- lib/async/container/best.rb | 4 ++-- lib/async/container/channel.rb | 4 ++-- lib/async/container/generic.rb | 10 +++++----- lib/async/container/hybrid.rb | 2 +- lib/async/container/keyed.rb | 2 +- lib/async/container/notify/pipe.rb | 2 +- lib/async/container/notify/server.rb | 2 +- lib/async/container/notify/socket.rb | 2 +- lib/async/container/process.rb | 4 ++-- lib/async/container/thread.rb | 6 ++---- 10 files changed, 18 insertions(+), 20 deletions(-) diff --git a/lib/async/container/best.rb b/lib/async/container/best.rb index c666d81..bf3be27 100644 --- a/lib/async/container/best.rb +++ b/lib/async/container/best.rb @@ -33,9 +33,9 @@ def self.fork? def self.best_container_class if fork? - return Forked + Forked else - return Threaded + Threaded end end diff --git a/lib/async/container/channel.rb b/lib/async/container/channel.rb index baa652b..966d410 100644 --- a/lib/async/container/channel.rb +++ b/lib/async/container/channel.rb @@ -48,9 +48,9 @@ def close def receive if data = @in.gets begin - return JSON.parse(data, symbolize_names: true) + JSON.parse(data, symbolize_names: true) rescue - return {line: data} + {line: data} end end end diff --git a/lib/async/container/generic.rb b/lib/async/container/generic.rb index 69fe9fb..f9d6301 100644 --- a/lib/async/container/generic.rb +++ b/lib/async/container/generic.rb @@ -160,7 +160,7 @@ def spawn(name: nil, restart: false, key: nil, &block) # Async.logger.error(self) {$!} if $! end.resume - return true + true end def async(**options, &block) @@ -174,7 +174,7 @@ def run(count: Container.processor_count, **options, &block) spawn(**options, &block) end - return self + self end def reload @@ -188,7 +188,7 @@ def reload value.stop? && (dirty = true) end - return dirty + dirty end def mark?(key) @@ -200,7 +200,7 @@ def mark?(key) end end - return false + false end def key?(key) @@ -221,7 +221,7 @@ def insert(key, child) @state[child] = state - return state + state end # Clear the child (value) as running. diff --git a/lib/async/container/hybrid.rb b/lib/async/container/hybrid.rb index 6456de3..d5fe827 100644 --- a/lib/async/container/hybrid.rb +++ b/lib/async/container/hybrid.rb @@ -42,7 +42,7 @@ def run(count: nil, forks: nil, threads: nil, **options, &block) end end - return self + self end end end diff --git a/lib/async/container/keyed.rb b/lib/async/container/keyed.rb index ede6178..22dadd2 100644 --- a/lib/async/container/keyed.rb +++ b/lib/async/container/keyed.rb @@ -47,7 +47,7 @@ def clear! def stop? unless @marked @value.stop - return true + true end end end diff --git a/lib/async/container/notify/pipe.rb b/lib/async/container/notify/pipe.rb index 0c32c58..61e6f1a 100644 --- a/lib/async/container/notify/pipe.rb +++ b/lib/async/container/notify/pipe.rb @@ -108,7 +108,7 @@ def environment_for(arguments) arguments.unshift(environment = Hash.new) end - return environment + environment end end end diff --git a/lib/async/container/notify/server.rb b/lib/async/container/notify/server.rb index e1756d4..285bb68 100644 --- a/lib/async/container/notify/server.rb +++ b/lib/async/container/notify/server.rb @@ -52,7 +52,7 @@ def self.load(message) next [key.downcase.to_sym, value] end - return Hash[pairs] + Hash[pairs] end def self.generate_path diff --git a/lib/async/container/notify/socket.rb b/lib/async/container/notify/socket.rb index afba5dc..5d4fe12 100644 --- a/lib/async/container/notify/socket.rb +++ b/lib/async/container/notify/socket.rb @@ -59,7 +59,7 @@ def dump(message) buffer << "#{key.to_s.upcase}=#{value}\n" end - return buffer + buffer end def send(**message) diff --git a/lib/async/container/process.rb b/lib/async/container/process.rb index 53a46f1..963c2a4 100644 --- a/lib/async/container/process.rb +++ b/lib/async/container/process.rb @@ -37,7 +37,7 @@ def self.for(process) instance.name = process.name - return instance + instance end def initialize(io) @@ -156,7 +156,7 @@ def wait end end - return @status + @status end end end diff --git a/lib/async/container/thread.rb b/lib/async/container/thread.rb index d422760..bb03576 100644 --- a/lib/async/container/thread.rb +++ b/lib/async/container/thread.rb @@ -44,9 +44,7 @@ def error class Instance < Notify::Pipe def self.for(thread) - instance = self.new(thread.out) - - return instance + self.new(thread.out) end def initialize(io) @@ -148,7 +146,7 @@ def wait @waiter = nil end - return @status + @status end class Status