[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35

Markus Roberts Markus at reality.com
Wed Jul 14 10:37:22 UTC 2010


The following commit has been merged in the upstream branch:
commit a07bbe2e711ee22a40e147c046997c8813ae3cc8
Author: Markus Roberts <Markus at reality.com>
Date:   Fri Jul 9 18:06:38 2010 -0700

    Code smell: Omit needless checks on defined
    
    * Replaced 53 occurances of
    
          defined\?\((.+?)\) (?:and|&&) \1( |$)
    
      with
    
          \1\2
    
      In code like:
    
         unless defined? @foo and @foo and bar("baz")
    
      "defined? @foo and @foo" can safely be replaced with "@foo":
    
         unless @foo and bar("baz")
    
      Because:
    
       * Both evaluate to false/nil when @foo is not defined
       * Both evaluate to @foo when @foo is defined
    
      3 Examples:
    
          The code:
              @sync = Sync.new unless defined?(@sync) and @sync
          becomes:
              @sync = Sync.new unless @sync
          The code:
              unless defined?(@content) and @content
          becomes:
              unless @content
          The code:
              raise(ArgumentError, "Already handling indirection for #{@indirection.name}; cannot also handle #{indirection}") if defined?(@indirection) and @indirection
          becomes:
              raise(ArgumentError, "Already handling indirection for #{@indirection.name}; cannot also handle #{indirection}") if @indirection
    
    * Replaced 2 occurances of
    
          defined\?\((.+?)\) (?:and|&&) ! *\1.nil\?
    
      with
    
          !\1.nil?
    
      In code like:
    
         while defined? @foo and ! @foo.nil? ...
    
      "defined? @foo and ! @foo.nil?" can safely be replaced with "! @foo.nil?":
    
         while ! @foo.nil? ...
    
      Because:
    
       * Both evaluate to false/nil when @foo is not defined
       * Both evaluate to "! @foo.nil?" when @foo is defined
    
      2 Examples:
    
          The code:
              !!(defined?(@value) and ! @value.nil?)
          becomes:
              !!(!@value.nil?)
          The code:
              self.init unless defined?(@@state) and ! @@state.nil?
          becomes:
              self.init unless !@@state.nil?

diff --git a/lib/puppet/agent.rb b/lib/puppet/agent.rb
index b860677..6682b84 100644
--- a/lib/puppet/agent.rb
+++ b/lib/puppet/agent.rb
@@ -81,7 +81,7 @@ class Puppet::Agent
     end
 
     def sync
-        @sync = Sync.new unless defined?(@sync) and @sync
+        @sync = Sync.new unless @sync
         @sync
     end
 
diff --git a/lib/puppet/file_serving/content.rb b/lib/puppet/file_serving/content.rb
index 87ef4fb..cacd908 100644
--- a/lib/puppet/file_serving/content.rb
+++ b/lib/puppet/file_serving/content.rb
@@ -35,7 +35,7 @@ class Puppet::FileServing::Content < Puppet::FileServing::Base
 
     # Read the content of our file in.
     def content
-        unless defined?(@content) and @content
+        unless @content
             # This stat can raise an exception, too.
             raise(ArgumentError, "Cannot read the contents of links unless following links") if stat().ftype == "symlink"
 
diff --git a/lib/puppet/indirector.rb b/lib/puppet/indirector.rb
index 97892d9..125445d 100644
--- a/lib/puppet/indirector.rb
+++ b/lib/puppet/indirector.rb
@@ -18,7 +18,7 @@ module Puppet::Indirector
     # evaluated at parse time, which is before the user has had a chance
     # to override it.
     def indirects(indirection, options = {})
-        raise(ArgumentError, "Already handling indirection for #{@indirection.name}; cannot also handle #{indirection}") if defined?(@indirection) and @indirection
+        raise(ArgumentError, "Already handling indirection for #{@indirection.name}; cannot also handle #{indirection}") if @indirection
         # populate this class with the various new methods
         extend ClassMethods
         include InstanceMethods
diff --git a/lib/puppet/indirector/indirection.rb b/lib/puppet/indirector/indirection.rb
index 89235f3..8eaaf26 100644
--- a/lib/puppet/indirector/indirection.rb
+++ b/lib/puppet/indirector/indirection.rb
@@ -77,7 +77,7 @@ class Puppet::Indirector::Indirection
     def doc
         text = ""
 
-        text += scrub(@doc) + "\n\n" if defined?(@doc) and @doc
+        text += scrub(@doc) + "\n\n" if @doc
 
         if s = terminus_setting()
             text += "* **Terminus Setting**: #{terminus_setting}"
diff --git a/lib/puppet/indirector/ldap.rb b/lib/puppet/indirector/ldap.rb
index 0b95b6e..3ccb21d 100644
--- a/lib/puppet/indirector/ldap.rb
+++ b/lib/puppet/indirector/ldap.rb
@@ -61,7 +61,7 @@ class Puppet::Indirector::Ldap < Puppet::Indirector::Terminus
 
     # Create an ldap connection.
     def connection
-        unless defined?(@connection) and @connection
+        unless @connection
             raise Puppet::Error, "Could not set up LDAP Connection: Missing ruby/ldap libraries" unless Puppet.features.ldap?
             begin
                 conn = Puppet::Util::Ldap::Connection.instance
diff --git a/lib/puppet/indirector/request.rb b/lib/puppet/indirector/request.rb
index 898722f..32494e1 100644
--- a/lib/puppet/indirector/request.rb
+++ b/lib/puppet/indirector/request.rb
@@ -21,7 +21,7 @@ class Puppet::Indirector::Request
     end
 
     def environment
-        @environment = Puppet::Node::Environment.new() unless defined?(@environment) and @environment
+        @environment = Puppet::Node::Environment.new() unless @environment
         @environment
     end
 
diff --git a/lib/puppet/network/client.rb b/lib/puppet/network/client.rb
index 6d8779f..258e577 100644
--- a/lib/puppet/network/client.rb
+++ b/lib/puppet/network/client.rb
@@ -104,7 +104,7 @@ class Puppet::Network::Client
 
     # Are we a local client?
     def local?
-        if defined?(@local) and @local
+        if @local
             true
         else
             false
diff --git a/lib/puppet/parameter.rb b/lib/puppet/parameter.rb
index c068e8e..54e71dd 100644
--- a/lib/puppet/parameter.rb
+++ b/lib/puppet/parameter.rb
@@ -90,7 +90,7 @@ class Puppet::Parameter
 
         # Is this parameter the namevar?  Defaults to false.
         def isnamevar?
-            defined?(@isnamevar) && @isnamevar
+            @isnamevar
         end
 
         # This parameter is required.
@@ -105,7 +105,7 @@ class Puppet::Parameter
 
         # Is this parameter required?  Defaults to false.
         def required?
-            defined?(@required) && @required
+            @required
         end
 
         # Verify that we got a good value
@@ -164,9 +164,9 @@ class Puppet::Parameter
 
         error = type.new(args.join(" "))
 
-        error.line = @resource.line if defined?(@resource) and @resource and @resource.line
+        error.line = @resource.line if @resource and @resource.line
 
-        error.file = @resource.file if defined?(@resource) and @resource and @resource.file
+        error.file = @resource.file if @resource and @resource.file
 
         raise error
     end
@@ -212,7 +212,7 @@ class Puppet::Parameter
     # return the full path to us, for logging and rollback; not currently
     # used
     def pathbuilder
-        if defined?(@resource) and @resource
+        if @resource
             return [@resource.pathbuilder, self.name]
         else
             return [self.name]
diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb
index baae78a..65d657b 100644
--- a/lib/puppet/parser/resource.rb
+++ b/lib/puppet/parser/resource.rb
@@ -102,7 +102,7 @@ class Puppet::Parser::Resource < Puppet::Resource
 
     # Has this resource already been finished?
     def finished?
-        defined?(@finished) and @finished
+        @finished
     end
 
     def initialize(*args)
diff --git a/lib/puppet/property/keyvalue.rb b/lib/puppet/property/keyvalue.rb
index fcd9d57..2ac87ac 100644
--- a/lib/puppet/property/keyvalue.rb
+++ b/lib/puppet/property/keyvalue.rb
@@ -50,7 +50,7 @@ module Puppet
             end
 
             def should
-                return nil unless defined?(@should) and @should
+                return nil unless @should
 
                 members = hashify(@should)
                 current = process_current_hash(retrieve)
@@ -77,7 +77,7 @@ module Puppet
             end
 
             def insync?(is)
-                return true unless defined?(@should) and @should
+                return true unless @should
 
                 return true unless is
 
diff --git a/lib/puppet/property/list.rb b/lib/puppet/property/list.rb
index fa85ac0..0433a51 100644
--- a/lib/puppet/property/list.rb
+++ b/lib/puppet/property/list.rb
@@ -36,7 +36,7 @@ module Puppet
             end
 
             def should
-                return nil unless defined?(@should) and @should
+                return nil unless @should
 
                 members = @should
                 #inclusive means we are managing everything so if it isn't in should, its gone
@@ -66,7 +66,7 @@ module Puppet
             end
 
             def insync?(is)
-                return true unless defined?(@should) and @should
+                return true unless @should
 
                 return true unless is
 
diff --git a/lib/puppet/provider/confine/variable.rb b/lib/puppet/provider/confine/variable.rb
index 66fe9b8..504c6a0 100644
--- a/lib/puppet/provider/confine/variable.rb
+++ b/lib/puppet/provider/confine/variable.rb
@@ -18,7 +18,7 @@ class Puppet::Provider::Confine::Variable < Puppet::Provider::Confine
 
     # Retrieve the value from facter
     def facter_value
-        @facter_value = ::Facter.value(name).to_s.downcase unless defined?(@facter_value) and @facter_value
+        @facter_value = ::Facter.value(name).to_s.downcase unless @facter_value
         @facter_value
     end
 
diff --git a/lib/puppet/provider/naginator.rb b/lib/puppet/provider/naginator.rb
index 75337f2..1006a4c 100644
--- a/lib/puppet/provider/naginator.rb
+++ b/lib/puppet/provider/naginator.rb
@@ -10,7 +10,7 @@ class Puppet::Provider::Naginator < Puppet::Provider::ParsedFile
     NAME_STRING = "## --PUPPET_NAME-- (called '_naginator_name' in the manifest)"
     # Retrieve the associated class from Nagios::Base.
     def self.nagios_type
-        unless defined?(@nagios_type) and @nagios_type
+        unless @nagios_type
             name = resource_type.name.to_s.sub(/^nagios_/, '')
             unless @nagios_type = Nagios::Base.type(name.to_sym)
                 raise Puppet::DevError, "Could not find nagios type '#{name}'"
diff --git a/lib/puppet/provider/service/daemontools.rb b/lib/puppet/provider/service/daemontools.rb
index 934e96a..7a584a1 100644
--- a/lib/puppet/provider/service/daemontools.rb
+++ b/lib/puppet/provider/service/daemontools.rb
@@ -46,7 +46,7 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do
 
         # Determine the daemon path.
         def defpath(dummy_argument=:work_arround_for_ruby_GC_bug)
-            unless defined?(@defpath) and @defpath
+            unless @defpath
                 ["/var/lib/service", "/etc"].each do |path|
                     if FileTest.exist?(path)
                         @defpath = path
@@ -87,7 +87,7 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do
 
     # find the service dir on this node
     def servicedir
-        unless defined?(@servicedir) and @servicedir
+        unless @servicedir
             ["/service", "/etc/service","/var/lib/svscan"].each do |path|
                 if FileTest.exist?(path)
                     @servicedir = path
diff --git a/lib/puppet/provider/service/runit.rb b/lib/puppet/provider/service/runit.rb
index 26c8954..c2603c9 100644
--- a/lib/puppet/provider/service/runit.rb
+++ b/lib/puppet/provider/service/runit.rb
@@ -39,7 +39,7 @@ Puppet::Type.type(:service).provide :runit, :parent => :daemontools do
         # this is necessary to autodetect a valid resource
         # default path, since there is no standard for such directory.
         def defpath(dummy_argument=:work_arround_for_ruby_GC_bug)
-            unless defined?(@defpath) and @defpath
+            unless @defpath
                 ["/etc/sv", "/var/lib/service"].each do |path|
                     if FileTest.exist?(path)
                         @defpath = path
@@ -54,7 +54,7 @@ Puppet::Type.type(:service).provide :runit, :parent => :daemontools do
 
     # find the service dir on this node
     def servicedir
-        unless defined?(@servicedir) and @servicedir
+        unless @servicedir
             ["/service", "/etc/service","/var/service"].each do |path|
                 if FileTest.exist?(path)
                     @servicedir = path
diff --git a/lib/puppet/resource/catalog.rb b/lib/puppet/resource/catalog.rb
index 3e69900..b5f1737 100644
--- a/lib/puppet/resource/catalog.rb
+++ b/lib/puppet/resource/catalog.rb
@@ -173,7 +173,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
         @resource_table.values.each { |resource| resource.remove } if remove_resources
         @resource_table.clear
 
-        if defined?(@relationship_graph) and @relationship_graph
+        if @relationship_graph
             @relationship_graph.clear
             @relationship_graph = nil
         end
@@ -303,7 +303,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
 
     # Create a graph of all of the relationships in our catalog.
     def relationship_graph
-        unless defined?(@relationship_graph) and @relationship_graph
+        unless @relationship_graph
             # It's important that we assign the graph immediately, because
             # the debug messages below use the relationships in the
             # relationship graph to determine the path to the resources
diff --git a/lib/puppet/simple_graph.rb b/lib/puppet/simple_graph.rb
index 24f4399..18bca61 100644
--- a/lib/puppet/simple_graph.rb
+++ b/lib/puppet/simple_graph.rb
@@ -119,7 +119,7 @@ class Puppet::SimpleGraph
     def dependencies(resource)
         # Cache the reversal graph, because it's somewhat expensive
         # to create.
-        @reversal = reversal unless defined?(@reversal) and @reversal
+        @reversal = reversal unless @reversal
         # Strangely, it's significantly faster to search a reversed
         # tree in the :out direction than to search a normal tree
         # in the :in direction.
diff --git a/lib/puppet/ssl/host.rb b/lib/puppet/ssl/host.rb
index cfc40fd..ae91cea 100644
--- a/lib/puppet/ssl/host.rb
+++ b/lib/puppet/ssl/host.rb
@@ -203,7 +203,7 @@ class Puppet::SSL::Host
     # Create/return a store that uses our SSL info to validate
     # connections.
     def ssl_store(purpose = OpenSSL::X509::PURPOSE_ANY)
-        unless defined?(@ssl_store) and @ssl_store
+        unless @ssl_store
             @ssl_store = OpenSSL::X509::Store.new
             @ssl_store.purpose = purpose
 
diff --git a/lib/puppet/sslcertificates/certificate.rb b/lib/puppet/sslcertificates/certificate.rb
index 1a5c31d..92a2a7c 100644
--- a/lib/puppet/sslcertificates/certificate.rb
+++ b/lib/puppet/sslcertificates/certificate.rb
@@ -23,7 +23,7 @@ class Puppet::SSLCertificates::Certificate
             File.unlink(file) if FileTest.exists?(file)
         }
 
