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/network/handler | |
| 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/network/handler')
| -rw-r--r-- | lib/puppet/network/handler/ca.rb | 2 | ||||
| -rwxr-xr-x | lib/puppet/network/handler/filebucket.rb | 2 | ||||
| -rwxr-xr-x | lib/puppet/network/handler/fileserver.rb | 16 | ||||
| -rw-r--r-- | lib/puppet/network/handler/master.rb | 4 | ||||
| -rwxr-xr-x | lib/puppet/network/handler/runner.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/network/handler/status.rb | 2 |
6 files changed, 14 insertions, 14 deletions
diff --git a/lib/puppet/network/handler/ca.rb b/lib/puppet/network/handler/ca.rb index c72171d5d..101cf6f8e 100644 --- a/lib/puppet/network/handler/ca.rb +++ b/lib/puppet/network/handler/ca.rb @@ -55,7 +55,7 @@ class Puppet::Network::Handler } # for now, just cheat and pass a fake IP address to allowed? - return auth.allowed?(hostname, "127.1.1.1") + auth.allowed?(hostname, "127.1.1.1") end def initialize(hash = {}) diff --git a/lib/puppet/network/handler/filebucket.rb b/lib/puppet/network/handler/filebucket.rb index 13fee1661..c0693ad7a 100755 --- a/lib/puppet/network/handler/filebucket.rb +++ b/lib/puppet/network/handler/filebucket.rb @@ -28,7 +28,7 @@ class Puppet::Network::Handler # :nodoc: def addfile(contents, path, client = nil, clientip = nil) contents = Base64.decode64(contents) if client bucket = Puppet::FileBucket::File.new(contents) - return bucket.save + bucket.save end # Return the contents associated with a given md5 sum. diff --git a/lib/puppet/network/handler/fileserver.rb b/lib/puppet/network/handler/fileserver.rb index b7a0c1387..efd71223f 100755 --- a/lib/puppet/network/handler/fileserver.rb +++ b/lib/puppet/network/handler/fileserver.rb @@ -84,7 +84,7 @@ class Puppet::Network::Handler return "" end - return metadata.attributes_with_tabs + metadata.attributes_with_tabs end # Create a new fileserving module. @@ -159,7 +159,7 @@ class Puppet::Network::Handler @mounts[name] = Mount.new(name, path) @mounts[name].info "Mounted #{path}" - return @mounts[name] + @mounts[name] end # Retrieve a file from the local disk and pass it to the remote @@ -235,7 +235,7 @@ class Puppet::Network::Handler env = (node = Puppet::Node.find(hostname)) ? node.environment : nil # And use the environment to look up the module. - return (mod = Puppet::Node::Environment.new(env).module(module_name) and mod.files?) ? @mounts[MODULES].copy(mod.name, mod.file_directory) : nil + (mod = Puppet::Node::Environment.new(env).module(module_name) and mod.files?) ? @mounts[MODULES].copy(mod.name, mod.file_directory) : nil end # Read the configuration file. @@ -458,7 +458,7 @@ class Puppet::Network::Handler # If there's no relative path name, then we're serving the mount itself. return full_path unless relative_path and relative_path != "/" - return File.join(full_path, relative_path) + File.join(full_path, relative_path) end # Create out object. It must have a name. @@ -505,7 +505,7 @@ class Puppet::Network::Handler # This, ah, might be completely redundant obj[:links] = links unless obj[:links] == links - return obj + obj end # Read the contents of the file at the relative path given. @@ -602,7 +602,7 @@ class Puppet::Network::Handler result = self.clone result.path = path result.instance_variable_set(:@name, name) - return result + result end # List the contents of the relative path +relpath+ of this mount. @@ -635,7 +635,7 @@ class Puppet::Network::Handler return [["/", File.stat(abspath).ftype]] end end - return nil + nil end def reclist(abspath, recurse, ignore) @@ -659,7 +659,7 @@ class Puppet::Network::Handler [ file, stat.ftype ] end - return ary.compact + ary.compact end end diff --git a/lib/puppet/network/handler/master.rb b/lib/puppet/network/handler/master.rb index 690e7079e..6f2c238a2 100644 --- a/lib/puppet/network/handler/master.rb +++ b/lib/puppet/network/handler/master.rb @@ -23,7 +23,7 @@ class Puppet::Network::Handler # Tell a client whether there's a fresh config for it def freshness(client = nil, clientip = nil) # Always force a recompile. Newer clients shouldn't do this (as of April 2008). - return Time.now.to_i + Time.now.to_i end def initialize(hash = {}) @@ -79,7 +79,7 @@ class Puppet::Network::Handler end end - return facts + facts end # Translate our configuration appropriately for sending back to a client. diff --git a/lib/puppet/network/handler/runner.rb b/lib/puppet/network/handler/runner.rb index 4f8247214..bc1a07ac5 100755 --- a/lib/puppet/network/handler/runner.rb +++ b/lib/puppet/network/handler/runner.rb @@ -24,7 +24,7 @@ class Puppet::Network::Handler runner.run - return runner.status + runner.status end end end diff --git a/lib/puppet/network/handler/status.rb b/lib/puppet/network/handler/status.rb index fbdc7a765..fe6c23dc3 100644 --- a/lib/puppet/network/handler/status.rb +++ b/lib/puppet/network/handler/status.rb @@ -9,7 +9,7 @@ class Puppet::Network::Handler } def status(client = nil, clientip = nil) - return 1 + 1 end end end |
