fog/fog-openstack

View on GitHub

Showing 616 of 616 total issues

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

        def delete_server(server_id)
          response = Excon::Response.new
          server = list_servers_detail.body['servers'].find { |srv| srv['id'] == server_id }
          if server
            if server['status'] == 'BUILD'
Severity: Minor
Found in lib/fog/openstack/compute/requests/delete_server.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 list_resources has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def list_resources(options = {}, options_deprecated = {})
          if options.kind_of?(Hash)
            if !options.key?(:stack) && !(options.key?(:stack_name) && options.key?(:stack_id))
              raise(ArgumentError, "Missing required options keys: :stack or :stack_name and :stack_id, while calling "\
                                   " .list_resources(options)")
Severity: Minor
Found in lib/fog/openstack/orchestration/requests/list_resources.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 list_bays has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def list_bays
          response = Excon::Response.new
          response.status = 200
          response.body = {
            "bays" => [
Severity: Minor
Found in lib/fog/openstack/container_infra/requests/list_bays.rb - About 1 hr to fix

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

            def create_security_group(options = {})
              # Spaces are NOT removed from name and description, as in case of compute sec groups
              tenant_id     = Fog::Mock.random_numbers(14).to_s
              sec_group_id  = Fog::UUID.uuid
    
    
    Severity: Minor
    Found in lib/fog/openstack/network/requests/create_security_group.rb - About 1 hr to fix

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

              def update_cluster_template(_uuid_or_name, _params)
                response = Excon::Response.new
                response.status = 200
                response.body = {
                  "insecure_registry"     => nil,

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

                def create_cluster_template(_params)
                  response = Excon::Response.new
                  response.status = 201
                  response.body = {
                    "insecure_registry"     => nil,

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

                  def create_bay_model(_params)
                    response = Excon::Response.new
                    response.status = 201
                    response.body = {
                      "insecure_registry"     => nil,
          Severity: Minor
          Found in lib/fog/openstack/container_infra/requests/create_bay_model.rb - About 1 hr to fix

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

                  def setup(options)
                    if options.respond_to?(:config_service?) && options.config_service?
                      configure(options)
                      return
                    end
            Severity: Minor
            Found in lib/fog/openstack/core.rb - About 1 hr to fix

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

                      def get_bay_model(_uuid_or_name)
                        response = Excon::Response.new
                        response.status = 200
                        response.body = {
                          "insecure_registry"     => nil,
              Severity: Minor
              Found in lib/fog/openstack/container_infra/requests/get_bay_model.rb - About 1 hr to fix

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

                        def update_bay_model(_uuid_or_name, _params)
                          response = Excon::Response.new
                          response.status = 200
                          response.body = {
                            "insecure_registry"     => nil,
                Severity: Minor
                Found in lib/fog/openstack/container_infra/requests/update_bay_model.rb - About 1 hr to fix

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

                          def get_cluster_template(_uuid_or_name)
                            response = Excon::Response.new
                            response.status = 200
                            response.body = {
                              "insecure_registry"     => nil,
                  Severity: Minor
                  Found in lib/fog/openstack/container_infra/requests/get_cluster_template.rb - About 1 hr to fix

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

                      module OpenStack
                        class Compute
                          class Real
                            def get_image_details(image_id)
                              request(
                    Severity: Major
                    Found in lib/fog/openstack/compute/requests/get_image_details.rb and 1 other location - About 1 hr to fix
                    lib/fog/openstack/compute/requests/get_server_details.rb on lines 2..24

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

                    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 OpenStack
                        class Compute
                          class Real
                            def get_server_details(server_id)
                              request(
                    Severity: Major
                    Found in lib/fog/openstack/compute/requests/get_server_details.rb and 1 other location - About 1 hr to fix
                    lib/fog/openstack/compute/requests/get_image_details.rb on lines 2..24

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

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

                            def create_stack(arg1, arg2 = nil)
                              if arg1.kind_of?(Hash)
                                # Normal use: create_stack(options)
                                options = arg1
                              else
                    Severity: Minor
                    Found in lib/fog/openstack/orchestration/requests/create_stack.rb - About 1 hr to fix

                      Method create_router has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              def create_router(name, options = {})
                                data = {
                                  'router' => {
                                    'name' => name,
                                  }
                      Severity: Minor
                      Found in lib/fog/openstack/network/requests/create_router.rb - About 1 hr to fix

                        Method create_flavor has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                def create_flavor(attributes)
                                  response = Excon::Response.new
                                  response.status = 200
                                  response.headers = {
                                    "X-Compute-Request-Id" => "req-fdc6f99e-55a2-4ab1-8904-0892753828cf",
                        Severity: Minor
                        Found in lib/fog/openstack/compute/requests/create_flavor.rb - About 1 hr to fix

                          Method create_image has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                    def create_image(attributes)
                                      data = {
                                        'Content-Type'                  => 'application/octet-stream',
                                        'x-image-meta-name'             => attributes[:name],
                                        'x-image-meta-disk-format'      => attributes[:disk_format],
                          Severity: Minor
                          Found in lib/fog/openstack/image/v1/requests/create_image.rb - About 1 hr to fix

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

                                    def save(options = {})
                                      requires :directory, :key
                                      options['Cache-Control'] = cache_control if cache_control
                                      options['Content-Type'] = content_type if content_type
                                      options['Content-Disposition'] = content_disposition if content_disposition
                            Severity: Minor
                            Found in lib/fog/openstack/storage/models/file.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 update_stack has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                                    def update_stack(arg1, arg2 = nil, arg3 = nil)
                                      if arg1.kind_of?(Stack)
                                        # Normal use, update_stack(stack, options = {})
                                        stack = arg1
                                        stack_name = stack.stack_name
                            Severity: Minor
                            Found in lib/fog/openstack/orchestration/requests/update_stack.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 create_stack has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                                    def create_stack(arg1, arg2 = nil)
                                      if arg1.kind_of?(Hash)
                                        # Normal use: create_stack(options)
                                        options = arg1
                                      else
                            Severity: Minor
                            Found in lib/fog/openstack/orchestration/requests/create_stack.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