summaryrefslogtreecommitdiffstats
path: root/lib/puppet/rails
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 /lib/puppet/rails
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 'lib/puppet/rails')
-rw-r--r--lib/puppet/rails/host.rb8
-rw-r--r--lib/puppet/rails/resource.rb6
2 files changed, 7 insertions, 7 deletions
diff --git a/lib/puppet/rails/host.rb b/lib/puppet/rails/host.rb
index 7a3fe75bc..854df2bd4 100644
--- a/lib/puppet/rails/host.rb
+++ b/lib/puppet/rails/host.rb
@@ -78,7 +78,7 @@ class Puppet::Rails::Host < ActiveRecord::Base
# This only runs if time debugging is enabled.
write_benchmarks
- return host
+ host
end
# Return the value of a fact.
@@ -238,7 +238,7 @@ class Puppet::Rails::Host < ActiveRecord::Base
db_resource.save
- return db_resource
+ db_resource
end
@@ -256,7 +256,7 @@ class Puppet::Rails::Host < ActiveRecord::Base
end
log_accumulated_marks "Resource merger"
- return additions
+ additions
end
def remove_unneeded_resources(compiled, existing)
@@ -284,7 +284,7 @@ class Puppet::Rails::Host < ActiveRecord::Base
# dependent objects get removed, too.
Puppet::Rails::Resource.destroy(deletions) unless deletions.empty?
- return resources
+ resources
end
def find_resources_parameters(resources)
diff --git a/lib/puppet/rails/resource.rb b/lib/puppet/rails/resource.rb
index 3b2e78b3a..46b49ba1b 100644
--- a/lib/puppet/rails/resource.rb
+++ b/lib/puppet/rails/resource.rb
@@ -48,7 +48,7 @@ class Puppet::Rails::Resource < ActiveRecord::Base
end
def file
- return (f = self.source_file) ? f.filename : nil
+ (f = self.source_file) ? f.filename : nil
end
def file=(file)
@@ -84,7 +84,7 @@ class Puppet::Rails::Resource < ActiveRecord::Base
end
def [](param)
- return super || parameter(param)
+ super || parameter(param)
end
# Make sure this resource is equivalent to the provided Parser resource.
@@ -226,6 +226,6 @@ class Puppet::Rails::Resource < ActiveRecord::Base
# Store the ID, so we can check if we're re-collecting the same resource.
obj.rails_id = self.id
- return obj
+ obj
end
end