diff options
author | Markus Roberts <Markus@reality.com> | 2010-07-09 18:06:33 -0700 |
---|---|---|
committer | Markus Roberts <Markus@reality.com> | 2010-07-09 18:06:33 -0700 |
commit | 8d1fbe4586c91682cdda0cb271649e918fd9778b (patch) | |
tree | 314508ca21830874d9e4ec6e27880fede14193bd /lib/puppet/indirector/node | |
parent | 889158ad57e33df083613d6f7d136b2e11aaa16a (diff) | |
download | puppet-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/indirector/node')
-rw-r--r-- | lib/puppet/indirector/node/exec.rb | 4 | ||||
-rw-r--r-- | lib/puppet/indirector/node/ldap.rb | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/puppet/indirector/node/exec.rb b/lib/puppet/indirector/node/exec.rb index cac515f59..f458ba4c7 100644 --- a/lib/puppet/indirector/node/exec.rb +++ b/lib/puppet/indirector/node/exec.rb @@ -19,7 +19,7 @@ class Puppet::Node::Exec < Puppet::Indirector::Exec # Translate the output to ruby. result = translate(request.key, output) - return create_node(request.key, result) + create_node(request.key, result) end private @@ -36,7 +36,7 @@ class Puppet::Node::Exec < Puppet::Indirector::Exec end node.fact_merge - return node + node end # Translate the yaml string into Ruby objects. diff --git a/lib/puppet/indirector/node/ldap.rb b/lib/puppet/indirector/node/ldap.rb index 2ca44c3d6..c6f17d0bf 100644 --- a/lib/puppet/indirector/node/ldap.rb +++ b/lib/puppet/indirector/node/ldap.rb @@ -43,7 +43,7 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap end info = name2hash('default',name_env,'parent') - return info + info end # Look for our node in ldap. @@ -68,7 +68,7 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap end end - return node + node end # Find more than one node. LAK:NOTE This is a bit of a clumsy API, because the 'search' @@ -251,7 +251,7 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap parent = find_and_merge_parent(parent, info) end - return info + info end def get_classes_from_entry(entry) |