cloudfoundry/cfoundry

View on GitHub

Showing 40 of 46 total issues

Method log_request has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def log_request(time, request, response)
      return unless @log

      data = log_data(time, request, response)

Severity: Minor
Found in lib/cfoundry/rest_client.rb - About 1 hr to fix

    Method succeed_to_load has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def succeed_to_load(options={})
            response_body = Helper.load_fixtures(options[:fixture] || "fake_cc_user")
            response_body["metadata"]["guid"] = options[:id] || "user-id-1"
    
            if options[:no_organizations]
    Severity: Minor
    Found in lib/cc_api_stub/users.rb - About 1 hr to fix

      Method value_matches? has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def value_matches?(val, type)
              return true if val.nil?
      
              case type
              when Class
      Severity: Minor
      Found in lib/cfoundry/validator.rb - About 1 hr to fix

        Method filter_protected_attributes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def filter_protected_attributes(hash_or_array)
              if hash_or_array.is_a? Array
                hash_or_array.each do |value|
                  filter_protected_attributes(value)
                end
        Severity: Minor
        Found in lib/cfoundry/trace_helpers.rb - About 55 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 proxy_options_for has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def proxy_options_for(uri)
              ssl = uri.is_a?(URI::HTTPS)
              proxy_to_use = (ssl ? https_proxy : http_proxy)
        
              if proxy_to_use.blank?
        Severity: Minor
        Found in lib/cfoundry/concerns/proxy_options.rb - About 55 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 token_data has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def token_data
              return @token_data if @token_data
              return {} unless @auth_header
        
              json_hashes = Base64.decode64(@auth_header.split(" ", 2).last)
        Severity: Minor
        Found in lib/cfoundry/auth_token.rb - About 55 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 value_matches? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def value_matches?(val, type)
                return true if val.nil?
        
                case type
                when Class
        Severity: Minor
        Found in lib/cfoundry/validator.rb - About 55 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 params_from has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.params_from(args)
              options, _ = args
              options ||= {}
              options[:depth] ||= 1
        
        
        Severity: Minor
        Found in lib/cfoundry/v2/model_magic.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 find_archives_in_path has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def find_archives_in_path(path)
              files = Array.new
              list = Array.new
              if File.file?(path)
                files << path
        Severity: Minor
        Found in lib/cfoundry/upload_helpers.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 percent_running has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def percent_running
              if state == "STARTED"
                healthy_count = running_instances
                expected = total_instances
        
        
        Severity: Minor
        Found in lib/cfoundry/v2/app.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 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def initialize(app_name, app_guid, id, client, manifest = {})
        Severity: Minor
        Found in lib/cfoundry/v2/app_instance.rb - About 35 mins to fix

          Method generate_headers has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def generate_headers(payload, options)
                headers = {}
          
                if payload.is_a?(String)
                  headers["Content-Length"] = payload.size
          Severity: Minor
          Found in lib/cfoundry/rest_client.rb - About 35 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 upload has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def upload(path, check_resources = true)
                unless File.exist? path
                  raise CFoundry::Error, "Invalid application path '#{path}'"
                end
          
          
          Severity: Minor
          Found in lib/cfoundry/upload_helpers.rb - About 35 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 has_summary has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def has_summary(actions = {})
                #
                # def summary
                #
                define_method(:summary) do
          Severity: Minor
          Found in lib/cfoundry/v2/model_magic/has_summary.rb - About 35 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

          Avoid too many return statements within this method.
          Open

                  return
          Severity: Major
          Found in lib/cfoundry/rest_client.rb - About 30 mins to fix

            Method unpack has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def unpack(file, dest)
                  ::Zip::ZipFile.foreach(file) do |zentry|
                    epath = "#{dest}/#{zentry}"
                    dirname = File.dirname(epath)
                    FileUtils.mkdir_p(dirname) unless File.exists?(dirname)
            Severity: Minor
            Found in lib/cfoundry/zip.rb - About 25 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 print_backtrace has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def print_backtrace(locs)
                  return unless @backtrace
            
                  interesting_locs = locs.drop_while { |loc|
                    loc =~ /\/(cfoundry\/|restclient\/|net\/http)/
            Severity: Minor
            Found in lib/cfoundry/rest_client.rb - About 25 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 stream_update_log has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def stream_update_log(log_url)
                  offset = 0
            
                  while true
                    begin
            Severity: Minor
            Found in lib/cfoundry/v2/app.rb - About 25 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 stream_url has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def stream_url(url, &blk)
                  uri = URI.parse(url)
            
                  opts = {}
                  
            Severity: Minor
            Found in lib/cfoundry/baseclient.rb - About 25 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 poll_upload_until_finished has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def poll_upload_until_finished(guid)
                  while true
                    response = get("v2", "jobs", guid, :accept => :json)
                    break if response[:entity][:status] == "finished"
            
            
            Severity: Minor
            Found in lib/cfoundry/v2/base.rb - About 25 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