<feed xmlns='http://www.w3.org/2005/Atom'>
<title>puppet.git/test/network/xmlrpc, 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: 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>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 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: Inconsistent indentation and related formatting issues</title>
<updated>2010-07-10T01:05:04+00:00</updated>
<author>
<name>Markus Roberts</name>
<email>Markus@reality.com</email>
</author>
<published>2010-07-10T01:05:04+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/commit/?id=9ee56f2e67be973da49b1d3f21de1bf87de35e6f'/>
<id>9ee56f2e67be973da49b1d3f21de1bf87de35e6f</id>
<content type='text'>
* Replaced 163 occurances of

      defined\? +([@a-zA-Z_.0-9?=]+)

  with

      defined?(\1)

  This makes detecting subsequent patterns easier.

  3 Examples:

      The code:
          if ! defined? @parse_config
      becomes:
          if ! defined?(@parse_config)
      The code:
          return @option_parser if defined? @option_parser
      becomes:
          return @option_parser if defined?(@option_parser)
      The code:
          if defined? @local and @local
      becomes:
          if defined?(@local) and @local

* Eliminate trailing spaces.

  Replaced 428 occurances of ^(.*?) +$ with \1

  1 file was skipped.

      test/ral/providers/host/parsed.rb because 0

* Replace leading tabs with an appropriate number of spaces.

  Replaced 306 occurances of ^(\t+)(.*) with

  Tabs are not consistently expanded in all environments.

* Don't arbitrarily wrap on sprintf (%) operator.

  Replaced 143 occurances of

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

  with

  Splitting the line does nothing to aid clarity and hinders further refactorings.

  3 Examples:

      The code:
          raise Puppet::Error, "Cannot create %s: basedir %s is a file" %
              [dir, File.join(path)]
      becomes:
          raise Puppet::Error, "Cannot create %s: basedir %s is a file" % [dir, File.join(path)]
      The code:
          Puppet.err "Will not start without authorization file %s" %
              Puppet[:authconfig]
      becomes:
          Puppet.err "Will not start without authorization file %s" % Puppet[:authconfig]
      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, $?.exitstatus]

* Don't break short arrays/parameter list in two.

  Replaced 228 occurances of

      (.*)
       +(.*)

  with

  3 Examples:

      The code:
          puts @format.wrap(type.provider(prov).doc,
                            :indent =&gt; 4, :scrub =&gt; true)
      becomes:
          puts @format.wrap(type.provider(prov).doc, :indent =&gt; 4, :scrub =&gt; true)
      The code:
          assert(FileTest.exists?(daily),
              "Did not make daily graph for %s" % type)
      becomes:
          assert(FileTest.exists?(daily), "Did not make daily graph for %s" % type)
      The code:
          assert(prov.target_object(:first).read !~ /^notdisk/,
              "Did not remove thing from disk")
      becomes:
          assert(prov.target_object(:first).read !~ /^notdisk/, "Did not remove thing from disk")

