<feed xmlns='http://www.w3.org/2005/Atom'>
<title>puppet.git/lib/puppet/provider/zone, 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>Merge branch '2.6.x' into next</title>
<updated>2011-02-03T00:47:53+00:00</updated>
<author>
<name>Matt Robinson</name>
<email>matt@puppetlabs.com</email>
</author>
<published>2011-02-03T00:47:53+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/commit/?id=d4a468543f1f06d44efdb7e375284b0e65260caf'/>
<id>d4a468543f1f06d44efdb7e375284b0e65260caf</id>
<content type='text'>
* 2.6.x: (46 commits)
  Augmentation of tests for prior commit
  Fix to fix for #5755 -- backref serialization issues in zaml
  Fixed #5564 - Added some more fqdn_rand documentation
  Fixed #4968 - Updated list of options turned on by --test in documentation
  (#5061) - allow special hostclass/define variables to be evaluated as defaults.
  (#6107) Fix an error when auditing a file with empty content
  Remove already initialized constant warning from file_spec.rb tests
  (#5566) Treat source only File checksums as syntax errors when used with content
  Rename variable used in File type validation to be more clear
  Remove invalid "timestamp" and "time", and add missing "ctime" File checksum types.
  Remove order dependency when specifying source and checksum on File type
  Bug #5755 -- ZAML generates extra newline in some hash backreferences.
  bug #5681 -- code fix to handle AIX mount output
  Bug #5681 -- parse AIX mount command output.
  Spec for #5681 to allow parsing of AIX mount output in mount provider
  Fixed #6091 - Changed POSIX path matching to allow multiple leading slashes
  Bug #6091 -- test leading double-slash in filenames are allowed.
  Fixed #6071 - Fixed typo and improved exec path error message
  Fixed #6061 - Allowed -1 as password min/max age
  Bug #6061 -- verify that negative {min,max}_password_age are accepted.
  ...

Manually Resolved Conflicts:
	lib/puppet/util/zaml.rb
	spec/unit/util/zaml_spec.rb
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* 2.6.x: (46 commits)
  Augmentation of tests for prior commit
  Fix to fix for #5755 -- backref serialization issues in zaml
  Fixed #5564 - Added some more fqdn_rand documentation
  Fixed #4968 - Updated list of options turned on by --test in documentation
  (#5061) - allow special hostclass/define variables to be evaluated as defaults.
  (#6107) Fix an error when auditing a file with empty content
  Remove already initialized constant warning from file_spec.rb tests
  (#5566) Treat source only File checksums as syntax errors when used with content
  Rename variable used in File type validation to be more clear
  Remove invalid "timestamp" and "time", and add missing "ctime" File checksum types.
  Remove order dependency when specifying source and checksum on File type
  Bug #5755 -- ZAML generates extra newline in some hash backreferences.
  bug #5681 -- code fix to handle AIX mount output
  Bug #5681 -- parse AIX mount command output.
  Spec for #5681 to allow parsing of AIX mount output in mount provider
  Fixed #6091 - Changed POSIX path matching to allow multiple leading slashes
  Bug #6091 -- test leading double-slash in filenames are allowed.
  Fixed #6071 - Fixed typo and improved exec path error message
  Fixed #6061 - Allowed -1 as password min/max age
  Bug #6061 -- verify that negative {min,max}_password_age are accepted.
  ...

Manually Resolved Conflicts:
	lib/puppet/util/zaml.rb
	spec/unit/util/zaml_spec.rb
</pre>
</div>
</content>
</entry>
<entry>
<title>(#5931) Prevent errors when calling insync? on audited properties</title>
<updated>2011-01-25T23:12:47+00:00</updated>
<author>
<name>Paul Berry</name>
<email>paul@puppetlabs.com</email>
</author>
<published>2011-01-25T22:34:28+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/commit/?id=67e1bba154accd900b9690d96cec8b050f8082e7'/>
<id>67e1bba154accd900b9690d96cec8b050f8082e7</id>
<content type='text'>
Created a method safe_insync? which first checks whether the property
has a "should" value of nil, and if so returns true.  Most insync?
methods were already doing this, but a few were not, leading to bugs
if a property was being audited but not set.

Types should continue to override the insync? method, but callers of
insync? should call safe_insync? instead.

Paired-with: Jesse Wolfe &lt;jesse@puppetlabs.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Created a method safe_insync? which first checks whether the property
has a "should" value of nil, and if so returns true.  Most insync?
methods were already doing this, but a few were not, leading to bugs
if a property was being audited but not set.

Types should continue to override the insync? method, but callers of
insync? should call safe_insync? instead.

Paired-with: Jesse Wolfe &lt;jesse@puppetlabs.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>(#5393) Add "dataset" parameter to the zone provider</title>
<updated>2010-12-07T21:56:59+00:00</updated>
<author>
<name>Derek Olsen</name>
<email>derek.olsen@e-hps.com</email>
</author>
<published>2010-11-26T21:57:10+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/commit/?id=c88afa0cb9917177502700fddffcf8a40ca75f90'/>
<id>c88afa0cb9917177502700fddffcf8a40ca75f90</id>
<content type='text'>
This patch extends the zone provider to support the inclusion of one or more datasets in a solaris zone.  A dataset is an zfs filesystem that has been delegated from the global zone to the non global zone.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch extends the zone provider to support the inclusion of one or more datasets in a solaris zone.  A dataset is an zfs filesystem that has been delegated from the global zone to the non global zone.
</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: Avoid unneeded blocks</title>
<updated>2010-07-10T01:06:37+00:00</updated>
<author>
<name>Markus Roberts</name>
<email>Markus@reality.com</email>
</author>
<published>2010-07-10T01:06:37+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/commit/?id=07b15bf6fa2a2183f73fcb9b6740c7df75c8b47b'/>
<id>07b15bf6fa2a2183f73fcb9b6740c7df75c8b47b</id>
<content type='text'>
Replaced 45 occurances of

    (DEF)
        begin
            (LINES)
        rescue(.*)
            (LINES)
        end
    end

with

3 Examples:

    The code:
        def find(name)
            begin
                self.const_get(name.to_s.capitalize)
            rescue
                puts "Unable to find application '#{name.to_s}'."
                Kernel::exit(1)
            end
        end
    becomes:
        def find(name)
                self.const_get(name.to_s.capitalize)
        rescue
                puts "Unable to find application '#{name.to_s}'."
                Kernel::exit(1)
        end
    The code:
        def exit_on_fail(message, code = 1)
            begin
                yield
            rescue RuntimeError, NotImplementedError =&gt; detail
                puts detail.backtrace if Puppet[:trace]
                $stderr.puts "Could not #{message}: #{detail}"
                exit(code)
            end
        end
    becomes:
        def exit_on_fail(message, code = 1)
                yield
        rescue RuntimeError, NotImplementedError =&gt; detail
                puts detail.backtrace if Puppet[:trace]
                $stderr.puts "Could not #{message}: #{detail}"
                exit(code)
        end
    The code:
        def start
            begin
                case ssl
                when :tls
                    @connection = LDAP::SSLConn.new(host, port, true)
                when true
                    @connection = LDAP::SSLConn.new(host, port)
                else
                    @connection = LDAP::Conn.new(host, port)
                end
                @connection.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3)
                @connection.set_option(LDAP::LDAP_OPT_REFERRALS, LDAP::LDAP_OPT_ON)
                @connection.simple_bind(user, password)
            rescue =&gt; detail
                raise Puppet::Error, "Could not connect to LDAP: #{detail}"
            end
        end
    becomes:
        def start
                case ssl
                when :tls
                    @connection = LDAP::SSLConn.new(host, port, true)
                when true
                    @connection = LDAP::SSLConn.new(host, port)
                else
                    @connection = LDAP::Conn.new(host, port)
                end
                @connection.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3)
                @connection.set_option(LDAP::LDAP_OPT_REFERRALS, LDAP::LDAP_OPT_ON)
                @connection.simple_bind(user, password)
        rescue =&gt; detail
                raise Puppet::Error, "Could not connect to LDAP: #{detail}"
        end
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Replaced 45 occurances of

    (DEF)
        begin
            (LINES)
        rescue(.*)
            (LINES)
        end
    end

with

3 Examples:

    The code:
        def find(name)
            begin
                self.const_get(name.to_s.capitalize)
            rescue
                puts "Unable to find application '#{name.to_s}'."
                Kernel::exit(1)
            end
        end
    becomes:
        def find(name)
                self.const_get(name.to_s.capitalize)
        rescue
                puts "Unable to find application '#{name.to_s}'."
                Kernel::exit(1)
        end
    The code:
        def exit_on_fail(message, code = 1)
            begin
                yield
            rescue RuntimeError, NotImplementedError =&gt; detail
                puts detail.backtrace if Puppet[:trace]
                $stderr.puts "Could not #{message}: #{detail}"
                exit(code)
            end
        end
    becomes:
        def exit_on_fail(message, code = 1)
                yield
        rescue RuntimeError, NotImplementedError =&gt; detail
                puts detail.backtrace if Puppet[:trace]
                $stderr.puts "Could not #{message}: #{detail}"
                exit(code)
        end
    The code:
        def start
            begin
                case ssl
                when :tls
                    @connection = LDAP::SSLConn.new(host, port, true)
                when true
                    @connection = LDAP::SSLConn.new(host, port)
                else
                    @connection = LDAP::Conn.new(host, port)
                end
                @connection.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3)
                @connection.set_option(LDAP::LDAP_OPT_REFERRALS, LDAP::LDAP_OPT_ON)
                @connection.simple_bind(user, password)
            rescue =&gt; detail
                raise Puppet::Error, "Could not connect to LDAP: #{detail}"
            end
        end
    becomes:
        def start
                case ssl
                when :tls
                    @connection = LDAP::SSLConn.new(host, port, true)
                when true
                    @connection = LDAP::SSLConn.new(host, port)
                else
                    @connection = LDAP::Conn.new(host, port)
                end
                @connection.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3)
                @connection.set_option(LDAP::LDAP_OPT_REFERRALS, LDAP::LDAP_OPT_ON)
                @connection.simple_bind(user, password)
        rescue =&gt; detail
                raise Puppet::Error, "Could not connect to LDAP: #{detail}"
        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: Line modifiers are preferred to one-line blocks.</title>
<updated>2010-07-10T01:06:06+00:00</updated>
<author>
<name>Markus Roberts</name>
<email>Markus@reality.com</email>
</author>
<published>2010-07-10T01:06:06+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/commit/?id=81e283b28cdd91d259e3b60687aee7ea66e9d05d'/>
<id>81e283b28cdd91d259e3b60687aee7ea66e9d05d</id>
<content type='text'>
* 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]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* 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]
</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>
<entry>
<title>Code smell: English names for special globals rather than line-noise</title>
<updated>2010-07-10T01:05:08+00:00</updated>
<author>
<name>Markus Roberts</name>
<email>Markus@reality.com</email>
</author>
<published>2010-07-10T01:05:08+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/commit/?id=eefccf252527dc5b69af5959b0b0e2ddb5c91b74'/>
<id>eefccf252527dc5b69af5959b0b0e2ddb5c91b74</id>
<content type='text'>
* Replaced 36 occurances of [$][?] with $CHILD_STATUS

  3 Examples:

      The code:
          print "%s finished with exit code %s\n" % [host, $?.exitstatus]
      becomes:
          print "%s finished with exit code %s\n" % [host, $CHILD_STATUS.exitstatus]
      The code:
          $stderr.puts "Could not find host for PID %s with status %s" % [pid, $?.exitstatus]
      becomes:
          $stderr.puts "Could not find host for PID %s with status %s" % [pid, $CHILD_STATUS.exitstatus]
      The code:
          unless $? == 0
      becomes:
          unless $CHILD_STATUS == 0

* Replaced 3 occurances of [$][$] with $PID

  3 Examples:

      The code:
          Process.kill(:HUP, $$) if restart_requested?
      becomes:
          Process.kill(:HUP, $PID) if restart_requested?
      The code:
          if pid == $$
      becomes:
          if pid == $PID
      The code:
          host[:name] = "!invalid.hostname.$$$"
      becomes:
          host[:name] = "!invalid.hostname.$PID$"

* Replaced 7 occurances of [$]&amp; with $MATCH

  3 Examples:

      The code:
          work.slice!(0, $&amp;.length)
      becomes:
          work.slice!(0, $MATCH.length)
      The code:
          if $&amp;
      becomes:
          if $MATCH
      The code:
          if $&amp;
      becomes:
          if $MATCH

* Replaced 28 occurances of [$]:(?!:) with $LOAD_PATH

  3 Examples:

      The code:
          sitelibdir = $:.find { |x| x =~ /site_ruby/ }
      becomes:
          sitelibdir = $LOAD_PATH.find { |x| x =~ /site_ruby/ }
      The code:
          $:.unshift "lib"
      becomes:
          $LOAD_PATH.unshift "lib"
      The code:
          $:.shift
      becomes:
          $LOAD_PATH.shift

* Replaced 3 occurances of [$]! with $ERROR_INFO

  3 Examples:

      The code:
          $LOG.fatal("Problem reading #{filepath}: #{$!}")
      becomes:
          $LOG.fatal("Problem reading #{filepath}: #{$ERROR_INFO}")
      The code:
          $stderr.puts "Couldn't build man pages: " + $!
      becomes:
          $stderr.puts "Couldn't build man pages: " + $ERROR_INFO
      The code:
          $stderr.puts $!.message
      becomes:
          $stderr.puts $ERROR_INFO.message

* Replaced 3 occurances of ^(.*)[$]" with \1$LOADED_FEATURES

  3 Examples:

      The code:
          unless $".index 'racc/parser.rb'
      becomes:
          unless $LOADED_FEATURES.index 'racc/parser.rb'
      The code:
          $".push 'racc/parser.rb'
      becomes:
          $LOADED_FEATURES.push 'racc/parser.rb'
      The code:
          $".should be_include("tmp/myfile.rb")
      becomes:
          $LOADED_FEATURES.should be_include("tmp/myfile.rb")
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Replaced 36 occurances of [$][?] with $CHILD_STATUS

  3 Examples:

      The code:
          print "%s finished with exit code %s\n" % [host, $?.exitstatus]
      becomes:
          print "%s finished with exit code %s\n" % [host, $CHILD_STATUS.exitstatus]
      The code:
          $stderr.puts "Could not find host for PID %s with status %s" % [pid, $?.exitstatus]
      becomes:
          $stderr.puts "Could not find host for PID %s with status %s" % [pid, $CHILD_STATUS.exitstatus]
      The code:
          unless $? == 0
      becomes:
          unless $CHILD_STATUS == 0

* Replaced 3 occurances of [$][$] with $PID

  3 Examples:

      The code:
          Process.kill(:HUP, $$) if restart_requested?
      becomes:
          Process.kill(:HUP, $PID) if restart_requested?
      The code:
          if pid == $$
      becomes:
          if pid == $PID
      The code:
          host[:name] = "!invalid.hostname.$$$"
      becomes:
          host[:name] = "!invalid.hostname.$PID$"

* Replaced 7 occurances of [$]&amp; with $MATCH

  3 Examples:

      The code:
          work.slice!(0, $&amp;.length)
      becomes:
          work.slice!(0, $MATCH.length)
      The code:
          if $&amp;
      becomes:
          if $MATCH
      The code:
          if $&amp;
      becomes:
          if $MATCH

* Replaced 28 occurances of [$]:(?!:) with $LOAD_PATH

  3 Examples:

      The code:
          sitelibdir = $:.find { |x| x =~ /site_ruby/ }
      becomes:
          sitelibdir = $LOAD_PATH.find { |x| x =~ /site_ruby/ }
      The code:
          $:.unshift "lib"
      becomes:
          $LOAD_PATH.unshift "lib"
      The code:
          $:.shift
      becomes:
          $LOAD_PATH.shift

* Replaced 3 occurances of [$]! with $ERROR_INFO

  3 Examples:

      The code:
          $LOG.fatal("Problem reading #{filepath}: #{$!}")
      becomes:
          $LOG.fatal("Problem reading #{filepath}: #{$ERROR_INFO}")
      The code:
          $stderr.puts "Couldn't build man pages: " + $!
      becomes:
          $stderr.puts "Couldn't build man pages: " + $ERROR_INFO
      The code:
          $stderr.puts $!.message
      becomes:
          $stderr.puts $ERROR_INFO.message

* Replaced 3 occurances of ^(.*)[$]" with \1$LOADED_FEATURES

  3 Examples:

      The code:
          unless $".index 'racc/parser.rb'
      becomes:
          unless $LOADED_FEATURES.index 'racc/parser.rb'
      The code:
          $".push 'racc/parser.rb'
      becomes:
          $LOADED_FEATURES.push 'racc/parser.rb'
      The code:
          $".should be_include("tmp/myfile.rb")
      becomes:
          $LOADED_FEATURES.should be_include("tmp/myfile.rb")
</pre>
</div>
</content>
</entry>
</feed>
