<feed xmlns='http://www.w3.org/2005/Atom'>
<title>puppet.git/test/ral/manager, branch master</title>
<subtitle>Puppet repo</subtitle>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/'/>
<entry>
<title>maint: remove inaccurate copyright and license statements.</title>
<updated>2011-08-18T18:27:41+00:00</updated>
<author>
<name>Daniel Pittman</name>
<email>daniel@puppetlabs.com</email>
</author>
<published>2011-08-18T18:27:41+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/commit/?id=fd7332be5ca8ba78ff24a455fddad1713be779b5'/>
<id>fd7332be5ca8ba78ff24a455fddad1713be779b5</id>
<content type='text'>
For a while Luke, and other authors, injected a created tag, copyright
statement, and "All rights reserved" into every new file they added to the
Puppet project.

This isn't really true, and we have a global license covering the code, so
we have now stripped out all those old tags.

Signed-off-by: Daniel Pittman &lt;daniel@puppetlabs.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
For a while Luke, and other authors, injected a created tag, copyright
statement, and "All rights reserved" into every new file they added to the
Puppet project.

This isn't really true, and we have a global license covering the code, so
we have now stripped out all those old tags.

Signed-off-by: Daniel Pittman &lt;daniel@puppetlabs.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>maint: Use expand_path when requiring spec_helper or puppettest</title>
<updated>2010-12-06T20:01:18+00:00</updated>
<author>
<name>Matt Robinson</name>
<email>matt@puppetlabs.com</email>
</author>
<published>2010-12-06T20:01:18+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/commit/?id=626d7564467bdc0e9d2d385e9aa10c539d9ed175'/>
<id>626d7564467bdc0e9d2d385e9aa10c539d9ed175</id>
<content type='text'>
Doing a require to a relative path can cause files to be required more
than once when they're required from different relative paths.  If you
expand the path fully, this won't happen.  Ruby 1.9 also requires that
you use expand_path when doing these requires.

Paired-with: Jesse Wolfe
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Doing a require to a relative path can cause files to be required more
than once when they're required from different relative paths.  If you
expand the path fully, this won't happen.  Ruby 1.9 also requires that
you use expand_path when doing these requires.

Paired-with: Jesse Wolfe
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix for #4299 -- Don't require which</title>
<updated>2010-11-12T04:02:00+00:00</updated>
<author>
<name>Markus Roberts</name>
<email>Markus@reality.com</email>
</author>
<published>2010-11-04T20:53:23+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/commit/?id=b15231df5842df2ea83b779b22e6756e51bc39d0'/>
<id>b15231df5842df2ea83b779b22e6756e51bc39d0</id>
<content type='text'>
We already had an internal implementation of which hiding under an assumed
name (Puppet::Util.binary); this commit calls it out of hiding and uses it
consisantly.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We already had an internal implementation of which hiding under an assumed
name (Puppet::Util.binary); this commit calls it out of hiding and uses it
consisantly.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix for Bug #4756 - Providers no longer respect missing features</title>
<updated>2010-09-13T23:22:19+00:00</updated>
<author>
<name>James Cammarata</name>
<email>jimi@sngx.net</email>
</author>
<published>2010-09-11T15:23:38+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/commit/?id=9bdfe694bc6c60a48b45f8dd49c20c6da31445f7'/>
<id>9bdfe694bc6c60a48b45f8dd49c20c6da31445f7</id>
<content type='text'>
Restored deleted lines from type.rb and reinstated unit tests
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Restored deleted lines from type.rb and reinstated unit tests
</pre>
</div>
</content>
</entry>
<entry>
<title>Code smell: Two space indentation</title>
<updated>2010-07-10T01:12:17+00:00</updated>
<author>
<name>Markus Roberts</name>
<email>Markus@reality.com</email>
</author>
<published>2010-07-10T01:12:17+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/commit/?id=3180b9d9b2c844dade1d361326600f7001ec66dd'/>
<id>3180b9d9b2c844dade1d361326600f7001ec66dd</id>
<content type='text'>
Replaced 106806 occurances of ^( +)(.*$) with

The ruby community almost universally (i.e. everyone but Luke, Markus, and the other eleven people
who learned ruby in the 1900s) uses two-space indentation.