* If arguments must wrap, treat them all equally

  Replaced 510 occurances of

      lines ending in things like ...(foo, or ...(bar(1,3),

  with

      \1
          \2

  3 Examples:

      The code:
          midscope.to_hash(false),
      becomes:
          assert_equal(
      The code:
          botscope.to_hash(true),
      becomes:
          # bottomscope, then checking that we see the right stuff.
      The code:
          :path =&gt; link,
      becomes:

* Replaced 4516 occurances of ^( *)(.*) with

  The present code base is supposed to use four-space indentation.  In some places we failed
  to maintain that standard.  These should be fixed regardless of the 2 vs. 4 space question.

  15 Examples:

      The code:

          def run_comp(cmd)
             puts cmd
             results = []
             old_sync = $stdout.sync
             $stdout.sync = true
             line = []
             begin
                open("| #{cmd}", "r") do |f|
                  until f.eof? do
                    c = f.getc
      becomes:

          def run_comp(cmd)
              puts cmd
              results = []
              old_sync = $stdout.sync
              $stdout.sync = true
              line = []
              begin
                  open("| #{cmd}", "r") do |f|
                      until f.eof? do
                          c = f.getc
      The code:
                              s.gsub!(/.{4}/n, '\\\\u\&amp;')
                            }
              string.force_encoding(Encoding::UTF_8)
              string
            rescue Iconv::Failure =&gt; e
              raise GeneratorError, "Caught #{e.class}: #{e}"
            end
          else
            def utf8_to_pson(string) # :nodoc:
              string = string.gsub(/["\\\x0-\x1f]/) { MAP[$&amp;] }
              string.gsub!(/(
      becomes:
                                      s.gsub!(/.{4}/n, '\\\\u\&amp;')
                                  }
                  string.force_encoding(Encoding::UTF_8)
                  string
              rescue Iconv::Failure =&gt; e
                  raise GeneratorError, "Caught #{e.class}: #{e}"
              end
          else
              def utf8_to_pson(string) # :nodoc:
                  string = string.gsub(/["\\\x0-\x1f]/) { MAP[$&amp;] }
                  string.gsub!(/(
      The code:
              end
          }

          rvalues:      rvalue
                      | rvalues comma rvalue {
              if val[0].instance_of?(AST::ASTArray)
                  result = val[0].push(val[2])
              else
                  result = ast AST::ASTArray, :children =&gt; [val[0],val[2]]
              end
          }
      becomes:
              end
          }

          rvalues:      rvalue
              | rvalues comma rvalue {
                  if val[0].instance_of?(AST::ASTArray)
                  result = val[0].push(val[2])
              else
                  result = ast AST::ASTArray, :children =&gt; [val[0],val[2]]
              end
          }
      The code:
          #passwdproc = proc { @password }

                      keytext = @key.export(

              OpenSSL::Cipher::DES.new(:EDE3, :CBC),

              @password
          )
          File.open(@keyfile, "w", 0400) { |f|
              f &lt;&lt; keytext
          }
      becomes:
          #        passwdproc = proc { @password }

              keytext = @key.export(

                  OpenSSL::Cipher::DES.new(:EDE3, :CBC),

                  @password
                  )
                  File.open(@keyfile, "w", 0400) { |f|
                      f &lt;&lt; keytext
                  }
      The code:
          end

          def to_manifest
              "%s { '%s':\n%s\n}" % [self.type.to_s, self.name,
                   @params.collect { |p, v|
                       if v.is_a? Array
                           "    #{p} =&gt; [\'#{v.join("','")}\']"
                       else
                           "    #{p} =&gt; \'#{v}\'"
                       end
                   }.join(",\n")
      becomes:
          end

          def to_manifest
              "%s { '%s':\n%s\n}" % [self.type.to_s, self.name,
                  @params.collect { |p, v|
                      if v.is_a? Array
                          "    #{p} =&gt; [\'#{v.join("','")}\']"
                      else
                          "    #{p} =&gt; \'#{v}\'"
                      end
                  }.join(",\n")
      The code:
          via the augeas tool.

           Requires:
             - augeas to be installed (http://www.augeas.net)
             - ruby-augeas bindings

           Sample usage with a string::

              augeas{\"test1\" :
                     context =&gt; \"/files/etc/sysconfig/firstboot\",
                     changes =&gt; \"set RUN_FIRSTBOOT YES\",
      becomes:
          via the augeas tool.

          Requires:
              - augeas to be installed (http://www.augeas.net)
              - ruby-augeas bindings

          Sample usage with a string::

              augeas{\"test1\" :
                  context =&gt; \"/files/etc/sysconfig/firstboot\",
                  changes =&gt; \"set RUN_FIRSTBOOT YES\",
      The code:
              names.should_not be_include("root")
          end

          describe "when generating a purgeable resource" do
              it "should be included in the generated resources" do
                  Puppet::Type.type(:host).stubs(:instances).returns [@purgeable_resource]
                  @resources.generate.collect { |r| r.ref }.should include(@purgeable_resource.ref)
              end
          end

          describe "when the instance's do not have an ensure property" do
      becomes:
              names.should_not be_include("root")
          end

          describe "when generating a purgeable resource" do
              it "should be included in the generated resources" do
                  Puppet::Type.type(:host).stubs(:instances).returns [@purgeable_resource]
                  @resources.generate.collect { |r| r.ref }.should include(@purgeable_resource.ref)
              end
          end

          describe "when the instance's do not have an ensure property" do
      The code:
          describe "when the instance's do not have an ensure property" do
              it "should not be included in the generated resources" do
                  @no_ensure_resource = Puppet::Type.type(:exec).new(:name =&gt; '/usr/bin/env echo')
                  Puppet::Type.type(:host).stubs(:instances).returns [@no_ensure_resource]
                  @resources.generate.collect { |r| r.ref }.should_not include(@no_ensure_resource.ref)
              end
          end

          describe "when the instance's ensure property does not accept absent" do
              it "should not be included in the generated resources" do
                  @no_absent_resource = Puppet::Type.type(:service).new(:name =&gt; 'foobar')
      becomes:
          describe "when the instance's do not have an ensure property" do
              it "should not be included in the generated resources" do
                  @no_ensure_resource = Puppet::Type.type(:exec).new(:name =&gt; '/usr/bin/env echo')
                  Puppet::Type.type(:host).stubs(:instances).returns [@no_ensure_resource]
                  @resources.generate.collect { |r| r.ref }.should_not include(@no_ensure_resource.ref)
              end
          end

          describe "when the instance's ensure property does not accept absent" do
              it "should not be included in the generated resources" do
                  @no_absent_resource = Puppet::Type.type(:service).new(:name =&gt; 'foobar')
      The code:
          func = nil
          assert_nothing_raised do

                          func = Puppet::Parser::AST::Function.new(

                  :name =&gt; "template",
                  :ftype =&gt; :rvalue,

                  :arguments =&gt; AST::ASTArray.new(
                      :children =&gt; [stringobj(template)]
                  )
      becomes:
          func = nil
          assert_nothing_raised do

              func = Puppet::Parser::AST::Function.new(

                  :name =&gt; "template",
                  :ftype =&gt; :rvalue,

                  :arguments =&gt; AST::ASTArray.new(
                      :children =&gt; [stringobj(template)]
                  )
      The code:

                  assert(
              @store.allowed?("hostname.madstop.com", "192.168.1.50"),

          "hostname not allowed")

                  assert(
              ! @store.allowed?("name.sub.madstop.com", "192.168.0.50"),

          "subname name allowed")
      becomes:

          assert(
              @store.allowed?("hostname.madstop.com", "192.168.1.50"),

          "hostname not allowed")

              assert(
                  ! @store.allowed?("name.sub.madstop.com", "192.168.0.50"),

          "subname name allowed")
      The code:

          assert_nothing_raised {

                          server = Puppet::Network::Handler.fileserver.new(

                  :Local =&gt; true,

                  :Config =&gt; false
              )
          }

      becomes:

          assert_nothing_raised {

              server = Puppet::Network::Handler.fileserver.new(

                  :Local =&gt; true,

                  :Config =&gt; false
              )
          }

      The code:
               'yay',
                                               { :failonfail =&gt; false,
                                                 :uid =&gt; @user.uid,

                                                 :gid =&gt; @user.gid }
                                             ).returns('output')

          output = Puppet::Util::SUIDManager.run_and_capture 'yay',
                                                             @user.uid,
                                                             @user.gid
      becomes:
                  'yay',
                      { :failonfail =&gt; false,
                          :uid =&gt; @user.uid,

                          :gid =&gt; @user.gid }
                              ).returns('output')

          output = Puppet::Util::SUIDManager.run_and_capture 'yay',
              @user.uid,
              @user.gid
      The code:
                      ).times(1)
          pkg.provider.expects(
                          :aptget

                                  ).with(

                          '-y',
                          '-q',
                          'remove',

                          'faff'
      becomes:
                      ).times(1)
          pkg.provider.expects(
              :aptget

                  ).with(

                      '-y',
                      '-q',
                      'remove',

                      'faff'
      The code:
          johnny one two
          billy three four\n"

                  # Just parse and generate, to make sure it's isomorphic.
                  assert_nothing_raised do
                      assert_equal(text, @parser.to_file(@parser.parse(text)),
                          "parsing was not isomorphic")
                  end
              end

              def test_valid_attrs
      becomes:
          johnny one two
          billy three four\n"

          #         Just parse and generate, to make sure it's isomorphic.
          assert_nothing_raised do
              assert_equal(text, @parser.to_file(@parser.parse(text)),
                  "parsing was not isomorphic")
                  end
              end

              def test_valid_attrs
      The code:
                  "testing",
                              :onboolean =&gt; [true, "An on bool"],

                              :string =&gt; ["a string", "A string arg"]
                              )
          result = []
          should = []
          assert_nothing_raised("Add args failed") do
              @config.addargs(result)
          end
          @config.each do |name, element|
      becomes:
                  "testing",
                      :onboolean =&gt; [true, "An on bool"],

                      :string =&gt; ["a string", "A string arg"]
                      )
          result = []
          should = []
          assert_nothing_raised("Add args failed") do
              @config.addargs(result)
          end
          @config.each do |name, element|
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Replaced 163 occurances of

      defined\? +([@a-zA-Z_.0-9?=]+)

  with

      defined?(\1)

  This makes detecting subsequent patterns easier.

  3 Examples:

      The code:
          if ! defined? @parse_config
      becomes:
          if ! defined?(@parse_config)
      The code:
          return @option_parser if defined? @option_parser
      becomes:
          return @option_parser if defined?(@option_parser)
      The code:
          if defined? @local and @local
      becomes:
          if defined?(@local) and @local

* Eliminate trailing spaces.

  Replaced 428 occurances of ^(.*?) +$ with \1

  1 file was skipped.

      test/ral/providers/host/parsed.rb because 0

* Replace leading tabs with an appropriate number of spaces.

  Replaced 306 occurances of ^(\t+)(.*) with

  Tabs are not consistently expanded in all environments.

* Don't arbitrarily wrap on sprintf (%) operator.

  Replaced 143 occurances of

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

  with

  Splitting the line does nothing to aid clarity and hinders further refactorings.

  3 Examples:

      The code:
          raise Puppet::Error, "Cannot create %s: basedir %s is a file" %
              [dir, File.join(path)]
      becomes:
          raise Puppet::Error, "Cannot create %s: basedir %s is a file" % [dir, File.join(path)]
      The code:
          Puppet.err "Will not start without authorization file %s" %
              Puppet[:authconfig]
      becomes:
          Puppet.err "Will not start without authorization file %s" % Puppet[:authconfig]
      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, $?.exitstatus]

* Don't break short arrays/parameter list in two.

  Replaced 228 occurances of

      (.*)
       +(.*)

  with

  3 Examples:

      The code:
          puts @format.wrap(type.provider(prov).doc,
                            :indent =&gt; 4, :scrub =&gt; true)
      becomes:
          puts @format.wrap(type.provider(prov).doc, :indent =&gt; 4, :scrub =&gt; true)
      The code:
          assert(FileTest.exists?(daily),
              "Did not make daily graph for %s" % type)
      becomes:
          assert(FileTest.exists?(daily), "Did not make daily graph for %s" % type)
      The code:
          assert(prov.target_object(:first).read !~ /^notdisk/,
              "Did not remove thing from disk")
      becomes:
          assert(prov.target_object(:first).read !~ /^notdisk/, "Did not remove thing from disk")

* If arguments must wrap, treat them all equally

  Replaced 510 occurances of

      lines ending in things like ...(foo, or ...(bar(1,3),

  with

      \1
          \2

  3 Examples:

      The code:
          midscope.to_hash(false),
      becomes:
          assert_equal(
      The code:
          botscope.to_hash(true),
      becomes:
          # bottomscope, then checking that we see the right stuff.
      The code:
          :path =&gt; link,
      becomes:

* Replaced 4516 occurances of ^( *)(.*) with

  The present code base is supposed to use four-space indentation.  In some places we failed
  to maintain that standard.  These should be fixed regardless of the 2 vs. 4 space question.

  15 Examples:

      The code:

          def run_comp(cmd)
             puts cmd
             results = []
             old_sync = $stdout.sync
             $stdout.sync = true
             line = []
             begin
                open("| #{cmd}", "r") do |f|
                  until f.eof? do
                    c = f.getc
      becomes:

          def run_comp(cmd)
              puts cmd
              results = []
              old_sync = $stdout.sync
              $stdout.sync = true
              line = []
              begin
                  open("| #{cmd}", "r") do |f|
                      until f.eof? do
                          c = f.getc
      The code:
                              s.gsub!(/.{4}/n, '\\\\u\&amp;')
                            }
              string.force_encoding(Encoding::UTF_8)
              string
            rescue Iconv::Failure =&gt; e
              raise GeneratorError, "Caught #{e.class}: #{e}"
            end
          else
            def utf8_to_pson(string) # :nodoc:
              string = string.gsub(/["\\\x0-\x1f]/) { MAP[$&amp;] }
              string.gsub!(/(
      becomes:
                                      s.gsub!(/.{4}/n, '\\\\u\&amp;')
                                  }
                  string.force_encoding(Encoding::UTF_8)
                  string
              rescue Iconv::Failure =&gt; e
                  raise GeneratorError, "Caught #{e.class}: #{e}"
              end
          else
              def utf8_to_pson(string) # :nodoc:
                  string = string.gsub(/["\\\x0-\x1f]/) { MAP[$&amp;] }
                  string.gsub!(/(
      The code:
              end
          }

          rvalues:      rvalue
                      | rvalues comma rvalue {
              if val[0].instance_of?(AST::ASTArray)
                  result = val[0].push(val[2])
              else
                  result = ast AST::ASTArray, :children =&gt; [val[0],val[2]]
              end
          }
      becomes:
              end
          }

          rvalues:      rvalue
              | rvalues comma rvalue {
                  if val[0].instance_of?(AST::ASTArray)
                  result = val[0].push(val[2])
              else
                  result = ast AST::ASTArray, :children =&gt; [val[0],val[2]]
              end
          }
      The code:
          #passwdproc = proc { @password }

                      keytext = @key.export(

              OpenSSL::Cipher::DES.new(:EDE3, :CBC),

              @password
          )
          File.open(@keyfile, "w", 0400) { |f|
              f &lt;&lt; keytext
          }
      becomes:
          #        passwdproc = proc { @password }

              keytext = @key.export(

                  OpenSSL::Cipher::DES.new(:EDE3, :CBC),

                  @password
                  )
                  File.open(@keyfile, "w", 0400) { |f|
                      f &lt;&lt; keytext
                  }
      The code:
          end

          def to_manifest
              "%s { '%s':\n%s\n}" % [self.type.to_s, self.name,
                   @params.collect { |p, v|
                       if v.is_a? Array
                           "    #{p} =&gt; [\'#{v.join("','")}\']"
                       else
                           "    #{p} =&gt; \'#{v}\'"
                       end
                   }.join(",\n")
      becomes:
          end

          def to_manifest
              "%s { '%s':\n%s\n}" % [self.type.to_s, self.name,
                  @params.collect { |p, v|
                      if v.is_a? Array
                          "    #{p} =&gt; [\'#{v.join("','")}\']"
                      else
                          "    #{p} =&gt; \'#{v}\'"
                      end
                  }.join(",\n")
      The code:
          via the augeas tool.

           Requires:
             - augeas to be installed (http://www.augeas.net)
             - ruby-augeas bindings

           Sample usage with a string::

              augeas{\"test1\" :
                     context =&gt; \"/files/etc/sysconfig/firstboot\",
                     changes =&gt; \"set RUN_FIRSTBOOT YES\",
      becomes:
          via the augeas tool.

          Requires:
              - augeas to be installed (http://www.augeas.net)
              - ruby-augeas bindings

          Sample usage with a string::

              augeas{\"test1\" :
                  context =&gt; \"/files/etc/sysconfig/firstboot\",
                  changes =&gt; \"set RUN_FIRSTBOOT YES\",
      The code:
              names.should_not be_include("root")
          end

          describe "when generating a purgeable resource" do
              it "should be included in the generated resources" do
                  Puppet::Type.type(:host).stubs(:instances).returns [@purgeable_resource]
                  @resources.generate.collect { |r| r.ref }.should include(@purgeable_resource.ref)
              end
          end

          describe "when the instance's do not have an ensure property" do
      becomes:
              names.should_not be_include("root")
          end

          describe "when generating a purgeable resource" do
              it "should be included in the generated resources" do
                  Puppet::Type.type(:host).stubs(:instances).returns [@purgeable_resource]
                  @resources.generate.collect { |r| r.ref }.should include(@purgeable_resource.ref)
              end
          end

          describe "when the instance's do not have an ensure property" do
      The code:
          describe "when the instance's do not have an ensure property" do
              it "should not be included in the generated resources" do
                  @no_ensure_resource = Puppet::Type.type(:exec).new(:name =&gt; '/usr/bin/env echo')
                  Puppet::Type.type(:host).stubs(:instances).returns [@no_ensure_resource]
                  @resources.generate.collect { |r| r.ref }.should_not include(@no_ensure_resource.ref)
              end
          end

          describe "when the instance's ensure property does not accept absent" do
              it "should not be included in the generated resources" do
                  @no_absent_resource = Puppet::Type.type(:service).new(:name =&gt; 'foobar')
      becomes:
          describe "when the instance's do not have an ensure property" do
              it "should not be included in the generated resources" do
                  @no_ensure_resource = Puppet::Type.type(:exec).new(:name =&gt; '/usr/bin/env echo')
                  Puppet::Type.type(:host).stubs(:instances).returns [@no_ensure_resource]
                  @resources.generate.collect { |r| r.ref }.should_not include(@no_ensure_resource.ref)
              end
          end

          describe "when the instance's ensure property does not accept absent" do
              it "should not be included in the generated resources" do
                  @no_absent_resource = Puppet::Type.type(:service).new(:name =&gt; 'foobar')
      The code:
          func = nil
          assert_nothing_raised do

                          func = Puppet::Parser::AST::Function.new(

                  :name =&gt; "template",
                  :ftype =&gt; :rvalue,

                  :arguments =&gt; AST::ASTArray.new(
                      :children =&gt; [stringobj(template)]
                  )
      becomes:
          func = nil
          assert_nothing_raised do

              func = Puppet::Parser::AST::Function.new(

                  :name =&gt; "template",
                  :ftype =&gt; :rvalue,

                  :arguments =&gt; AST::ASTArray.new(
                      :children =&gt; [stringobj(template)]
                  )
      The code:

                  assert(
              @store.allowed?("hostname.madstop.com", "192.168.1.50"),

          "hostname not allowed")

                  assert(
              ! @store.allowed?("name.sub.madstop.com", "192.168.0.50"),

          "subname name allowed")
      becomes:

          assert(
              @store.allowed?("hostname.madstop.com", "192.168.1.50"),

          "hostname not allowed")

              assert(
                  ! @store.allowed?("name.sub.madstop.com", "192.168.0.50"),

          "subname name allowed")
      The code:

          assert_nothing_raised {

                          server = Puppet::Network::Handler.fileserver.new(

                  :Local =&gt; true,

                  :Config =&gt; false
              )
          }

      becomes:

          assert_nothing_raised {

              server = Puppet::Network::Handler.fileserver.new(

                  :Local =&gt; true,

                  :Config =&gt; false
              )
          }

      The code:
               'yay',
                                               { :failonfail =&gt; false,
                                                 :uid =&gt; @user.uid,

                                                 :gid =&gt; @user.gid }
                                             ).returns('output')

          output = Puppet::Util::SUIDManager.run_and_capture 'yay',
                                                             @user.uid,
                                                             @user.gid
      becomes:
                  'yay',
                      { :failonfail =&gt; false,
                          :uid =&gt; @user.uid,

                          :gid =&gt; @user.gid }
                              ).returns('output')

          output = Puppet::Util::SUIDManager.run_and_capture 'yay',
              @user.uid,
              @user.gid
      The code:
                      ).times(1)
          pkg.provider.expects(
                          :aptget

                                  ).with(

                          '-y',
                          '-q',
                          'remove',

                          'faff'
      becomes:
                      ).times(1)
          pkg.provider.expects(
              :aptget

                  ).with(

                      '-y',
                      '-q',
                      'remove',

                      'faff'
      The code:
          johnny one two
          billy three four\n"

                  # Just parse and generate, to make sure it's isomorphic.
                  assert_nothing_raised do
                      assert_equal(text, @parser.to_file(@parser.parse(text)),
                          "parsing was not isomorphic")
                  end
              end

              def test_valid_attrs
      becomes:
          johnny one two
          billy three four\n"

          #         Just parse and generate, to make sure it's isomorphic.
          assert_nothing_raised do
              assert_equal(text, @parser.to_file(@parser.parse(text)),
                  "parsing was not isomorphic")
                  end
              end

              def test_valid_attrs
      The code:
                  "testing",
                              :onboolean =&gt; [true, "An on bool"],

                              :string =&gt; ["a string", "A string arg"]
                              )
          result = []
          should = []
          assert_nothing_raised("Add args failed") do
              @config.addargs(result)
          end
          @config.each do |name, element|
      becomes:
                  "testing",
                      :onboolean =&gt; [true, "An on bool"],

                      :string =&gt; ["a string", "A string arg"]
                      )
          result = []
          should = []
          assert_nothing_raised("Add args failed") do
              @config.addargs(result)
          end
          @config.each do |name, element|
</pre>
</div>
</content>
</entry>
<entry>
<title>Changed tabs to spaces without interfering with indentation or alignment</title>
<updated>2009-06-05T23:11:28+00:00</updated>
<author>
<name>Ian Taylor</name>
<email>ian@lorf.org</email>
</author>
<published>2009-06-05T16:38:35+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/commit/?id=41ce18cc8ea239d1633fc6cd9e9f599957a82e74'/>
<id>41ce18cc8ea239d1633fc6cd9e9f599957a82e74</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Entirely refactoring http keep-alive.  There's now</title>
<updated>2007-12-19T17:42:22+00:00</updated>
<author>
<name>Luke Kanies</name>
<email>luke@madstop.com</email>
</author>
<published>2007-12-19T17:42:22+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/commit/?id=553b2ad8add20cd629fcd90b512d97d4edd7e481'/>
<id>553b2ad8add20cd629fcd90b512d97d4edd7e481</id>
<content type='text'>
a central module responsible for managing the http pool
(Puppet::Network::HttpPool), and it also handles
setting certificate information.  This gets rid of
what were otherwise long chains of method calls,
and it makes the code paths much clearer.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
a central module responsible for managing the http pool
(Puppet::Network::HttpPool), and it also handles
setting certificate information.  This gets rid of
what were otherwise long chains of method calls,
and it makes the code paths much clearer.
</pre>
</div>
</content>
</entry>
<entry>
<title>Updated tests for http_enable_post_connection_check configuration setting.</title>
<updated>2007-11-29T22:15:15+00:00</updated>
<author>
<name>Jeffrey J McCune</name>
<email>jeff@northstarlabs.net</email>
</author>
<published>2007-11-29T22:15:15+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/commit/?id=a012849e9ca496ccf72cbaf307f220f3891b802e'/>
<id>a012849e9ca496ccf72cbaf307f220f3891b802e</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Better test to match the behavior of the code.</title>
<updated>2007-11-29T14:48:17+00:00</updated>
<author>
<name>Jeffrey J McCune</name>
<email>jeff@northstarlabs.net</email>
</author>
<published>2007-11-29T14:48:17+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/commit/?id=4d4abd36b8e354e3581d32faae345fb55e16f3ea'/>
<id>4d4abd36b8e354e3581d32faae345fb55e16f3ea</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Fixed test case for http_enable_post_connection_check</title>
<updated>2007-11-29T14:43:32+00:00</updated>
<author>
<name>Jeffrey J McCune</name>
<email>jeff@northstarlabs.net</email>
</author>
<published>2007-11-29T14:43:32+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/commit/?id=24cacdbde383fef132f9a289e91a354c2a5c3668'/>
<id>24cacdbde383fef132f9a289e91a354c2a5c3668</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
