Showing 988 of 988 total issues

Method get_supported_versions has 1129 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def get_supported_versions
          body =
            {:xmlns=>"http://www.vmware.com/vcloud/versions",
             :xmlns_xsi=>xmlns_xsi,
             :xsi_schemaLocation=>xsi_schema_location,
Severity: Major
Found in lib/fog/vcloud_director/requests/compute/get_supported_versions.rb - About 5 days to fix

    File get_supported_versions.rb has 1150 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Fog
      module Compute
        class VcloudDirector
          class Real
            # List all supported versions.
    Severity: Major
    Found in lib/fog/vcloud_director/requests/compute/get_supported_versions.rb - About 2 days to fix

      Method build_source_items has a Cognitive Complexity of 144 (exceeds 5 allowed). Consider refactoring.
      Open

                def build_source_items(xml)
                  vms = @configuration[:source_vms]
                  vms.each do |vm|
                    xml.SourcedItem {
                      xml.Source(:name =>vm[:name], :href => vm[:href])
      Severity: Minor
      Found in lib/fog/vcloud_director/generators/compute/compose_common.rb - About 2 days 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_xml has a Cognitive Complexity of 140 (exceeds 5 allowed). Consider refactoring.
      Open

                def generate_xml
                  body = Nokogiri::XML::Builder.new do
                    attrs = {
                      :xmlns => 'http://www.vmware.com/vcloud/v1.5',
                      :name  => options[:name]
      Severity: Minor
      Found in lib/fog/vcloud_director/generators/compute/org_vdc_network.rb - About 2 days 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

      File compute.rb has 951 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'fog/cloudstack/core'
      require 'digest/md5'
      
      module Fog
        module Compute
      Severity: Major
      Found in lib/fog/cloudstack/compute.rb - About 2 days to fix

        File compute.rb has 800 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'fog/vcloud_director/core'
        require 'fog/vcloud_director/query'
        
        class VcloudDirectorParser < Fog::Parsers::Base
          def extract_attributes(attributes_xml)
        Severity: Major
        Found in lib/fog/vcloud_director/compute.rb - About 1 day to fix

          Method all_types has 328 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def all_types
                    {:xmlns=>xmlns,
                     :xmlns_xsi=>xmlns_xsi,
                     :type=>"application/vnd.vmware.vcloud.query.queryList+xml",
                     :href=>make_href('query'),
          Severity: Major
          Found in lib/fog/vcloud_director/requests/compute/get_execute_query.rb - About 1 day to fix

            Method post_instantiate_vapp_template has a Cognitive Complexity of 82 (exceeds 5 allowed). Consider refactoring.
            Open

                    def post_instantiate_vapp_template(id, vapp_template_id, name, 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',

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

                    def self.data
                      @data ||= begin
                        zone_id     = Fog.credentials[:cloudstack_zone_id]             || Fog::Cloudstack.uuid
                        image_id    = Fog.credentials[:cloudstack_template_id]         || Fog::Cloudstack.uuid
                        flavor_id   = Fog.credentials[:cloudstack_service_offering_id] || Fog::Cloudstack.uuid
            Severity: Major
            Found in lib/fog/cloudstack/compute.rb - About 1 day to fix

              File get_execute_query.rb has 630 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              module Fog
                module Compute
                  class VcloudDirector
                    class Real
                      # REST API General queries handler.
              Severity: Major
              Found in lib/fog/vcloud_director/requests/compute/get_execute_query.rb - About 1 day to fix

                Method data has 245 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        def data
                          @@data ||= Hash.new do |hash, key|
                
                            vdc1_uuid = uuid
                            vdc2_uuid = uuid
                Severity: Major
                Found in lib/fog/vcloud_director/compute.rb - About 1 day to fix

                  Method generate_configure_vm_request has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
                  Open

                          def generate_configure_vm_request(vm_data)
                            xmlns = 'http://schemas.dmtf.org/ovf/envelope/1'
                            xmlns_vcloud = 'http://www.vmware.com/vcloud/v1'
                            xmlns_rasd = 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData'
                            xmlns_vssd = 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData'
                  Severity: Minor
                  Found in lib/fog/vcloud/requests/compute/configure_vm.rb - About 1 day 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 vm_allocate has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
                  Open

                          def vm_allocate(attr={ })
                  
                            if(attr[:flavor].nil?)
                              raise(ArgumentError.new("Attribute flavor is nil! #{attr.inspect}"))
                            end
                  Severity: Minor
                  Found in lib/fog/opennebula/requests/compute/vm_allocate.rb - About 1 day 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 fetch_items has 216 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          def fetch_items(type, opts)
                            if opts.key?(:filter) && opts[:filter] =~ /^name==([^;,]+)$/
                              name = $1
                            elsif type == 'vAppTemplate' && opts.key?(:filter) &&
                              opts[:filter] =~ /^name==([^;,]+);catalogName==([^;,]+)$/ #TODO also match in other order
                  Severity: Major
                  Found in lib/fog/vcloud_director/requests/compute/get_execute_query.rb - About 1 day to fix

                    Method get_supported_systems_info has 208 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            def get_supported_systems_info
                              body = # this is a subset of the full list
                                {:xmlns=>xmlns,
                                 :xmlns_xsi=>xmlns_xsi,
                                 :type=>"application/vnd.vmware.vcloud.supportedSystemsInfo+xml",

                      Method put_guest_customization_section_vapp has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
                      Open

                              def put_guest_customization_section_vapp(id, options={})
                                options = options.dup
                      
                                # Mutate options to new format.
                                deprecated = {

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

                              def template_pool(filter = { })
                      
                                templates = ::OpenNebula::TemplatePool.new(client)
                                if filter[:id].nil?
                                  templates.info!(-2,-1,-1)
                      Severity: Minor
                      Found in lib/fog/opennebula/requests/compute/template_pool.rb - About 6 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

                      Method fetch_items has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
                      Open

                              def fetch_items(type, opts)
                                if opts.key?(:filter) && opts[:filter] =~ /^name==([^;,]+)$/
                                  name = $1
                                elsif type == 'vAppTemplate' && opts.key?(:filter) &&
                                  opts[:filter] =~ /^name==([^;,]+);catalogName==([^;,]+)$/ #TODO also match in other order
                      Severity: Minor
                      Found in lib/fog/vcloud_director/requests/compute/get_execute_query.rb - About 6 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

                      Method build_firewall_service has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
                      Open

                                def build_firewall_service(xml)
                                  firewall_config = @configuration[:FirewallService]
                                  return unless firewall_config
                      
                                  xml.FirewallService {

                      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

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

                        module Compute
                          class VcloudDirector
                            class Real
                              # Retrieves a list of vApps by using REST API general QueryHandler.
                              #
                      lib/fog/vcloud_director/requests/compute/get_catalogs_from_query.rb on lines 2..89
                      lib/fog/vcloud_director/requests/compute/get_disks_from_query.rb on lines 2..89
                      lib/fog/vcloud_director/requests/compute/get_groups_from_query.rb on lines 2..90
                      lib/fog/vcloud_director/requests/compute/get_medias_from_query.rb on lines 2..89
                      lib/fog/vcloud_director/requests/compute/get_organizations_from_query.rb on lines 2..90
                      lib/fog/vcloud_director/requests/compute/get_users_from_query.rb on lines 2..90
                      lib/fog/vcloud_director/requests/compute/get_vapp_templates_from_query.rb on lines 2..90
                      lib/fog/vcloud_director/requests/compute/get_vdcs_from_query.rb on lines 2..89

                      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 200.

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language