3 Examples:

    The code:
        end

        # Tell getopt which arguments are valid
        def test_get_getopt_args
            element = Setting.new :name =&gt; "foo", :desc =&gt; "anything", :settings =&gt; Puppet::Util::Settings.new
            assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args")

    becomes:
        end

        # Tell getopt which arguments are valid
        def test_get_getopt_args
          element = Setting.new :name =&gt; "foo", :desc =&gt; "anything", :settings =&gt; Puppet::Util::Settings.new
          assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args")

    The code:
            assert_equal(str, val)

            assert_instance_of(Float, result)

        end

        # Now test it with a passed object
    becomes:
          assert_equal(str, val)

          assert_instance_of(Float, result)

        end

        # Now test it with a passed object
    The code:
        end

        assert_nothing_raised do
            klass[:Yay] = "boo"
            klass["Cool"] = :yayness
        end

    becomes:
        end

        assert_nothing_raised do
          klass[:Yay] = "boo"
          klass["Cool"] = :yayness
        end
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Replaced 106806 occurances of ^( +)(.*$) with

The ruby community almost universally (i.e. everyone but Luke, Markus, and the other eleven people
who learned ruby in the 1900s) uses two-space indentation.

3 Examples:

    The code:
        end

        # Tell getopt which arguments are valid
        def test_get_getopt_args
            element = Setting.new :name =&gt; "foo", :desc =&gt; "anything", :settings =&gt; Puppet::Util::Settings.new
            assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args")

    becomes:
        end

        # Tell getopt which arguments are valid
        def test_get_getopt_args
          element = Setting.new :name =&gt; "foo", :desc =&gt; "anything", :settings =&gt; Puppet::Util::Settings.new
          assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args")

    The code:
            assert_equal(str, val)

            assert_instance_of(Float, result)

        end

        # Now test it with a passed object
    becomes:
          assert_equal(str, val)

          assert_instance_of(Float, result)

        end

        # Now test it with a passed object
    The code:
        end

        assert_nothing_raised do
            klass[:Yay] = "boo"
            klass["Cool"] = :yayness
        end

    becomes:
        end

        assert_nothing_raised do
          klass[:Yay] = "boo"
          klass["Cool"] = :yayness
        end
</pre>
</div>
</content>
</entry>
<entry>
<title>Code smell: Avoid needless decorations</title>
<updated>2010-07-10T01:07:15+00:00</updated>
<author>
<name>Markus Roberts</name>
<email>Markus@reality.com</email>
</author>
<published>2010-07-10T01:07:15+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/commit/?id=543225970225de5697734bfaf0a6eee996802c04'/>
<id>543225970225de5697734bfaf0a6eee996802c04</id>
<content type='text'>
* 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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* 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
</pre>
</div>
</content>
</entry>
<entry>
<title>Code smell: Don't restate results directly after assignment</title>
<updated>2010-07-10T01:06:58+00:00</updated>
<author>
<name>Markus Roberts</name>
<email>Markus@reality.com</email>
</author>
<published>2010-07-10T01:06:58+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/commit/?id=8f15707251cdb58d53e82c4bbd332a38c2d31b4c'/>
<id>8f15707251cdb58d53e82c4bbd332a38c2d31b4c</id>
<content type='text'>
Replaced 33 occurances of

        ([$@]?\w+)( +[|&amp;+-]{0,2}= .+)
        \1
    end

with

3 Examples:

    The code:
            @sync ||= Sync.new
            @sync
        end
    becomes:
            @sync ||= Sync.new
        end
    The code:
            str += "\n"
            str
        end
    becomes:
            str += "\n"
        end
    The code:
            @indirection = Puppet::Indirector::Indirection.new(self, indirection,  options)
            @indirection
        end
    becomes:
            @indirection = Puppet::Indirector::Indirection.new(self, indirection,  options)
        end
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Replaced 33 occurances of

        ([$@]?\w+)( +[|&amp;+-]{0,2}= .+)
        \1
    end

with

3 Examples:

    The code:
            @sync ||= Sync.new
            @sync
        end
    becomes:
            @sync ||= Sync.new
        end
    The code:
            str += "\n"
            str
        end
    becomes:
            str += "\n"
        end
    The code:
            @indirection = Puppet::Indirector::Indirection.new(self, indirection,  options)
            @indirection
        end
    becomes:
            @indirection = Puppet::Indirector::Indirection.new(self, indirection,  options)
        end
