Skip to content

Commit

Permalink
Rubocop autocorrected: Style/RedundantReturn
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidner committed Jun 5, 2015
1 parent 88209df commit 2698e0b
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 79 deletions.
6 changes: 0 additions & 6 deletions .rubocop.yml
Expand Up @@ -151,12 +151,6 @@ Style/Next:
Style/OpMethod:
Enabled: false

# Offense count: 73
# Cop supports --auto-correct.
# Configuration parameters: AllowMultipleReturnValues.
Style/RedundantReturn:
Enabled: false

# Offense count: 2
# Cop supports --auto-correct.
Style/RedundantSelf:
Expand Down
68 changes: 34 additions & 34 deletions src/ruby/yast/builtins.rb
Expand Up @@ -101,7 +101,7 @@ def self.foreach(object, &block)
else
Yast.y2warning(1, "foreach builtin called on wrong type #{object.class}")
end
return res
res
end

# - Returns whether the map m is empty.
Expand Down Expand Up @@ -168,7 +168,7 @@ def self.remove(object, element)
raise "Invalid type passed to remove #{object.class}"
end

return res
res
end

# - Selects a list element (deprecated, use LIST[INDEX]:DEFAULT)
Expand Down Expand Up @@ -250,39 +250,39 @@ module Float
def self.abs(value)
return nil if value.nil?

return value.abs
value.abs
end

# round upwards to integer
# @deprecated Use {::Float#ceil} instead
def self.ceil(value)
return nil if value.nil?

return value.ceil.to_f
value.ceil.to_f
end

# round downwards to integer
# @deprecated Use {::Float#floor} instead
def self.floor(value)
return nil if value.nil?

return value.floor.to_f
value.floor.to_f
end

# power function
# @deprecated Use {::Float#**} instead
def self.pow(base, power)
return nil if base.nil? || power.nil?

return base ** power
base ** power
end

# round to integer, towards zero
# @deprecated Use {::Float#to_i} instead
def self.trunc(value)
return nil if value.nil?

return value.to_i.to_f
value.to_i.to_f
end
end

Expand Down Expand Up @@ -335,7 +335,7 @@ def self.contains(list, value)
def self.flatten(value)
return nil if value.nil?

return value.reduce([]) do |acc,i|
value.reduce([]) do |acc,i|
return nil if i.nil?
acc.push *Yast.deep_copy(i)
end
Expand All @@ -353,7 +353,7 @@ def self.reduce(*params, &block)
else
params.first
end
return Yast.deep_copy(list).reduce &block
Yast.deep_copy(list).reduce &block
end

# Creates new list with swaped elements at offset i1 and i2.
Expand All @@ -371,7 +371,7 @@ def self.swap(list, offset1, offset2)
if offset2 < list.size-1
res.concat list[offset2+1..-1]
end
return Yast.deep_copy(res)
Yast.deep_copy(res)
end
end

Expand All @@ -389,7 +389,7 @@ def self.listmap(list, &block)
# break stops adding to hash
end

return res
res
end

# Sort A List respecting locale
Expand All @@ -414,7 +414,7 @@ def self.merge(a1, a2)
def self.prepend(list, element)
return nil if list.nil?

return [Yast.deep_copy(element)].push *Yast.deep_copy(list)
[Yast.deep_copy(element)].push *Yast.deep_copy(list)
end

# setcontains() Yast built-in
Expand Down Expand Up @@ -465,13 +465,13 @@ def self.sublist(list, offset, length=DEF_LENGHT)
return nil if offset < 0 || offset >= list.size
return nil if length < 0 || offset+length > list.size

return Yast.deep_copy(list)[offset..offset+length-1]
Yast.deep_copy(list)[offset..offset+length-1]
end

# Converts a value to a list (deprecated, use (list)VAR).
# @deprecated not needed in ruby
def self.tolist(object)
return object.is_a?(::Array) ? object : nil
object.is_a?(::Array) ? object : nil
end

# toset() Yast built-in
Expand Down Expand Up @@ -518,13 +518,13 @@ def self.mapmap(map, &block)
# break stops adding to hash
end

return res
res
end

# Converts a value to a map.
# @deprecated not needed in ruby or use {::Hash.try_convert}
def self.tomap(object)
return object.is_a?(::Hash) ? object : nil
object.is_a?(::Hash) ? object : nil
end

###########################################################
Expand All @@ -544,15 +544,15 @@ def self.eval(object)
# Change or add an environment variable
# @deprecated use {ENV#[]}
def self.getenv(value)
return ENV[value]
ENV[value]
end

# Random number generator.
# @deprecated use {::Kernel#rand}
def self.random(max)
return nil if max.nil?

return max < 0 ? -rand(max) : rand(max)
max < 0 ? -rand(max) : rand(max)
end

# Change or add an environment variable
Expand All @@ -561,7 +561,7 @@ def self.setenv(env, value, overwrite = true)
return true if ENV.include?(env) && !overwrite

