<feed xmlns='http://www.w3.org/2005/Atom'>
<title>puppet.git/lib/puppet/util/autoload, 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>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 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: 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: 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>[#3674] Part 2: Autoloader load method should propagate failures</title>
<updated>2010-02-17T14:50:53+00:00</updated>
<author>
<name>Jesse Wolfe</name>
<email>jes5199@gmail.com</email>
</author>
<published>2010-05-23T00:58:44+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/commit/?id=2a73b5d194a5237722840844588a03addedf2d4c'/>
<id>2a73b5d194a5237722840844588a03addedf2d4c</id>
<content type='text'>
Change Autoloader's load to re-raise exceptions that happen when
trying to load files, rather than just warning.

This version still does not raise an error if the file is not found, as
doing so would change the behavior of 'load' pretty significantly, but I
am ambivalent this.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Change Autoloader's load to re-raise exceptions that happen when
trying to load files, rather than just warning.

This version still does not raise an error if the file is not found, as
doing so would change the behavior of 'load' pretty significantly, but I
am ambivalent this.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fixing #2541 - file cache is more resilient to failure</title>
<updated>2009-08-10T07:36:17+00:00</updated>
<author>
<name>Luke Kanies</name>
<email>luke@madstop.com</email>
</author>
<published>2009-08-08T00:39:44+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/commit/?id=0cb9072c0e3b37332f4eeaeff061950d6f73d021'/>
<id>0cb9072c0e3b37332f4eeaeff061950d6f73d021</id>
<content type='text'>
Signed-off-by: Luke Kanies &lt;luke@madstop.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: Luke Kanies &lt;luke@madstop.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Caching whether named autoloaded files are missing</title>
<updated>2009-05-20T08:29:04+00:00</updated>
<author>
<name>Luke Kanies</name>
<email>luke@madstop.com</email>
</author>
<published>2009-05-16T05:08:35+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/commit/?id=138f19fc6e7bb1d8ebf305decaa045c53787297c'/>
<id>138f19fc6e7bb1d8ebf305decaa045c53787297c</id>
<content type='text'>
This is the big win, because it causes us to just
skip the whole loading infrastructure, including
skipping looking through the modulepath.

Signed-off-by: Luke Kanies &lt;luke@madstop.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is the big win, because it causes us to just
skip the whole loading infrastructure, including
skipping looking through the modulepath.

Signed-off-by: Luke Kanies &lt;luke@madstop.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Adding caching of file metadata to the autoloader</title>
<updated>2009-05-20T08:29:04+00:00</updated>
<author>
<name>Luke Kanies</name>
<email>luke@madstop.com</email>
</author>
<published>2009-05-17T22:20:55+00:00</published>
<link rel='alternate' type='text/html' href='https://fedorapeople.org/cgit/ricky/public_git/puppet.git/commit/?id=415553e9485d7ba3ed867033ac9c3315107d3c92'/>
<id>415553e9485d7ba3ed867033ac9c3315107d3c92</id>
<content type='text'>
The cache isn't actually used yet - this just adds
all of the plumbing.

It was found that stat'ing files that didn't exist
could take up to 85% of a run, so this is progress
toward getting rid of those stats.

Signed-off-by: Luke Kanies &lt;luke@madstop.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The cache isn't actually used yet - this just adds
all of the plumbing.

It was found that stat'ing files that didn't exist
could take up to 85% of a run, so this is progress
toward getting rid of those stats.

Signed-off-by: Luke Kanies &lt;luke@madstop.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