</pre>
</div>
</content>
</entry>
<entry>
<title>Code smell: Avoid explicit returns</title>
<updated>2010-07-10T01:06:33+00:00</updated>
<author>
<name>Markus Roberts</name>
<email>Markus@reality.com</email>
</author>
<published>2010-07-10T01:06:33+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/commit/?id=8d1fbe4586c91682cdda0cb271649e918fd9778b'/>
<id>8d1fbe4586c91682cdda0cb271649e918fd9778b</id>
<content type='text'>
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] &lt;&lt; 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] &lt;&lt; spec
                    break
                end
            end
            filters
        end
    The code:
        def retrieve
            return_value = super
            return_value = return_value[0] if return_value &amp;&amp; return_value.is_a?(Array)

            return return_value
        end
    becomes:
        def retrieve
            return_value = super
            return_value = return_value[0] if return_value &amp;&amp; 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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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] &lt;&lt; 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] &lt;&lt; spec
                    break
                end
            end
            filters
        end
    The code:
        def retrieve
            return_value = super
            return_value = return_value[0] if return_value &amp;&amp; return_value.is_a?(Array)

            return return_value
        end
    becomes:
        def retrieve
            return_value = super
            return_value = return_value[0] if return_value &amp;&amp; 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
</pre>
</div>
</content>
</entry>
<entry>
<title>Code smell: Booleans are first class values.</title>
<updated>2010-07-10T01:06:12+00:00</updated>
<author>
<name>Markus Roberts</name>
<email>Markus@reality.com</email>
</author>
<published>2010-07-10T01:06:12+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/commit/?id=889158ad57e33df083613d6f7d136b2e11aaa16a'/>
<id>889158ad57e33df083613d6f7d136b2e11aaa16a</id>
<content type='text'>
* Replaced 2 occurances of

      def (.*)
          begin
              (.*) = Integer\((.*)\)
              return \2
          rescue ArgumentError
              \2 = nil
          end
          if \2 = (.*)
              return \2
          else
              return false
          end
      end

  with

  2 Examples:

      The code:
          def validuser?(value)
              begin
                  number = Integer(value)
                  return number
              rescue ArgumentError
                  number = nil
              end
              if number = uid(value)
                  return number
              else
                  return false
              end
          end
      becomes:
          def validuser?(value)
              Integer(value) rescue uid(value) || false
          end
      The code:
          def validgroup?(value)
              begin
                  number = Integer(value)
                  return number
              rescue ArgumentError
                  number = nil
              end
              if number = gid(value)
                  return number
              else
                  return false
              end
          end
      becomes:
          def validgroup?(value)
              Integer(value) rescue gid(value) || false
          end

* Replaced 28 occurances of

      return (.*?) if (.*)
      return (.*)

  with

  3 Examples:

      The code:
          return send(options[:mode]) if [:rdoc, :trac, :markdown].include?(options[:mode])
          return other
      becomes:
          return[:rdoc, :trac, :markdown].include?(options[:mode]) ? send(options[:mode]) : other
      The code:
          return true if known_resource_types.definition(name)
          return false
      becomes:
          return(known_resource_types.definition(name) ? true : false)
      The code:
          return :rest if request.protocol == 'https'
          return Puppet::FileBucket::File.indirection.terminus_class
      becomes:
          return(request.protocol == 'https' ? :rest : Puppet::FileBucket::File.indirection.terminus_class)

* Replaced no occurances of

      return (.*?) unless (.*)
      return (.*)

  with

* Replaced 7 occurances of

      if (.*)
          (.*[^:])false
      else
          \2true
      end

  with

  3 Examples:

      The code:
          if RUBY_PLATFORM == "i386-mswin32"
              InstallOptions.ri  = false
          else
              InstallOptions.ri  = true
          end
      becomes:
          InstallOptions.ri  = RUBY_PLATFORM != "i386-mswin32"
      The code:
          if options[:references].length &gt; 1
              with_contents = false
          else
              with_contents = true
          end
      becomes:
          with_contents = options[:references].length &lt;= 1
      The code:
          if value == false or value == "" or value == :undef
              return false
          else
              return true
          end
      becomes:
          return (value != false and value != "" and value != :undef)

