Showing 460 of 460 total issues

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

        def self.data
          @data ||= Hash.new do |hash, key|
            hash[key] = {
              "vms" => [
                {
Severity: Major
Found in lib/fog/opennebula/compute.rb - About 2 hrs to fix

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

              if configuration = options[:Configuration]
                if ip_scopes = configuration[:IpScopes]
                  if ip_scope = ip_scopes[:IpScope]
                    [:IsInherited, :Gateway, :Netmask,
                      :Dns1, :Dns2, :DnsSuffix, :IsEnabled].each do |key|
    lib/fog/vcloud_director/requests/compute/put_network.rb on lines 113..131

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

    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

      module Compute
        class VcloudDirector
          class Real
            # Set the value for the specified metadata key to the value provided,
            # overwriting any existing value.
    lib/fog/vcloud_director/requests/compute/put_catalog_item_metadata_item_metadata.rb on lines 2..45
    lib/fog/vcloud_director/requests/compute/put_vapp_template_metadata_item_metadata.rb on lines 2..45

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

    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

      module Compute
        class VcloudDirector
          class Real
            # Set the value for the specified metadata key to the value provided,
            # overwriting any existing value.
    lib/fog/vcloud_director/requests/compute/put_catalog_item_metadata_item_metadata.rb on lines 2..45
    lib/fog/vcloud_director/requests/compute/put_media_metadata_item_metadata.rb on lines 2..45

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

    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

      module Compute
        class VcloudDirector
          class Real
            # Set the metadata value for the specified key to the value provided,
            # overwriting any existing value.
    lib/fog/vcloud_director/requests/compute/put_media_metadata_item_metadata.rb on lines 2..45
    lib/fog/vcloud_director/requests/compute/put_vapp_template_metadata_item_metadata.rb on lines 2..45

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

    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

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

              if configuration = options[:Configuration]
                if ip_scopes = configuration[:IpScopes]
                  if ip_scope = ip_scopes[:IpScope]
                    [:IsInherited, :Gateway, :Netmask,
                      :Dns1, :Dns2, :DnsSuffix, :IsEnabled].each do |key|
    Severity: Major
    Found in lib/fog/vcloud_director/requests/compute/put_network.rb and 1 other location - About 2 hrs to fix
    lib/fog/vcloud_director/requests/compute/post_create_org_vdc_network.rb on lines 111..129

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

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

            def media_body(id)
              media = data[:medias][id]
    
              body = {
                :size => media[:size].to_s,
    Severity: Minor
    Found in lib/fog/vcloud_director/requests/compute/get_media.rb - About 2 hrs to fix

      Method post_instantiate_vapp_template has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def post_instantiate_vapp_template(vdc_id, vapp_template_id, name, options={})
                unless data[:vdcs][vdc_id]
                  raise Fog::Compute::VcloudDirector::Forbidden.new(
                    "No access to entity \"(com.vmware.vcloud.entity.vdc:#{vdc_id})\"."
                  )

        Method generate_xml has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                  def generate_xml
                    body = Nokogiri::XML::Builder.new do |xml|
                      attrs = {
                        :xmlns => 'http://www.vmware.com/vcloud/v1.5',
                        'xmlns:ovf' => 'http://schemas.dmtf.org/ovf/envelope/1'

          Method class_for has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def self.class_for(key)
                  case key
                  when :auto_scaling
                    Fog::AWS::AutoScaling
                  when :beanstalk
          Severity: Minor
          Found in lib/fog/aws/service_mapper.rb - About 1 hr to fix

            Method disk_body has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def disk_body(id)
                      disk = data[:disks][id]
                      storage_class_id = disk[:vdc_storage_class]
            
                      body = {
            Severity: Minor
            Found in lib/fog/vcloud_director/requests/compute/get_disk.rb - About 1 hr to fix

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

                      def get_execute_query(type=nil, options={})
                        unless options[:fields].nil?
                          Fog::Mock.not_implemented("Fields are not yet implemented in get_execute_query Mock for #{type}")
                        end
              
              
              Severity: Minor
              Found in lib/fog/vcloud_director/requests/compute/get_execute_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 build_load_balancer_service has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                        def build_load_balancer_service(xml)
                          lb_config = @configuration[:LoadBalancerService]
                          return unless lb_config
              
                          xml.LoadBalancerService {

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

                    def available?
                      availability = true
                      for service in services
                        begin
                          service = self.class_for(service)
              Severity: Minor
              Found in lib/fog/bin.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_edge_gateway has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      def get_edge_gateway(id)
                        unless edge_gateway = data[:edge_gateways][id]
                          raise Fog::Compute::VcloudDirector::Forbidden.new(
                            "No access to entity \"(com.vmware.vcloud.entity.gateway:#{id})\""
                          )
              Severity: Minor
              Found in lib/fog/vcloud_director/requests/compute/get_edge_gateway.rb - About 1 hr to fix

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

                module Fog
                  module Compute
                    class Linode
                      class Servers < Fog::Collection
                        model Fog::Compute::Linode::Server
                Severity: Major
                Found in lib/fog/linode/models/compute/servers.rb and 1 other location - About 1 hr to fix
                lib/fog/linode/models/compute/stack_scripts.rb on lines 4..28

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

                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

                module Fog
                  module Compute
                    class Linode
                      class StackScripts < Fog::Collection
                        model Fog::Compute::Linode::StackScript
                Severity: Major
                Found in lib/fog/linode/models/compute/stack_scripts.rb and 1 other location - About 1 hr to fix
                lib/fog/linode/models/compute/servers.rb on lines 4..28

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

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

                        def get_vms_in_lease_from_query(options={})
                
                          if options.key?(:filter) && options[:filter] =~ /^href==([^;,]+)$/
                            href = $1
                            id = href.split('/').last

                  Method available? has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def available?
                        begin
                          availability=true unless Gem::Specification::find_by_name("opennebula").nil?
                        rescue Gem::LoadError
                          availability=false
                  Severity: Minor
                  Found in lib/fog/bin/opennebula.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 expand_commands has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                          def expand_commands(commands, params, args)
                            # For all params unless the ctid
                            # pass it to the command
                            params.keys.each do |k|
                              if (params[k]) && (k.to_s != 'ctid')
                  Severity: Minor
                  Found in lib/fog/openvz/compute.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