summaryrefslogtreecommitdiffstats
path: root/lib/puppet/indirector/node
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-07-09 18:06:06 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-09 18:06:06 -0700
commit81e283b28cdd91d259e3b60687aee7ea66e9d05d (patch)
treee3c7b6e4b41cc219f75a3ae7d1294652ead6f268 /lib/puppet/indirector/node
parente8cf06336b64491a2dd7538a06651e0caaf6a48d (diff)
Code smell: Line modifiers are preferred to one-line blocks.
* Replaced 6 occurances of (while .*?) *do$ with The do is unneeded in the block header form and causes problems with the block-to-one-line transformation. 3 Examples: The code: while line = f.gets do becomes: while line = f.gets The code: while line = shadow.gets do becomes: while line = shadow.gets The code: while wrapper = zeros.pop do becomes: while wrapper = zeros.pop * Replaced 19 occurances of ((if|unless) .*?) *then$ with The then is unneeded in the block header form and causes problems with the block-to-one-line transformation. 3 Examples: The code: if f = test_files_for(failed).find { |f| failed_trace =~ Regexp.new(f) } then becomes: if f = test_files_for(failed).find { |f| failed_trace =~ Regexp.new(f) } The code: unless defined?(@spec_command) then becomes: unless defined?(@spec_command) The code: if c == ?\n then becomes: if c == ?\n * Replaced 758 occurances of ((?:if|unless|while|until) .*) (.*) end with The one-line form is preferable provided: * The condition is not used to assign a variable * The body line is not already modified * The resulting line is not too long 3 Examples: The code: if Puppet.features.libshadow? has_feature :manages_passwords end becomes: has_feature :manages_passwords if Puppet.features.libshadow? The code: unless (defined?(@current_pool) and @current_pool) @current_pool = process_zpool_data(get_pool_data) end becomes: @current_pool = process_zpool_data(get_pool_data) unless (defined?(@current_pool) and @current_pool) The code: if Puppet[:trace] puts detail.backtrace end becomes: puts detail.backtrace if Puppet[:trace]
Diffstat (limited to 'lib/puppet/indirector/node')
-rw-r--r--lib/puppet/indirector/node/exec.rb4
-rw-r--r--lib/puppet/indirector/node/ldap.rb8
2 files changed, 3 insertions, 9 deletions
diff --git a/lib/puppet/indirector/node/exec.rb b/lib/puppet/indirector/node/exec.rb
index 445059d14..cac515f59 100644
--- a/lib/puppet/indirector/node/exec.rb
+++ b/lib/puppet/indirector/node/exec.rb
@@ -8,9 +8,7 @@ class Puppet::Node::Exec < Puppet::Indirector::Exec
def command
command = Puppet[:external_nodes]
- unless command != "none"
- raise ArgumentError, "You must set the 'external_nodes' parameter to use the external node terminus"
- end
+ raise ArgumentError, "You must set the 'external_nodes' parameter to use the external node terminus" unless command != "none"
command.split
end
diff --git a/lib/puppet/indirector/node/ldap.rb b/lib/puppet/indirector/node/ldap.rb
index 4cbc97573..71bca586d 100644
--- a/lib/puppet/indirector/node/ldap.rb
+++ b/lib/puppet/indirector/node/ldap.rb
@@ -49,9 +49,7 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap
# Look for our node in ldap.
def find(request)
names = [request.key]
- if request.key.include?(".") # we assume it's an fqdn
- names << request.key.sub(/\..+/, '')
- end
+ names << request.key.sub(/\..+/, '') if request.key.include?(".") # we assume it's an fqdn
names << "default"
node = nil
@@ -248,9 +246,7 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap
# Preload the parent array with the node name.
parents = [info[:name]]
while parent
- if parents.include?(parent)
- raise ArgumentError, "Found loop in LDAP node parents; #{parent} appears twice"
- end
+ raise ArgumentError, "Found loop in LDAP node parents; #{parent} appears twice" if parents.include?(parent)
parents << parent
parent = find_and_merge_parent(parent, info)
end