* Replaced 19 occurances of

      if (.*)
          (.*[^:])true
      else
          \2false
      end

  with

  3 Examples:

      The code:
          if Puppet::Util::Log.level == :debug
              return true
          else
              return false
          end
      becomes:
          return Puppet::Util::Log.level == :debug
      The code:
          if satisfies?(*features)
              return true
          else
              return false
          end
      becomes:
          return !!satisfies?(*features)
      The code:
          if self.class.parsed_auth_db.has_key?(resource[:name])
              return true
          else
              return false
          end
      becomes:
          return !!self.class.parsed_auth_db.has_key?(resource[:name])

* Replaced 1 occurance of

      if ([a-z_]) = (.*)
          (.*[^:])\1
      else
          \3(.*)
      end

  with

  1 Example:

      The code:
          if c = self.send(@subclassname, method)
              return c
          else
              return nil
          end
      becomes:
          return self.send(@subclassname, method) || nil

* Replaced 2 occurances of

      if (.*)
          (.*[^:])\1
      else
          \2false
      end

  with

  2 Examples:

      The code:
          if hash[:Local]
              @local = hash[:Local]
          else
              @local = false
          end
      becomes:
          @local = hash[:Local]
      The code:
          if hash[:Local]
              @local = hash[:Local]
          else
              @local = false
          end
      becomes:
          @local = hash[:Local]

* Replaced 10 occurances of

      if (.*)
          (.*[^:])(.*)
      else
          \2false
      end

  with

  3 Examples:

      The code:
          if defined?(@isnamevar)
              return @isnamevar
          else
              return false
          end
      becomes:
          return defined?(@isnamevar) &amp;&amp; @isnamevar
      The code:
          if defined?(@required)
              return @required
          else
              return false
          end
      becomes:
          return defined?(@required) &amp;&amp; @required
      The code:
          if number = uid(value)
              return number
          else
              return false
          end
      becomes:
          return (number = uid(value)) &amp;&amp; number

* Replaced no occurances of

      if (.*)
          (.*[^:])nil
      else
          \2(true)
      end

  with

* Replaced no occurances of

      if (.*)
          (.*[^:])true
      else
          \2nil
      end

  with

* Replaced no occurances of

      if (.*)
          (.*[^:])\1
      else
          \2nil
      end

  with

* Replaced 23 occurances of

      if (.*)
          (.*[^:])(.*)
      else
          \2nil
      end

  with

  3 Examples:

      The code:
          if node = Puppet::Node.find(hostname)
              env = node.environment
          else
              env = nil
          end
      becomes:
          env = (node = Puppet::Node.find(hostname)) ? node.environment : nil
      The code:
          if mod = Puppet::Node::Environment.new(env).module(module_name) and mod.files?
              return @mounts[MODULES].copy(mod.name, mod.file_directory)
          else
              return nil
          end
      becomes:
          return (mod = Puppet::Node::Environment.new(env).module(module_name) and mod.files?) ? @mounts[MODULES].copy(mod.name, mod.file_directory) : nil
      The code:
          if hash.include?(:CA) and hash[:CA]
              @ca = Puppet::SSLCertificates::CA.new()
          else
              @ca = nil
          end
      becomes:
          @ca = (hash.include?(:CA) and hash[:CA]) ? Puppet::SSLCertificates::CA.new() : nil
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Replaced 2 occurances of

      def (.*)
          begin
              (.*) = Integer\((.*)\)
              return \2
          rescue ArgumentError
              \2 = nil
          end
          if \2 = (.*)
              return \2
          else
              return false
          end
      end

  with

  2 Examples:

      The code:
          def validuser?(value)
              begin
                  number = Integer(value)
                  return number
              rescue ArgumentError
                  number = nil
              end
              if number = uid(value)
                  return number
              else
                  return false
              end
          end
      becomes:
          def validuser?(value)
              Integer(value) rescue uid(value) || false
          end
      The code:
          def validgroup?(value)
              begin
                  number = Integer(value)
                  return number
              rescue ArgumentError
                  number = nil
              end
              if number = gid(value)
                  return number
              else
                  return false
              end
          end
      becomes:
          def validgroup?(value)
              Integer(value) rescue gid(value) || false
          end

