RiotGames/ridley

View on GitHub

Showing 40 of 44 total issues

File metadata.rb has 402 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Ridley::Chef
  class Cookbook
    # Borrowed and modified from: {https://raw.github.com/opscode/chef/11.4.0/lib/chef/cookbook/metadata.rb}
    #
    # Copyright:: Copyright 2008-2010 Opscode, Inc.
Severity: Minor
Found in lib/ridley/chef/cookbook/metadata.rb - About 5 hrs to fix

    Class Metadata has 40 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Metadata
          class << self
            def from_hash(hash)
              new.from_hash(hash)
            end
    Severity: Minor
    Found in lib/ridley/chef/cookbook/metadata.rb - About 5 hrs to fix

      Method from_hash has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

            def from_hash(o)
              @name             = o[NAME] if o.has_key?(NAME)
              @description      = o[DESCRIPTION] if o.has_key?(DESCRIPTION)
              @long_description = o[LONG_DESCRIPTION] if o.has_key?(LONG_DESCRIPTION)
              @maintainer       = o[MAINTAINER] if o.has_key?(MAINTAINER)
      Severity: Minor
      Found in lib/ridley/chef/cookbook/metadata.rb - About 3 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Class Cookbook has 22 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Cookbook
          require_relative 'cookbook/metadata'
          require_relative 'cookbook/syntax_check'
      
          class << self
      Severity: Minor
      Found in lib/ridley/chef/cookbook.rb - About 2 hrs to fix

        Method validate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def validate(opts, map)
              #--
              # validate works by taking the keys in the validation map, assuming it's a hash, and
              # looking for _pv_:symbol as methods.  Assuming it find them, it calls the right
              # one.
        Severity: Minor
        Found in lib/ridley/mixin/params_validate.rb - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method build_query has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

              def build_query(query_string, options = {})
                {}.tap do |query_opts|
                  query_opts[:q]     = query_string unless query_string.nil?
                  query_opts[:sort]  = options[:sort] unless options[:sort].nil?
                  query_opts[:rows]  = options[:rows] unless options[:rows].nil?
        Severity: Minor
        Found in lib/ridley/resources/search_resource.rb - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method stream has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def stream(target, destination)
              FileUtils.mkdir_p(File.dirname(destination))
        
              target  = Addressable::URI.parse(target)
              headers = Middleware::ChefAuth.authentication_headers(
        Severity: Minor
        Found in lib/ridley/connection.rb - About 1 hr to fix

          Method initialize has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def initialize(cookbook = nil, maintainer = 'YOUR_COMPANY_NAME', maintainer_email = 'YOUR_EMAIL', license = 'none')
                  @cookbook = cookbook
                  @name = cookbook ? cookbook.name : ""
                  @long_description = ""
                  self.maintainer(maintainer)
          Severity: Minor
          Found in lib/ridley/chef/cookbook/metadata.rb - About 1 hr to fix

            Method upload has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def upload(sandbox, chk_id, file)
                  checksum = sandbox.checksum(chk_id)
            
                  unless checksum[:needs_upload]
                    return nil
            Severity: Minor
            Found in lib/ridley/sandbox_uploader.rb - About 1 hr to fix

              Method _pv_regex has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                    def _pv_regex(opts, key, regex)
                      value = _pv_opts_lookup(opts, key)
                      if value != nil
                        passes = false
                        [ regex ].flatten.each do |r|
              Severity: Minor
              Found in lib/ridley/mixin/params_validate.rb - About 1 hr to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Method initialize has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def initialize(server_url, client_name, client_key, options = {})
                    options         = options.reverse_merge(retries: 5, retry_interval: 0.5)
                    @client_name    = client_name
                    @client_key     = client_key
                    @retries        = options.delete(:retries)
              Severity: Minor
              Found in lib/ridley/connection.rb - About 1 hr to fix

                Method upload has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def upload(path, options = {})
                      options  = options.reverse_merge(validate: true, force: false, freeze: false)
                      cookbook = Ridley::Chef::Cookbook.from_path(path)
                
                      unless (existing = find(cookbook.cookbook_name, cookbook.version)).nil?
                Severity: Minor
                Found in lib/ridley/resources/cookbook_resource.rb - About 1 hr to fix

                  Method validate_choice_default_rule has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                          def validate_choice_default_rule(options)
                            return if !options[:choice].is_a?(Array) || options[:choice].empty?
                  
                            if options[:default].is_a?(String) && options[:default] != ""
                              raise ArgumentError, "Default must be one of your choice values!" if options[:choice].index(options[:default]) == nil
                  Severity: Minor
                  Found in lib/ridley/chef/cookbook/metadata.rb - About 1 hr to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Method initialize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def initialize(options = {})
                        @options = options.reverse_merge(
                          pool_size: 4
                        ).deep_symbolize_keys
                        self.class.validate_options(@options)
                  Severity: Minor
                  Found in lib/ridley/client.rb - About 1 hr to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Method stream has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def stream(target, destination)
                        FileUtils.mkdir_p(File.dirname(destination))
                  
                        target  = Addressable::URI.parse(target)
                        headers = Middleware::ChefAuth.authentication_headers(
                  Severity: Minor
                  Found in lib/ridley/connection.rb - About 1 hr to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Method upload has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def upload(sandbox, chk_id, file)
                        checksum = sandbox.checksum(chk_id)
                  
                        unless checksum[:needs_upload]
                          return nil
                  Severity: Minor
                  Found in lib/ridley/sandbox_uploader.rb - About 45 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Method load_root has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def load_root
                          [].tap do |files|
                            Dir.glob(path.join('*'), File::FNM_DOTMATCH).each do |file|
                              next if File.directory?(file)
                              next if ignored?(file)
                  Severity: Minor
                  Found in lib/ridley/chef/cookbook.rb - About 45 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Method _pv_equal_to has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def _pv_equal_to(opts, key, to_be)
                          value = _pv_opts_lookup(opts, key)
                          unless value.nil?
                            passes = false
                            Array(to_be).each do |tb|
                  Severity: Minor
                  Found in lib/ridley/mixin/params_validate.rb - About 45 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Method initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def initialize(server_url, client_name, client_key, options = {})
                        options         = options.reverse_merge(retries: 5, retry_interval: 0.5)
                        @client_name    = client_name
                        @client_key     = client_key
                        @retries        = options.delete(:retries)
                  Severity: Minor
                  Found in lib/ridley/connection.rb - About 45 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Method add has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def add(severity, message = nil, progname = nil, &block)
                          severity ||= Logger::UNKNOWN
                          if @logdev.nil? or severity < @level
                            return true
                          end
                  Severity: Minor
                  Found in lib/ridley/logger.rb - About 45 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Severity
                  Category
                  Status
                  Source
                  Language