Showing 460 of 460 total issues

Similar blocks of code found in 4 locations. Consider refactoring.
Open

  module Compute
    class CloudSigma
      class Real
        def clone_server(server_id, clone_params={})
          request(:path => "servers/#{server_id}/action/",
Severity: Major
Found in lib/fog/cloudsigma/requests/clone_server.rb and 3 other locations - About 1 hr to fix
lib/fog/cloudsigma/requests/clone_libvolume.rb on lines 2..26
lib/fog/cloudsigma/requests/clone_snapshot.rb on lines 2..26
lib/fog/cloudsigma/requests/clone_volume.rb on lines 2..26

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 65.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method get_vdcs_from_query has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

        def get_vdcs_from_query(options={})
          query = []
          query << "sortAsc=#{options[:sortAsc]}" if options[:sortAsc]
          query << "sortDesc=#{options[:sortDesc]}" if options[:sortDesc]
          query << "page=#{options[:page]}" if options[:page]
Severity: Minor
Found in lib/fog/vcloud_director/requests/compute/get_vdcs_from_query.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_vms_in_lease_from_query has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

        def get_vms_in_lease_from_query(options={})
          query = []
          query << "sortAsc=#{options[:sortAsc]}" if options[:sortAsc]
          query << "sortDesc=#{options[:sortDesc]}" if options[:sortDesc]
          query << "page=#{options[:page]}" if options[:page]

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_execute_query has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def get_execute_query(type=nil, options={})
          if type.nil?
            response = request(
              :expects    => 200,
              :idempotent => true,
Severity: Minor
Found in lib/fog/vcloud_director/requests/compute/get_execute_query.rb - About 1 hr to fix

    Method mock_data has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def self.mock_data
              {
                :volumes => {},
                :servers => {},
                :vlans => {},
    Severity: Minor
    Found in lib/fog/cloudsigma/mock_data.rb - About 1 hr to fix

      Method build_vpn has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                def build_vpn(xml)
                  vpn_config = @configuration[:GatewayIpsecVpnService]
                  return unless vpn_config
      
                  xml.GatewayIpsecVpnService {

        Method task_body has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def task_body(id)
                  task = data[:tasks][id]
        
                  body = {
                    :href => make_href("tasks/#{id}"),
        Severity: Minor
        Found in lib/fog/vcloud_director/requests/compute/get_task.rb - About 1 hr to fix

          Method post_clone_media has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def post_clone_media(vdc_id, source_id, options={})
                    # TODO: check this happens.
                    unless source_media = data[:medias][source_id]
                      raise Fog::Compute::VcloudDirector::Forbidden.new(
                        "No access to entity \"(com.vmware.vcloud.entity.media:#{source_id})\"."
          Severity: Minor
          Found in lib/fog/vcloud_director/requests/compute/post_clone_media.rb - About 1 hr to fix

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

                def start
                    if is_running?
                        message="VNC server already running"
                        STDERR.puts message
                        @logger.info message
            Severity: Minor
            Found in lib/fog/opennebula/requests/compute/OpenNebulaVNC.rb - About 1 hr to fix

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

                      def post_capture_vapp(vdc_id, name, source_id, options={})
                        body = Nokogiri::XML::Builder.new do
                          attrs = {
                            :xmlns => 'http://www.vmware.com/vcloud/v1.5',
                            'xmlns:ovf' => 'http://schemas.dmtf.org/ovf/envelope/1',
              Severity: Minor
              Found in lib/fog/vcloud_director/requests/compute/post_capture_vapp.rb - About 1 hr to fix

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                  class << self
                    def class_for(key)
                      case key
                      when :compute
                        Fog::Compute::Openvz
                Severity: Major
                Found in lib/fog/bin/openvz.rb and 2 other locations - About 1 hr to fix
                lib/fog/bin/bare_metal_cloud.rb on lines 2..26
                lib/fog/bin/go_grid.rb on lines 2..26

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 61.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                  class << self
                    def class_for(key)
                      case key
                      when :compute
                        Fog::Compute::GoGrid
                Severity: Major
                Found in lib/fog/bin/go_grid.rb and 2 other locations - About 1 hr to fix
                lib/fog/bin/bare_metal_cloud.rb on lines 2..26
                lib/fog/bin/openvz.rb on lines 2..26

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 61.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        def request(params)
                          params[:query] ||= {}
                          params[:query].merge!(:api_key => @linode_api_key)
                
                          response = @connection.request(params)
                Severity: Major
                Found in lib/fog/linode/compute.rb and 1 other location - About 1 hr to fix
                lib/fog/linode/dns.rb on lines 64..82

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 61.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                  class << self
                    def class_for(key)
                      case key
                      when :compute
                        Fog::Compute::BareMetalCloud
                Severity: Major
                Found in lib/fog/bin/bare_metal_cloud.rb and 2 other locations - About 1 hr to fix
                lib/fog/bin/go_grid.rb on lines 2..26
                lib/fog/bin/openvz.rb on lines 2..26

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 61.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        def request(params)
                          params[:query] ||= {}
                          params[:query].merge!(:api_key => @linode_api_key)
                
                          response = @connection.request(params)
                Severity: Major
                Found in lib/fog/linode/dns.rb and 1 other location - About 1 hr to fix
                lib/fog/linode/compute.rb on lines 101..119

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 61.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Method end_element has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                          def end_element(name)
                            parse_end_element name, @response[:vm]
                            case name
                            when 'IpAddress'
                              @response[:vm][:ip_address] = value
                Severity: Minor
                Found in lib/fog/vcloud_director/parsers/compute/vm.rb - About 1 hr to fix

                  Method list_vms has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          def list_vms(filter={})
                            vms=[]
                            vmpool = ::OpenNebula::VirtualMachinePool.new(client)
                            if filter[:id].nil?
                              vmpool.info!(-2,-1,-1,-1)
                  Severity: Minor
                  Found in lib/fog/opennebula/requests/compute/list_vms.rb - About 1 hr to fix

                    Method mount_volume has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            def mount_volume(volume, device = 'virtio', dev_channel = nil, boot_order = nil)
                              unless dev_channel
                                specified_channels = self.volumes.map { |v| v.dev_channel }.sort
                                if specified_channels
                                  controller, controller_channel = 0, 0
                    Severity: Minor
                    Found in lib/fog/cloudsigma/models/server.rb - About 1 hr to fix

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

                              def post_update_disk_metadata(id, metadata={})
                                body = Nokogiri::XML::Builder.new do
                                  attrs = {
                                    :xmlns => 'http://www.vmware.com/vcloud/v1.5',
                                    'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance'

                      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 modify_instance has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                      Open

                              def modify_instance(instance_id, params={})
                                response = Excon::Response.new
                                if instance_exists? instance_id
                                  if params['state'] == 'restart'
                                    self.data[:instances][instance_id]["status"] = "8"
                      Severity: Minor
                      Found in lib/fog/ibm/requests/compute/modify_instance.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

                      Severity
                      Category
                      Status
                      Source
                      Language