* Replaced 28 occurances of

      return (.*?) if (.*)
      return (.*)

  with

  3 Examples:

      The code:
          return send(options[:mode]) if [:rdoc, :trac, :markdown].include?(options[:mode])
          return other
      becomes:
          return[:rdoc, :trac, :markdown].include?(options[:mode]) ? send(options[:mode]) : other
      The code:
          return true if known_resource_types.definition(name)
          return false
      becomes:
          return(known_resource_types.definition(name) ? true : false)
      The code:
          return :rest if request.protocol == 'https'
          return Puppet::FileBucket::File.indirection.terminus_class
      becomes:
          return(request.protocol == 'https' ? :rest : Puppet::FileBucket::File.indirection.terminus_class)

* Replaced no occurances of

      return (.*?) unless (.*)
      return (.*)

  with

* Replaced 7 occurances of

      if (.*)
          (.*[^:])false
      else
          \2true
      end

  with

  3 Examples:

      The code:
          if RUBY_PLATFORM == "i386-mswin32"
              InstallOptions.ri  = false
          else
              InstallOptions.ri  = true
          end
      becomes:
          InstallOptions.ri  = RUBY_PLATFORM != "i386-mswin32"
      The code:
          if options[:references].length &gt; 1
              with_contents = false
          else
              with_contents = true
          end
      becomes:
          with_contents = options[:references].length &lt;= 1
      The code:
          if value == false or value == "" or value == :undef
              return false
          else
              return true
          end
      becomes:
          return (value != false and value != "" and value != :undef)

* Replaced 19 occurances of

      if (.*)
          (.*[^:])true
      else
          \2false
      end

  with

  3 Examples:

      The code:
          if Puppet::Util::Log.level == :debug
              return true
          else
              return false
          end
      becomes:
          return Puppet::Util::Log.level == :debug
      The code:
          if satisfies?(*features)
              return true
          else
              return false
          end
      becomes:
          return !!satisfies?(*features)
      The code:
          if self.class.parsed_auth_db.has_key?(resource[:name])
              return true
          else
              return false
          end
      becomes:
          return !!self.class.parsed_auth_db.has_key?(resource[:name])

* Replaced 1 occurance of

      if ([a-z_]) = (.*)
          (.*[^:])\1
      else
          \3(.*)
      end

  with

  1 Example:

      The code:
          if c = self.send(@subclassname, method)
              return c
          else
              return nil
          end
      becomes:
          return self.send(@subclassname, method) || nil

* Replaced 2 occurances of

      if (.*)
          (.*[^:])\1
      else
          \2false
      end

  with

  2 Examples:

      The code:
          if hash[:Local]
              @local = hash[:Local]
          else
              @local = false
          end
      becomes:
          @local = hash[:Local]
      The code:
          if hash[:Local]
              @local = hash[:Local]
          else
              @local = false
          end
      becomes:
          @local = hash[:Local]

* Replaced 10 occurances of

      if (.*)
          (.*[^:])(.*)
      else
          \2false
      end

  with

  3 Examples:

      The code:
          if defined?(@isnamevar)
              return @isnamevar
          else
              return false
          end
      becomes:
          return defined?(@isnamevar) &amp;&amp; @isnamevar
      The code:
          if defined?(@required)
              return @required
          else
              return false
          end
      becomes:
          return defined?(@required) &amp;&amp; @required
      The code:
          if number = uid(value)
              return number
          else
              return false
          end
      becomes:
          return (number = uid(value)) &amp;&amp; number

* Replaced no occurances of

      if (.*)
          (.*[^:])nil
      else
          \2(true)
      end

  with

* Replaced no occurances of

      if (.*)
          (.*[^:])true
      else
          \2nil
      end

  with

* Replaced no occurances of

      if (.*)
          (.*[^:])\1
      else
          \2nil
      end

  with