-        if defined?(@hash) and @hash
+        if @hash
             File.unlink(@hash) if FileTest.symlink?(@hash)
         end
     end
@@ -120,7 +120,7 @@ class Puppet::SSLCertificates::Certificate
 
     # this only works for servers, not for users
     def mkcsr
-        self.getkey unless defined?(@key) and @key
+        self.getkey unless @key
 
         name = OpenSSL::X509::Name.new self.subject
 
@@ -178,9 +178,9 @@ class Puppet::SSLCertificates::Certificate
     end
 
     def mkselfsigned
-        self.getkey unless defined?(@key) and @key
+        self.getkey unless @key
 
-        raise Puppet::Error, "Cannot replace existing certificate" if defined?(@cert) and @cert
+        raise Puppet::Error, "Cannot replace existing certificate" if @cert
 
         args = {
             :name => self.certname,
@@ -228,7 +228,7 @@ class Puppet::SSLCertificates::Certificate
         files[@cacertfile] = @cacert if defined?(@cacert)
 
         files.each { |file,thing|
-            if defined?(thing) and thing
+            if thing
                 next if FileTest.exists?(file)
 
                 text = nil
diff --git a/lib/puppet/transportable.rb b/lib/puppet/transportable.rb
index c0b3edc..b97817c 100644
--- a/lib/puppet/transportable.rb
+++ b/lib/puppet/transportable.rb
@@ -157,7 +157,7 @@ module Puppet
         # Convert to a parseable manifest
         def to_manifest
             unless self.top
-                raise Puppet::DevError, "No keyword; cannot convert to manifest" unless defined?(@keyword) and @keyword
+                raise Puppet::DevError, "No keyword; cannot convert to manifest" unless @keyword
             end
 
             str = "#{@keyword} #{@name} {\n%s\n}"
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index f84abd4..47e0151 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -572,7 +572,7 @@ class Type
         # Once an object is managed, it always stays managed; but an object
         # that is listed as unmanaged might become managed later in the process,
         # so we have to check that every time
-        if defined?(@managed) and @managed
+        if @managed
             return @managed
         else
             @managed = false
@@ -593,7 +593,7 @@ class Type
     # this is a retarded hack method to get around the difference between
     # component children and file children
     def self.depthfirst?
-        defined?(@depthfirst) && @depthfirst
+        @depthfirst
     end
 
     def depthfirst?
@@ -1328,7 +1328,7 @@ class Type
 
     # Find the default provider.
     def self.defaultprovider
-        unless defined?(@defaultprovider) and @defaultprovider
+        unless @defaultprovider
             suitable = suitableprovider()
 
             # Find which providers are a default for this system.
@@ -1824,7 +1824,7 @@ class Type
     # Retrieve the title of an object.  If no title was set separately,
     # then use the object's name.
     def title
-        unless defined?(@title) and @title
+        unless @title
             if self.class.validparameter?(name_var)
                 @title = self[:name]
             elsif self.class.validproperty?(name_var)
diff --git a/lib/puppet/type/cron.rb b/lib/puppet/type/cron.rb
index 9d5d2f4..856ea7c 100755
--- a/lib/puppet/type/cron.rb
+++ b/lib/puppet/type/cron.rb
@@ -54,7 +54,7 @@ Puppet::Type.newtype(:cron) do
         # We have to override the parent method, because we consume the entire
         # "should" array
         def insync?(is)
-            if defined?(@should) and @should
+            if @should
                 self.is_to_s(is) == self.should_to_s
             else
                 true
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
index a823ea9..0f1f5d8 100644
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@ -330,7 +330,7 @@ Puppet::Type.newtype(:file) do
     end
 
     def bucket
-        return @bucket if defined?(@bucket) and @bucket
+        return @bucket if @bucket
 
         backup = self[:backup]
         return nil unless backup
diff --git a/lib/puppet/type/file/mode.rb b/lib/puppet/type/file/mode.rb
index d38157b..03cb63f 100755
--- a/lib/puppet/type/file/mode.rb
+++ b/lib/puppet/type/file/mode.rb
@@ -99,7 +99,7 @@ module Puppet
 
             if stat = @resource.stat(false)
                 unless defined?(@fixed)
-                    @should = @should.collect { |s| self.dirmask(s) } if defined?(@should) and @should
+                    @should = @should.collect { |s| self.dirmask(s) } if @should
                 end
                 return stat.mode & 007777
             else
diff --git a/lib/puppet/util/cacher.rb b/lib/puppet/util/cacher.rb
index d229c40..8a0acc8 100644
--- a/lib/puppet/util/cacher.rb
+++ b/lib/puppet/util/cacher.rb
@@ -58,7 +58,7 @@ module Puppet::Util::Cacher
         end
 
         def attr_ttl(name)
-            return nil unless defined?(@attr_ttls) and @attr_ttls
+            return nil unless @attr_ttls
             @attr_ttls[name]
         end
 
@@ -122,7 +122,7 @@ module Puppet::Util::Cacher
         end
 
         def value_cache
-            @value_cache = {} unless defined?(@value_cache) and @value_cache
+            @value_cache = {} unless @value_cache
             @value_cache
         end
     end
diff --git a/lib/puppet/util/docs.rb b/lib/puppet/util/docs.rb
index beed4bb..d247ec0 100644
--- a/lib/puppet/util/docs.rb
+++ b/lib/puppet/util/docs.rb
@@ -22,7 +22,7 @@ module Puppet::Util::Docs
             self.send(m)
         }.join("  ")
 
-        if defined?(@doc) and @doc
+        if @doc
             @doc + extra
         else
             extra
diff --git a/lib/puppet/util/inline_docs.rb b/lib/puppet/util/inline_docs.rb
index 695b8e8..b04b40a 100644
--- a/lib/puppet/util/inline_docs.rb
+++ b/lib/puppet/util/inline_docs.rb
@@ -15,7 +15,7 @@ module Puppet::Util::InlineDocs
         attr_writer :doc
 
         def doc
-            @doc = "" unless defined?(@doc) and @doc
+            @doc = "" unless @doc
             @doc
         end
 
diff --git a/lib/puppet/util/ldap/generator.rb b/lib/puppet/util/ldap/generator.rb
index fb49151..2320c20 100644
--- a/lib/puppet/util/ldap/generator.rb
+++ b/lib/puppet/util/ldap/generator.rb
@@ -30,7 +30,7 @@ class Puppet::Util::Ldap::Generator
     end
 
     def source
-        if defined?(@source) and @source
+        if @source
             @source.to_s
         else
             nil
diff --git a/lib/puppet/util/ldap/manager.rb b/lib/puppet/util/ldap/manager.rb
index b1048a1..3e3c545 100644
--- a/lib/puppet/util/ldap/manager.rb
+++ b/lib/puppet/util/ldap/manager.rb
@@ -46,7 +46,7 @@ class Puppet::Util::Ldap::Manager
     def connect
         raise ArgumentError, "You must pass a block to #connect" unless block_given?
 
-        unless defined?(@connection) and @connection
+        unless @connection
             if Puppet[:ldaptls]
                 ssl = :tls
             elsif Puppet[:ldapssl]
diff --git a/lib/puppet/util/settings/file_setting.rb b/lib/puppet/util/settings/file_setting.rb
index 351a1ae..ee17d7d 100644
--- a/lib/puppet/util/settings/file_setting.rb
+++ b/lib/puppet/util/settings/file_setting.rb
@@ -23,7 +23,7 @@ class Puppet::Util::Settings::FileSetting < Puppet::Util::Settings::Setting
     end
 
     def group
-        return unless defined?(@group) && @group
+        return unless @group
         @settings[:group]
     end
 
@@ -36,7 +36,7 @@ class Puppet::Util::Settings::FileSetting < Puppet::Util::Settings::Setting
     end
 
     def owner
-        return unless defined?(@owner) && @owner
+        return unless @owner
         return "root" if @owner == "root" or ! use_service_user?
         @settings[:user]
     end
diff --git a/lib/puppet/util/settings/setting.rb b/lib/puppet/util/settings/setting.rb
index ba7e4b5..a14dcf0 100644
--- a/lib/puppet/util/settings/setting.rb
+++ b/lib/puppet/util/settings/setting.rb
@@ -50,11 +50,11 @@ class Puppet::Util::Settings::Setting
     end
 
     def iscreated?
-        defined?(@iscreated) && @iscreated
+        @iscreated
     end
 
     def set?
-        !!(defined?(@value) and ! @value.nil?)
+        !!(!@value.nil?)
     end
 
     # short name for the celement
@@ -68,7 +68,7 @@ class Puppet::Util::Settings::Setting
         str = @desc.gsub(/^/, "# ") + "\n"
 
         # Add in a statement about the default.
-        str += "# The default value is '#{@default}'.\n" if defined?(@default) and @default
+        str += "# The default value is '#{@default}'.\n" if @default
 
         # If the value has not been overridden, then print it out commented
         # and unconverted, so it's clear that that's the default and how it
diff --git a/lib/puppet/util/storage.rb b/lib/puppet/util/storage.rb
index f821c8f..6927092 100644
--- a/lib/puppet/util/storage.rb
+++ b/lib/puppet/util/storage.rb
@@ -47,7 +47,7 @@ class Puppet::Util::Storage
         Puppet.settings.use(:main) unless FileTest.directory?(Puppet[:statedir])
 
         unless File.exists?(Puppet[:statefile])
-            self.init unless defined?(@@state) and ! @@state.nil?
+            self.init unless !@@state.nil?
             return
         end
         unless File.file?(Puppet[:statefile])
diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb
index 22e7a3b..46d5573 100755
--- a/test/lib/puppettest.rb
+++ b/test/lib/puppettest.rb
@@ -251,7 +251,7 @@ module PuppetTest
     end
 
     def tmpdir
-        unless defined?(@tmpdir) and @tmpdir
+        unless @tmpdir
             @tmpdir = case Facter["operatingsystem"].value
                 when "Darwin"; "/private/tmp"
                 when "SunOS"; "/var/tmp"
diff --git a/test/lib/puppettest/parsertesting.rb b/test/lib/puppettest/parsertesting.rb
index 1165773..3935322 100644
--- a/test/lib/puppettest/parsertesting.rb
+++ b/test/lib/puppettest/parsertesting.rb
@@ -12,7 +12,7 @@ module PuppetTest::ParserTesting
         attr_writer :evaluate
 
         def evaluated?
-            defined?(@evaluated) and @evaluated
+            @evaluated
         end
 
         def evaluate(*args)
diff --git a/test/ral/type/user.rb b/test/ral/type/user.rb
index fd5dcd1..26cf7b1 100755
--- a/test/ral/type/user.rb
+++ b/test/ral/type/user.rb
@@ -27,7 +27,7 @@ class TestUser < Test::Unit::TestCase
         end
 
         def exists?
-            if defined?(@ensure) and @ensure == :present
+            if @ensure == :present
                 true
             else
                 false

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list