summaryrefslogtreecommitdiffstats
path: root/test/other
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-07-09 18:06:33 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-09 18:06:33 -0700
commit8d1fbe4586c91682cdda0cb271649e918fd9778b (patch)
tree314508ca21830874d9e4ec6e27880fede14193bd /test/other
parent889158ad57e33df083613d6f7d136b2e11aaa16a (diff)
downloadpuppet-8d1fbe4586c91682cdda0cb271649e918fd9778b.tar.gz
puppet-8d1fbe4586c91682cdda0cb271649e918fd9778b.tar.xz
puppet-8d1fbe4586c91682cdda0cb271649e918fd9778b.zip
Code smell: Avoid explicit returns
Replaced 583 occurances of (DEF) (LINES) return (.*) end with 3 Examples: The code: def consolidate_failures(failed) filters = Hash.new { |h,k| h[k] = [] } failed.each do |spec, failed_trace| if f = test_files_for(failed).find { |f| failed_trace =~ Regexp.new(f) } filters[f] << spec break end end return filters end becomes: def consolidate_failures(failed) filters = Hash.new { |h,k| h[k] = [] } failed.each do |spec, failed_trace| if f = test_files_for(failed).find { |f| failed_trace =~ Regexp.new(f) } filters[f] << spec break end end filters end The code: def retrieve return_value = super return_value = return_value[0] if return_value && return_value.is_a?(Array) return return_value end becomes: def retrieve return_value = super return_value = return_value[0] if return_value && return_value.is_a?(Array) return_value end The code: def fake_fstab os = Facter['operatingsystem'] if os == "Solaris" name = "solaris.fstab" elsif os == "FreeBSD" name = "freebsd.fstab" else # Catchall for other fstabs name = "linux.fstab" end oldpath = @provider_class.default_target return fakefile(File::join("data/types/mount", name)) end becomes: def fake_fstab os = Facter['operatingsystem'] if os == "Solaris" name = "solaris.fstab" elsif os == "FreeBSD" name = "freebsd.fstab" else # Catchall for other fstabs name = "linux.fstab" end oldpath = @provider_class.default_target fakefile(File::join("data/types/mount", name)) end
Diffstat (limited to 'test/other')
-rwxr-xr-xtest/other/provider.rb2
-rwxr-xr-xtest/other/report.rb2
-rwxr-xr-xtest/other/transactions.rb4
3 files changed, 4 insertions, 4 deletions
diff --git a/test/other/provider.rb b/test/other/provider.rb
index e746a330a..341c364f4 100755
--- a/test/other/provider.rb
+++ b/test/other/provider.rb
@@ -30,7 +30,7 @@ class TestImpl < Test::Unit::TestCase
assert_nothing_raised("Could not create provider") do
provider = type.provide(name) {}
end
- return provider
+ provider
end
def test_provider_default
diff --git a/test/other/report.rb b/test/other/report.rb
index b5cbec0c3..d15fb5505 100755
--- a/test/other/report.rb
+++ b/test/other/report.rb
@@ -38,7 +38,7 @@ class TestReports < Test::Unit::TestCase
report = Puppet::Transaction::Report.new
trans.add_metrics_to_report(report)
- return report
+ report
end
# Make sure we can use reports as log destinations.
diff --git a/test/other/transactions.rb b/test/other/transactions.rb
index fa4fa4f61..dd5348e33 100755
--- a/test/other/transactions.rb
+++ b/test/other/transactions.rb
@@ -51,7 +51,7 @@ class TestTransactions < Test::Unit::TestCase
Puppet::Type.rmtype(:generator)
end
- return type
+ type
end
# Create a new type that generates instances with shorter names.
@@ -70,7 +70,7 @@ class TestTransactions < Test::Unit::TestCase
type.class_eval(&block) if block
- return type
+ type
end
def test_prefetch