fog/fog-openstack

View on GitHub

Showing 156 of 616 total issues

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

      def request(params, parse_json = true)
        retried = false
        begin
          authenticate! if @expires && (@expires - Time.now.utc).to_i < 60

Severity: Minor
Found in lib/fog/openstack/core.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_cluster_templates has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def list_cluster_templates
          response = Excon::Response.new
          response.status = 200
          response.body = {
            "clustertemplates" => [

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

            def get_plan(_parameters = nil)
              response = Excon::Response.new
              response.status = [200, 204][rand(2)]
              response.body = {
                "created_at"  => "2014-09-26T20:23:14.222815",
    Severity: Minor
    Found in lib/fog/openstack/planning/requests/get_plan.rb - About 1 hr to fix

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

          def self.extract_version_from_body(body, supported_versions)
            versions = []
            unless body['versions'].nil? || body['versions'].empty?
              versions = body['versions'].kind_of?(Array) ? body['versions'] : body['versions']['values']
            end
      Severity: Minor
      Found in lib/fog/openstack.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 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

                        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

                                Severity
                                Category
                                Status
                                Source
                                Language