* Replaced 23 occurances of

      if (.*)
          (.*[^:])(.*)
      else
          \2nil
      end

  with

  3 Examples:

      The code:
          if node = Puppet::Node.find(hostname)
              env = node.environment
          else
              env = nil
          end
      becomes:
          env = (node = Puppet::Node.find(hostname)) ? node.environment : nil
      The code:
          if mod = Puppet::Node::Environment.new(env).module(module_name) and mod.files?
              return @mounts[MODULES].copy(mod.name, mod.file_directory)
          else
              return nil
          end
      becomes:
          return (mod = Puppet::Node::Environment.new(env).module(module_name) and mod.files?) ? @mounts[MODULES].copy(mod.name, mod.file_directory) : nil
      The code:
          if hash.include?(:CA) and hash[:CA]
              @ca = Puppet::SSLCertificates::CA.new()
          else
              @ca = nil
          end
      becomes:
          @ca = (hash.include?(:CA) and hash[:CA]) ? Puppet::SSLCertificates::CA.new() : nil
</pre>
</div>
</content>
</entry>
<entry>
<title>Code smell: Use string interpolation</title>
<updated>2010-07-10T01:05:55+00:00</updated>
<author>
<name>Markus Roberts</name>
<email>Markus@reality.com</email>
</author>
<published>2010-07-10T01:05:55+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/commit/?id=e8cf06336b64491a2dd7538a06651e0caaf6a48d'/>
<id>e8cf06336b64491a2dd7538a06651e0caaf6a48d</id>
<content type='text'>
* Replaced 83 occurances of

      (.*)" *[+] *([$@]?[\w_0-9.:]+?)(.to_s\b)?(?! *[*(%\w_0-9.:{\[])

  with

      \1#{\2}"

  3 Examples:

      The code:
          puts "PUPPET " + status + ": " + process + ", " + state
      becomes:
          puts "PUPPET " + status + ": " + process + ", #{state}"
      The code:
          puts "PUPPET " + status + ": #{process}" + ", #{state}"
      becomes:
          puts "PUPPET #{status}" + ": #{process}" + ", #{state}"
      The code:
          }.compact.join( "\n" ) + "\n" + t + "]\n"
      becomes:
          }.compact.join( "\n" ) + "\n#{t}" + "]\n"

* Replaced 21 occurances of (.*)" *[+] *" with \1

  3 Examples:

      The code:
          puts "PUPPET #{status}" + ": #{process}" + ", #{state}"
      becomes:
          puts "PUPPET #{status}" + ": #{process}, #{state}"
      The code:
          puts "PUPPET #{status}" + ": #{process}, #{state}"
      becomes:
          puts "PUPPET #{status}: #{process}, #{state}"
      The code:
          res = self.class.name + ": #{@name}" + "\n"
      becomes:
          res = self.class.name + ": #{@name}\n"

