fog/fog-ecloud

View on GitHub

Showing 92 of 165 total issues

Method node_service_create has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def node_service_create(service_data)
          validate_node_service_data(service_data)

          internet_service_id = service_data[:uri].match(/(\d+)/)[1]
          internet_service    = self.data[:internet_services][internet_service_id.to_i].dup
Severity: Minor
Found in lib/fog/compute/ecloud/requests/node_service_create.rb - About 1 hr to fix

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

            def get_servers(uri)
              if uri =~ /layoutgroups/i
                group_id        = id_from_uri(uri)
                group           = self.data[:groups][group_id]
                servers         = group[:VirtualMachines][:VirtualMachine]
    Severity: Minor
    Found in lib/fog/compute/ecloud/requests/get_servers.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 virtual_machine_edit_assigned_ips has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def virtual_machine_edit_assigned_ips(href, options)
              server_id       = href.match(/(\d+)/)[1].to_i
              server          = self.data[:servers][server_id]
              options.each do |network|
                network_id     = id_from_uri(network[:href])

      Method ssh_key_create has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def ssh_key_create(data)
                validate_data([:Name], data)
                ssh_key_id          = Fog::Mock.random_numbers(7).to_i
                ssh_key_fingerprint = ""
                (1..15).each do
      Severity: Minor
      Found in lib/fog/compute/ecloud/requests/ssh_key_create.rb - About 1 hr to fix

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

                def request(params)
                  # Convert the uri to a URI if it's a string.
                  if params[:uri].is_a?(String)
                    params[:uri] = URI.parse(@host + params[:uri])
                  end
        Severity: Minor
        Found in lib/fog/compute/ecloud.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 generate_internet_service_request has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

                def generate_internet_service_request(service_data)
                  xml = Builder::XmlMarkup.new
                  xml.CreateInternetService(:name => service_data[:name]) do
                    xml.Protocol service_data[:protocol]
                    xml.Port service_data[:port]
        Severity: Minor
        Found in lib/fog/compute/ecloud/requests/internet_service_create.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 get_templates has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def get_templates(uri) # /cloudapi/ecloud/computepools/compute_pools/534
                  compute_pool_id = id_from_uri(uri)
                  compute_pool    = self.data[:compute_pools][compute_pool_id]
        
                  templates = self.data[:templates].values.select{|template| template[:compute_pool_id] == compute_pool_id}
        Severity: Minor
        Found in lib/fog/compute/ecloud/requests/get_templates.rb - About 1 hr to fix

          Method request has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def request(params)
                    # Convert the uri to a URI if it's a string.
                    if params[:uri].is_a?(String)
                      params[:uri] = URI.parse(@host + params[:uri])
                    end
          Severity: Minor
          Found in lib/fog/compute/ecloud.rb - About 1 hr to fix

            Method virtual_machine_delete has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def virtual_machine_delete(uri)
                      server_id = id_from_uri(uri)
            
                      server = self.data[:servers][server_id]
                      self.data[:servers].delete(server_id)
            Severity: Minor
            Found in lib/fog/compute/ecloud/requests/virtual_machine_delete.rb - About 1 hr to fix

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

                      def virtual_machine_detach_disk(href, options)
                        server_id        = href.match(/(\d+)/)[1].to_i
                        server           = self.data[:servers][server_id]
                        compute_pool_id  = server[:compute_pool_id]
                        compute_pool     = self.data[:compute_pools][compute_pool_id]
              Severity: Minor
              Found in lib/fog/compute/ecloud/requests/virtual_machine_detach_disk.rb - About 1 hr to fix

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

                        def build_request_body_edit_hardware_configuration(data)
                          xml = Builder::XmlMarkup.new
                          xml.HardwareConfiguration do
                            xml.ProcessorCount data[:cpus]
                            xml.Memory do

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

                          def build_request_body_import(options)
                            xml = Builder::XmlMarkup.new
                            xml.ImportVirtualMachine(:name => options[:name]) do
                              xml.ProcessorCount options[:cpus]
                              xml.Memory do
                  Severity: Minor
                  Found in lib/fog/compute/ecloud/requests/virtual_machine_import.rb - About 1 hr to fix

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

                            def set_extra_headers_for(params)
                              length_required = ["PUT", "POST", "DELETE"]
                              params[:headers] = {
                                "x-tmrk-version" => @version,
                                "Date"           => Time.now.utc.strftime("%a, %d %b %Y %H:%M:%S GMT"),
                    Severity: Minor
                    Found in lib/fog/compute/ecloud.rb - About 1 hr to fix

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

                              def all
                                data = service.get_catalog(href).body # [:Locations][:Location][:Catalog][:CatalogEntry]
                                if data[:Locations][:Location].is_a?(Hash)
                                  data = [] if data[:Locations][:Location][:Catalog].is_a?(String) && data[:Locations][:Location][:Catalog].empty?
                                  load(data)
                      Severity: Minor
                      Found in lib/fog/compute/ecloud/models/catalog.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 slurp has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              def self.slurp(error)
                                data = nil
                                message = nil
                                status_code = nil
                                minor_code = nil
                      Severity: Minor
                      Found in lib/fog/compute/ecloud/errors.rb - About 1 hr to fix

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

                                def delete_ip(options)
                                  slice_ips = begin
                                                ips
                                              rescue
                                                []
                        Severity: Minor
                        Found in lib/fog/compute/ecloud/models/server.rb - About 1 hr to fix

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

                                  def get_servers(uri)
                                    if uri =~ /layoutgroups/i
                                      group_id        = id_from_uri(uri)
                                      group           = self.data[:groups][group_id]
                                      servers         = group[:VirtualMachines][:VirtualMachine]
                          Severity: Minor
                          Found in lib/fog/compute/ecloud/requests/get_servers.rb - About 1 hr to fix

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

                                    def internet_service_create(service_data)
                                      validate_internet_service_data(service_data)
                                      public_ip_id = service_data[:uri].match(/(\d+)/)[1]
                                      public_ip    = self.data[:public_ips][public_ip_id.to_i].dup
                                      service_id   = Fog::Mock.random_numbers(6).to_i
                            Severity: Minor
                            Found in lib/fog/compute/ecloud/requests/internet_service_create.rb - About 1 hr to fix

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

                                      def all
                                        data = []
                                        raw_location = service.get_organization(href).body[:Locations][:Location]
                                        if raw_location.is_a?(Array)
                                          # If there's more than one location, the XML parser returns an
                              Severity: Minor
                              Found in lib/fog/compute/ecloud/models/environments.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 validate_create_server_options has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                              Open

                                      def validate_create_server_options(template_uri, options)
                                        required_opts = [:name, :cpus, :memory, :row, :group, :customization, :network_uri]
                                        if options[:customization] == :windows
                                          required_opts.push(:windows_password)
                                        else
                              Severity: Minor
                              Found in lib/fog/compute/ecloud/requests/virtual_machine_create_from_template.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