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/util/ldap | |
| 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/util/ldap')
| -rw-r--r-- | lib/puppet/util/ldap/generator.rb | 4 | ||||
| -rw-r--r-- | lib/puppet/util/ldap/manager.rb | 10 |
2 files changed, 7 insertions, 7 deletions
diff --git a/lib/puppet/util/ldap/generator.rb b/lib/puppet/util/ldap/generator.rb index 2a868b0d9..fb4915100 100644 --- a/lib/puppet/util/ldap/generator.rb +++ b/lib/puppet/util/ldap/generator.rb @@ -7,7 +7,7 @@ class Puppet::Util::Ldap::Generator # Declare the attribute we'll use to generate the value. def from(source) @source = source - return self + self end # Actually do the generation. @@ -40,6 +40,6 @@ class Puppet::Util::Ldap::Generator # Provide the code that does the generation. def with(&block) @generator = block - return self + self end end diff --git a/lib/puppet/util/ldap/manager.rb b/lib/puppet/util/ldap/manager.rb index 93e8baac3..b1048a1a3 100644 --- a/lib/puppet/util/ldap/manager.rb +++ b/lib/puppet/util/ldap/manager.rb @@ -9,13 +9,13 @@ class Puppet::Util::Ldap::Manager # A null-op that just returns the config. def and - return self + self end # Set the offset from the search base and return the config. def at(location) @location = location - return self + self end # The basic search base. @@ -69,7 +69,7 @@ class Puppet::Util::Ldap::Manager ensure @connection.close end - return nil + nil end # Convert the name to a dn, then pass the args along to @@ -160,7 +160,7 @@ class Puppet::Util::Ldap::Manager # Specify what classes this provider models. def manages(*classes) @objectclasses = classes - return self + self end # Specify the attribute map. Assumes the keys are the puppet @@ -173,7 +173,7 @@ class Puppet::Util::Ldap::Manager # and the ldap attributes as the keys. @ldap2puppet = attributes.inject({}) { |map, ary| map[ary[1]] = ary[0]; map } - return self + self end # Return the ldap name for a puppet attribute. |
