From 2d0b50f6f37ae4707ae1b9e34a9961620654bc66 Mon Sep 17 00:00:00 2001 From: dearblue Date: Mon, 28 Jun 2021 23:21:47 +0900 Subject: Avoid warnings with `ruby -cw` ```console % for rb in `git ls-files '*/mrblib/*.rb' 'mrblib'`; do ruby30 -cw $rb > /dev/null; done mrbgems/mruby-array-ext/mrblib/array.rb:389: warning: assigned but unused variable - ary mrbgems/mruby-array-ext/mrblib/array.rb:663: warning: assigned but unused variable - len mrbgems/mruby-hash-ext/mrblib/hash.rb:119: warning: possibly useless use of a variable in void context mrbgems/mruby-hash-ext/mrblib/hash.rb:259: warning: assigned but unused variable - keys mrbgems/mruby-io/mrblib/io.rb:229: warning: literal in condition mrbgems/mruby-io/mrblib/io.rb:280: warning: literal in condition mrbgems/mruby-string-ext/mrblib/string.rb:347: warning: assigned but unused variable - len mrbgems/mruby-toplevel-ext/mrblib/toplevel.rb:2: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument ``` --- mrbgems/mruby-array-ext/mrblib/array.rb | 2 -- mrbgems/mruby-hash-ext/mrblib/hash.rb | 2 -- mrbgems/mruby-io/mrblib/io.rb | 4 ++-- mrbgems/mruby-string-ext/mrblib/string.rb | 2 -- mrbgems/mruby-toplevel-ext/mrblib/toplevel.rb | 2 +- 5 files changed, 3 insertions(+), 9 deletions(-) diff --git a/mrbgems/mruby-array-ext/mrblib/array.rb b/mrbgems/mruby-array-ext/mrblib/array.rb index 7fbb948d2..7520b932f 100644 --- a/mrbgems/mruby-array-ext/mrblib/array.rb +++ b/mrbgems/mruby-array-ext/mrblib/array.rb @@ -386,7 +386,6 @@ class Array end beg = len = 0 - ary = [] if block if arg0.nil? && arg1.nil? && arg2.nil? # ary.fill { |index| block } -> ary @@ -660,7 +659,6 @@ class Array return to_enum :keep_if unless block idx = 0 - len = self.size while idx < self.size do if block.call(self[idx]) idx += 1 diff --git a/mrbgems/mruby-hash-ext/mrblib/hash.rb b/mrbgems/mruby-hash-ext/mrblib/hash.rb index 33e2dcb9f..5775913c3 100644 --- a/mrbgems/mruby-hash-ext/mrblib/hash.rb +++ b/mrbgems/mruby-hash-ext/mrblib/hash.rb @@ -116,7 +116,6 @@ class Hash nk.each {|k| h[k] = self[k] } - h self.replace(h) end @@ -256,7 +255,6 @@ class Hash def keep_if(&block) return to_enum :keep_if unless block - keys = [] self.each do |k, v| unless block.call([k, v]) self.delete(k) diff --git a/mrbgems/mruby-io/mrblib/io.rb b/mrbgems/mruby-io/mrblib/io.rb index 645733226..006578222 100644 --- a/mrbgems/mruby-io/mrblib/io.rb +++ b/mrbgems/mruby-io/mrblib/io.rb @@ -209,7 +209,7 @@ class IO end array = [] - while 1 + while true begin _read_buf rescue EOFError @@ -256,7 +256,7 @@ class IO end array = [] - while 1 + while true begin _read_buf rescue EOFError diff --git a/mrbgems/mruby-string-ext/mrblib/string.rb b/mrbgems/mruby-string-ext/mrblib/string.rb index 84d566fda..4f533c4cd 100644 --- a/mrbgems/mruby-string-ext/mrblib/string.rb +++ b/mrbgems/mruby-string-ext/mrblib/string.rb @@ -344,8 +344,6 @@ class String end def codepoints(&block) - len = self.size - if block_given? self.split('').each do|x| block.call(x.ord) diff --git a/mrbgems/mruby-toplevel-ext/mrblib/toplevel.rb b/mrbgems/mruby-toplevel-ext/mrblib/toplevel.rb index 774562398..664008d1c 100644 --- a/mrbgems/mruby-toplevel-ext/mrblib/toplevel.rb +++ b/mrbgems/mruby-toplevel-ext/mrblib/toplevel.rb @@ -1,5 +1,5 @@ -def self.include (*modules) +def self.include(*modules) self.class.include(*modules) end -- cgit v1.2.3