ENV[env] = value
return true
true
end

# Yast compatible way how to format string with type conversion
Expand All @@ -573,7 +573,7 @@ def self.sformat(format, *args)

return format if args.empty?

return format.gsub(/%./) do |match|
format.gsub(/%./) do |match|
case match
when "%%"
"%"
Expand Down Expand Up @@ -661,14 +661,14 @@ def self.shift_frame_number(args)
# @note do nothing now, concept is quite unclear
def self.y2useritem(*args)
# TODO implement it
return nil
nil
end

# Log an user-level addional message to the y2changes
# @note do nothing now, concept is quite unclear
def self.y2usernote(*args)
# TODO implement it
return nil
nil
end

###########################################################
Expand Down Expand Up @@ -699,7 +699,7 @@ def self.topath(object)
def self.deletechars(string, chars)
return nil if !string || !chars

return string.gsub(/[#{Regexp.escape chars}]/, "")
string.gsub(/[#{Regexp.escape chars}]/, "")
end

extend Yast::I18n
Expand Down Expand Up @@ -747,39 +747,39 @@ def self.dpgettext (domain, dirname, text)
def self.filterchars(string, chars)
return nil if string.nil? || chars.nil?

return string.gsub(/[^#{Regexp.escape chars}]/, "")
string.gsub(/[^#{Regexp.escape chars}]/, "")
end

# Searches string for the first non matching chars
# @deprecated use {::String#index} instead
def self.findfirstnotof(string, chars)
return nil if string.nil? || chars.nil?

return string.index /[^#{Regexp.escape chars}]/
string.index /[^#{Regexp.escape chars}]/
end

# Finds position of the first matching characters in string
# @deprecated use {::String#index} instead
def self.findfirstof(string, chars)
return nil if string.nil? || chars.nil?

return string.index /[#{Regexp.escape chars}]/
string.index /[#{Regexp.escape chars}]/
end

# Searches the last element of string that doesn't match
# @deprecated use {::String#rindex} instead
def self.findlastnotof(string, chars)
return nil if string.nil? || chars.nil?

return string.rindex /[^#{Regexp.escape chars}]/
string.rindex /[^#{Regexp.escape chars}]/
end

# Searches string for the last match
# @deprecated use {::String#rindex} instead
def self.findlastof(string, chars)
return nil if string.nil? || chars.nil?

return string.rindex /[#{Regexp.escape chars}]/
string.rindex /[#{Regexp.escape chars}]/
end

# issubstring() Yast built-in
Expand Down Expand Up @@ -994,15 +994,15 @@ def self.toupper(string)
def self.argsof(term)
return nil if term.nil?

return Yast.deep_copy(term.params)
Yast.deep_copy(term.params)
end

# Returns the symbol of the term TERM.
# @deprecated use {Yast::Term#value} instead
def self.symbolof(term)
return nil if term.nil?

return term.value
term.value
end

# Converts a value to a term.
Expand All @@ -1028,7 +1028,7 @@ def self.toterm(symbol, list=DEF_LENGHT)
def self.tosymbol(value)
return nil if value.nil?

return value.to_sym
value.to_sym
end

# builtins enclosed in Multiset namespace
Expand Down Expand Up @@ -1078,7 +1078,7 @@ def self.symmetric_difference(set1, set2)
unless ss2.empty?
res = res + ss2.reverse
end
return Yast.deep_copy(res.reverse)
Yast.deep_copy(res.reverse)
end

# @see http://www.sgi.com/tech/stl/set_intersection.html for details
Expand All @@ -1102,7 +1102,7 @@ def self.intersection(set1, set2)
raise "unknown value from comparison #{i1 <=> u2}"
end
end
return Yast.deep_copy(res.reverse)
Yast.deep_copy(res.reverse)
end

# @see http://www.sgi.com/tech/stl/set_union.html for details
Expand Down Expand Up @@ -1136,7 +1136,7 @@ def self.union(set1, set2)
res = res + ss2.reverse
end

return Yast.deep_copy(res.reverse)
Yast.deep_copy(res.reverse)
end

# @see http://www.sgi.com/tech/stl/set_merge.html for details
Expand Down
2 changes: 1 addition & 1 deletion src/ruby/yast/convert.rb
Expand Up @@ -90,7 +90,7 @@ def self.allowed_type(object, to)

types = [types] unless types.is_a? Array

return types.any? {|t| object.is_a? t }
types.any? {|t| object.is_a? t }
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/ruby/yast/exportable.rb
Expand Up @@ -10,7 +10,7 @@ class ExportData < OpenStruct
# It is useful only to test private methods from old Yast testsuite.
def private?
table = marshal_dump
return !!table[:private]
!!table[:private]
end
end

Expand Down

0 comments on commit 2698e0b

Please sign in to comment.