diff options
author | Markus Roberts <Markus@reality.com> | 2010-07-09 18:07:15 -0700 |
---|---|---|
committer | Markus Roberts <Markus@reality.com> | 2010-07-09 18:07:15 -0700 |
commit | 543225970225de5697734bfaf0a6eee996802c04 (patch) | |
tree | ecc6f639c43cf1812e64f9c6ce7eacc0922b57ff /ext | |
parent | 8f15707251cdb58d53e82c4bbd332a38c2d31b4c (diff) | |
download | puppet-543225970225de5697734bfaf0a6eee996802c04.tar.gz puppet-543225970225de5697734bfaf0a6eee996802c04.tar.xz puppet-543225970225de5697734bfaf0a6eee996802c04.zip |
Code smell: Avoid needless decorations
* Replaced 704 occurances of (.*)\b([a-z_]+)\(\) with \1\2
3 Examples:
The code:
ctx = OpenSSL::SSL::SSLContext.new()
becomes:
ctx = OpenSSL::SSL::SSLContext.new
The code:
skip()
becomes:
skip
The code:
path = tempfile()
becomes:
path = tempfile
* Replaced 31 occurances of ^( *)end *#.* with \1end
3 Examples:
The code:
becomes:
The code:
end # Dir.foreach
becomes:
end
The code:
end # def
becomes:
end
Diffstat (limited to 'ext')
-rwxr-xr-x | ext/puppetlisten/puppetlisten.rb | 2 | ||||
-rwxr-xr-x | ext/puppetlisten/puppetrun.rb | 2 | ||||
-rw-r--r-- | ext/regexp_nodes/regexp_nodes.rb | 32 |
3 files changed, 18 insertions, 18 deletions
diff --git a/ext/puppetlisten/puppetlisten.rb b/ext/puppetlisten/puppetlisten.rb index d1d6e8e44..fd187c81b 100755 --- a/ext/puppetlisten/puppetlisten.rb +++ b/ext/puppetlisten/puppetlisten.rb @@ -15,7 +15,7 @@ Puppet[:config] = "/etc/puppet/puppet.conf" Puppet.parse_config # set the SSL environment -ctx = OpenSSL::SSL::SSLContext.new() +ctx = OpenSSL::SSL::SSLContext.new ctx.key = OpenSSL::PKey::RSA.new(File::read(Puppet[:hostprivkey])) ctx.cert = OpenSSL::X509::Certificate.new(File::read(Puppet[:hostcert])) ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER|OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT diff --git a/ext/puppetlisten/puppetrun.rb b/ext/puppetlisten/puppetrun.rb index 192016c8d..7aa0919cb 100755 --- a/ext/puppetlisten/puppetrun.rb +++ b/ext/puppetlisten/puppetrun.rb @@ -20,7 +20,7 @@ Puppet[:config] = "/etc/puppet/puppet.conf" Puppet.parse_config # establish the certificate -ctx = OpenSSL::SSL::SSLContext.new() +ctx = OpenSSL::SSL::SSLContext.new ctx.key = OpenSSL::PKey::RSA.new(File::read(Puppet[:hostprivkey])) ctx.cert = OpenSSL::X509::Certificate.new(File::read(Puppet[:hostcert])) ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER diff --git a/ext/regexp_nodes/regexp_nodes.rb b/ext/regexp_nodes/regexp_nodes.rb index ff851bc4a..7633e5cea 100644 --- a/ext/regexp_nodes/regexp_nodes.rb +++ b/ext/regexp_nodes/regexp_nodes.rb @@ -54,14 +54,14 @@ $LOG.level = Logger::DEBUG WORKINGDIR = Dir.pwd # This class holds all the methods for creating and accessing the properties -# of an external node. There are really only two public methods: initialize() -# and a special version of to_yaml() +# of an external node. There are really only two public methods: initialize +# and a special version of to_yaml class ExternalNode # Make these instance variables get/set-able with eponymous methods attr_accessor :classes, :parameters, :hostname - # initialize() takes three arguments: + # initialize takes three arguments: # hostname:: usually passed in via ARGV[0] but it could be anything # classdir:: directory under WORKINGDIR to look for files named after # classes @@ -78,7 +78,7 @@ class ExternalNode self.match_parameters(WORKINGDIR + "/#{parameterdir}") end - # private method called by initialize() which sanity-checks our hostname. + # private method called by initialize which sanity-checks our hostname. # good candidate for overriding in a subclass if you need different checks def parse_argv(hostname) if hostname =~ /^([-\w]+?)\.([-\w\.]+)/ # non-greedy up to the first . is hostname @@ -132,7 +132,7 @@ class ExternalNode return nil end - end # def + end # private method - takes a path to look for files, iterates through all # readable, regular files it finds, and matches this instance's @hostname @@ -146,9 +146,9 @@ class ExternalNode if matched_in_patternfile?(filepath,@hostname) @classes << patternfile.to_s $LOG.debug("Appended #{patternfile.to_s} to classes instance variable") - end # if - end # Dir.foreach - end # def + end + end + end # Parameters are handled slightly differently; we make another level of # directories to get the parameter name, then use the names of the files @@ -177,12 +177,12 @@ class ExternalNode if matched_in_patternfile?(secondlevel, @hostname) @parameters[ parametername.to_s ] = patternfile.to_s $LOG.debug("Set @parameters[#{parametername.to_s}] = #{patternfile.to_s}") - end # if - end # Dir.foreach #{filepath} - end # Dir.foreach #{fullpath} - end # def + end + end + end + end -end # Class +end # Logic for local hacks that don't fit neatly into the autoloading model can # happen as we initialize a subclass @@ -202,10 +202,10 @@ class MyExternalNode < ExternalNode @parameters[ "hostclass" ] = hostclass else $LOG.debug("hostclass couldn't figure out class from #{@hostname}") - end # if - end # def + end + end -end # Class +end # Here we begin actual execution by calling methods defined above |