* Don't use string concatenation to split lines unless they would be very long.

  Replaced 11 occurances of

      (.*)(['"]) *[+]
       *(['"])(.*)

  with

  3 Examples:

      The code:
          o.define_head "The check_puppet Nagios plug-in checks that specified " +
              "Puppet process is running and the state file is no " +
      becomes:
          o.define_head "The check_puppet Nagios plug-in checks that specified Puppet process is running and the state file is no " +
      The code:
          o.separator   "Mandatory arguments to long options are mandatory for " +
          "short options too."
      becomes:
          o.separator   "Mandatory arguments to long options are mandatory for short options too."
      The code:
          o.define_head "The check_puppet Nagios plug-in checks that specified Puppet process is running and the state file is no " +
              "older than specified interval."
      becomes:
          o.define_head "The check_puppet Nagios plug-in checks that specified Puppet process is running and the state file is no older than specified interval."

* Replaced no occurances of do (.*?) end with {\1}

* Replaced 1488 occurances of

      "([^"\n]*%s[^"\n]*)" *% *(.+?)(?=$| *\b(do|if|while|until|unless|#)\b)

  with

  20 Examples:

      The code:
          args[0].split(/\./).map do |s| "dc=%s"%[s] end.join(",")
      becomes:
          args[0].split(/\./).map do |s| "dc=#{s}" end.join(",")
      The code:
          puts "%s" % Puppet.version
      becomes:
          puts "#{Puppet.version}"
      The code:
          raise "Could not find information for %s" % node
      becomes:
          raise "Could not find information for #{node}"
      The code:
          raise Puppet::Error, "Cannot create %s: basedir %s is a file" % [dir, File.join(path)]
      becomes:
          raise Puppet::Error, "Cannot create #{dir}: basedir #{File.join(path)} is a file"
      The code:
          Puppet.err "Could not run %s: %s" % [client_class, detail]
      becomes:
          Puppet.err "Could not run #{client_class}: #{detail}"
      The code:
          raise "Could not find handler for %s" % arg
      becomes:
          raise "Could not find handler for #{arg}"
      The code:
          Puppet.err "Will not start without authorization file %s" % Puppet[:authconfig]
      becomes:
          Puppet.err "Will not start without authorization file #{Puppet[:authconfig]}"
      The code:
          raise Puppet::Error, "Could not deserialize catalog from pson: %s" % detail
      becomes:
          raise Puppet::Error, "Could not deserialize catalog from pson: #{detail}"
      The code:
          raise "Could not find facts for %s" % Puppet[:certname]
      becomes:
          raise "Could not find facts for #{Puppet[:certname]}"
      The code:
          raise ArgumentError, "%s is not readable" % path
      becomes:
          raise ArgumentError, "#{path} is not readable"
      The code:
          raise ArgumentError, "Invalid handler %s" % name
      becomes:
          raise ArgumentError, "Invalid handler #{name}"
      The code:
          debug "Executing '%s' in zone %s with '%s'" % [command, @resource[:name], str]
      becomes:
          debug "Executing '#{command}' in zone #{@resource[:name]} with '#{str}'"
      The code:
          raise Puppet::Error, "unknown cert type '%s'" % hash[:type]
      becomes:
          raise Puppet::Error, "unknown cert type '#{hash[:type]}'"
      The code:
          Puppet.info "Creating a new certificate request for %s" % Puppet[:certname]
      becomes:
          Puppet.info "Creating a new certificate request for #{Puppet[:certname]}"
      The code:
          "Cannot create alias %s: object already exists" % [name]
      becomes:
          "Cannot create alias #{name}: object already exists"
      The code:
          return "replacing from source %s with contents %s" % [metadata.source, metadata.checksum]
      becomes:
          return "replacing from source #{metadata.source} with contents #{metadata.checksum}"
      The code:
          it "should have a %s parameter" % param do
      becomes:
          it "should have a #{param} parameter" do
      The code:
          describe "when registring '%s' messages" % log do
      becomes:
          describe "when registring '#{log}' messages" do
      The code:
          paths = %w{a b c d e f g h}.collect { |l| "/tmp/iteration%stest" % l }
      becomes:
          paths = %w{a b c d e f g h}.collect { |l| "/tmp/iteration#{l}test" }
      The code:
          assert_raise(Puppet::Error, "Check '%s' did not fail on false" % check) do
      becomes:
          assert_raise(Puppet::Error, "Check '#{check}' did not fail on false") do
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Replaced 83 occurances of

      (.*)" *[+] *([$@]?[\w_0-9.:]+?)(.to_s\b)?(?! *[*(%\w_0-9.:{\[])

  with

      \1#{\2}"

  3 Examples:

      The code:
          puts "PUPPET " + status + ": " + process + ", " + state
      becomes:
          puts "PUPPET " + status + ": " + process + ", #{state}"
      The code:
          puts "PUPPET " + status + ": #{process}" + ", #{state}"
      becomes:
          puts "PUPPET #{status}" + ": #{process}" + ", #{state}"
      The code:
          }.compact.join( "\n" ) + "\n" + t + "]\n"
      becomes:
          }.compact.join( "\n" ) + "\n#{t}" + "]\n"

* Replaced 21 occurances of (.*)" *[+] *" with \1

  3 Examples:

      The code:
          puts "PUPPET #{status}" + ": #{process}" + ", #{state}"
      becomes:
          puts "PUPPET #{status}" + ": #{process}, #{state}"
      The code:
          puts "PUPPET #{status}" + ": #{process}, #{state}"
      becomes:
          puts "PUPPET #{status}: #{process}, #{state}"
      The code:
          res = self.class.name + ": #{@name}" + "\n"
      becomes:
          res = self.class.name + ": #{@name}\n"

* Don't use string concatenation to split lines unless they would be very long.

  Replaced 11 occurances of

      (.*)(['"]) *[+]
       *(['"])(.*)

  with

  3 Examples:

      The code:
          o.define_head "The check_puppet Nagios plug-in checks that specified " +
              "Puppet process is running and the state file is no " +
      becomes:
          o.define_head "The check_puppet Nagios plug-in checks that specified Puppet process is running and the state file is no " +
      The code:
          o.separator   "Mandatory arguments to long options are mandatory for " +
          "short options too."
      becomes:
          o.separator   "Mandatory arguments to long options are mandatory for short options too."
      The code:
          o.define_head "The check_puppet Nagios plug-in checks that specified Puppet process is running and the state file is no " +
              "older than specified interval."
      becomes:
          o.define_head "The check_puppet Nagios plug-in checks that specified Puppet process is running and the state file is no older than specified interval."

* Replaced no occurances of do (.*?) end with {\1}

* Replaced 1488 occurances of

      "([^"\n]*%s[^"\n]*)" *% *(.+?)(?=$| *\b(do|if|while|until|unless|#)\b)

  with

  20 Examples:

      The code:
          args[0].split(/\./).map do |s| "dc=%s"%[s] end.join(",")
      becomes:
          args[0].split(/\./).map do |s| "dc=#{s}" end.join(",")
      The code:
          puts "%s" % Puppet.version
      becomes:
          puts "#{Puppet.version}"
      The code:
          raise "Could not find information for %s" % node
      becomes:
          raise "Could not find information for #{node}"
      The code:
          raise Puppet::Error, "Cannot create %s: basedir %s is a file" % [dir, File.join(path)]
      becomes:
          raise Puppet::Error, "Cannot create #{dir}: basedir #{File.join(path)} is a file"
      The code:
          Puppet.err "Could not run %s: %s" % [client_class, detail]
      becomes:
          Puppet.err "Could not run #{client_class}: #{detail}"
      The code:
          raise "Could not find handler for %s" % arg
      becomes:
          raise "Could not find handler for #{arg}"
      The code:
          Puppet.err "Will not start without authorization file %s" % Puppet[:authconfig]
      becomes:
          Puppet.err "Will not start without authorization file #{Puppet[:authconfig]}"
      The code:
          raise Puppet::Error, "Could not deserialize catalog from pson: %s" % detail
      becomes:
          raise Puppet::Error, "Could not deserialize catalog from pson: #{detail}"
      The code:
          raise "Could not find facts for %s" % Puppet[:certname]
      becomes:
          raise "Could not find facts for #{Puppet[:certname]}"
      The code:
          raise ArgumentError, "%s is not readable" % path
      becomes:
          raise ArgumentError, "#{path} is not readable"
      The code:
          raise ArgumentError, "Invalid handler %s" % name
      becomes:
          raise ArgumentError, "Invalid handler #{name}"
      The code:
          debug "Executing '%s' in zone %s with '%s'" % [command, @resource[:name], str]
      becomes:
          debug "Executing '#{command}' in zone #{@resource[:name]} with '#{str}'"
      The code:
          raise Puppet::Error, "unknown cert type '%s'" % hash[:type]
      becomes:
          raise Puppet::Error, "unknown cert type '#{hash[:type]}'"
      The code:
          Puppet.info "Creating a new certificate request for %s" % Puppet[:certname]
      becomes:
          Puppet.info "Creating a new certificate request for #{Puppet[:certname]}"
      The code:
          "Cannot create alias %s: object already exists" % [name]
      becomes:
          "Cannot create alias #{name}: object already exists"
      The code:
          return "replacing from source %s with contents %s" % [metadata.source, metadata.checksum]
      becomes:
          return "replacing from source #{metadata.source} with contents #{metadata.checksum}"
      The code:
          it "should have a %s parameter" % param do
      becomes:
          it "should have a #{param} parameter" do
      The code:
          describe "when registring '%s' messages" % log do
      becomes:
          describe "when registring '#{log}' messages" do
      The code:
          paths = %w{a b c d e f g h}.collect { |l| "/tmp/iteration%stest" % l }
      becomes:
          paths = %w{a b c d e f g h}.collect { |l| "/tmp/iteration#{l}test" }
      The code:
          assert_raise(Puppet::Error, "Check '%s' did not fail on false" % check) do
      becomes:
          assert_raise(Puppet::Error, "Check '#{check}' did not fail on false") do
</pre>
</div>
</content>
</entry>
</feed>
