fog/fog-google

View on GitHub

Showing 132 of 331 total issues

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

        def self.data(api_version)
          @data ||= Hash.new do |hash, key|
            case key
            when "debian-cloud"
              hash[key] =
Severity: Major
Found in lib/fog/compute/google/mock.rb - About 4 days to fix

    File mock.rb has 835 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Fog
      module Compute
        class Google
          class Mock
            include Fog::Google::Shared
    Severity: Major
    Found in lib/fog/compute/google/mock.rb - About 2 days to fix

      File server.rb has 353 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require "fog/compute/models/server"
      
      module Fog
        module Compute
          class Google
      Severity: Minor
      Found in lib/fog/compute/google/models/server.rb - About 4 hrs to fix

        Method get_object has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

                def get_object(bucket_name, object_name, options = {})
                  raise ArgumentError.new("bucket_name is required") unless bucket_name
                  raise ArgumentError.new("object_name is required") unless object_name
                  response = Excon::Response.new
                  if (bucket = data[:buckets][bucket_name]) && (object = bucket[:objects][object_name])
        Severity: Minor
        Found in lib/fog/storage/google_xml/requests/get_object.rb - About 4 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

        Class Server has 33 methods (exceeds 20 allowed). Consider refactoring.
        Open

              class Server < Fog::Compute::Server
                identity :name
        
                # @return [Boolean]
                attribute :can_ip_forward, :aliases => "canIpForward"
        Severity: Minor
        Found in lib/fog/compute/google/models/server.rb - About 4 hrs to fix

          Method test has 88 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          def test
            # Config
            name = "fog-lb-test-#{Time.now.to_i}"
            zone = "europe-west1-d"
            region = "europe-west1"
          Severity: Major
          Found in examples/load-balance.rb - About 3 hrs to fix

            Method end_element has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

                      def end_element(name)
                        case name
                        when "DeleteMarker"
                          @response["Versions"] << { "DeleteMarker" => @delete_marker }
                          @delete_marker = { "Owner" => {} }
            Severity: Minor
            Found in lib/fog/parsers/storage/google/get_bucket_object_versions.rb - About 3 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

            Class Instance has 26 methods (exceeds 20 allowed). Consider refactoring.
            Open

                  class Instance < Fog::Model
                    identity :name
            
                    attribute :current_disk_size, :aliases => "currentDiskSize"
                    attribute :database_version, :aliases => "databaseVersion"
            Severity: Minor
            Found in lib/fog/google/models/sql/instance.rb - About 3 hrs to fix

              Method test has 68 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              def test
                connection = Fog::Compute.new(:provider => "google")
                health = connection.http_health_checks.create(:name => "test-checks")
                instance1 = connection.servers.get("fog-l7-instance-1")
                instance2 = connection.servers.get("fog-l7-instance-2")
              Severity: Major
              Found in examples/l7_load_balance.rb - About 2 hrs to fix

                Method example has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                def example
                  p "Connecting to Google API"
                  connection = Fog::Compute.new(:provider => "Google")
                
                  p "Creating disk"
                Severity: Major
                Found in examples/create_instance_and_attach_disk_later.rb - About 2 hrs to fix

                  Method acls has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          def self.acls(type)
                            case type
                            when "private"
                              {
                                "AccessControlList" => [
                  Severity: Major
                  Found in lib/fog/storage/google_xml/mock.rb - About 2 hrs to fix

                    Method get has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                    Open

                            def get(identity, project = nil)
                              if project
                                begin
                                  image = service.get_image(identity, project).to_h
                                  # TODO: Remove response modification - see #405
                    Severity: Minor
                    Found in lib/fog/compute/google/models/images.rb - About 2 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 end_element has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                              def end_element(name)
                                case name
                                when "DeleteMarker"
                                  @response["Versions"] << { "DeleteMarker" => @delete_marker }
                                  @delete_marker = { "Owner" => {} }
                    Severity: Major
                    Found in lib/fog/parsers/storage/google/get_bucket_object_versions.rb - About 2 hrs to fix

                      File google.rb has 257 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      module Fog
                        module Compute
                          class Google < Fog::Service
                            autoload :Mock, File.expand_path("../google/mock", __FILE__)
                            autoload :Real, File.expand_path("../google/real", __FILE__)
                      Severity: Minor
                      Found in lib/fog/compute/google.rb - About 2 hrs to fix

                        Method example has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        def example
                          p "Connecting to Google API"
                          connection = Fog::Compute.new(:provider => "Google")
                        
                          p "Creating disk"
                        Severity: Major
                        Found in examples/create_instance.rb - About 2 hrs to fix

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

                                  def get(identity, zone = nil)
                                    if zone
                                      disk = service.get_disk(identity, zone).to_h
                          
                                      # Force the hash to contain a :users key so that it will override any :users key in the existing object
                          Severity: Minor
                          Found in lib/fog/compute/google/models/disks.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_bucket has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                          Open

                                  def get_bucket(bucket_name, options = {})
                                    raise ArgumentError.new("bucket_name is required") unless bucket_name
                                    response = Excon::Response.new
                                    name = /(\w+\.?)*/.match(bucket_name)
                                    if bucket_name == name.to_s
                          Severity: Minor
                          Found in lib/fog/storage/google_xml/requests/get_bucket.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 example has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def example
                            p "Connecting to Google API"
                            connection = Fog::Compute.new(:provider => "Google")
                          
                            p "Creating disk"
                          Severity: Minor
                          Found in examples/create_instance_and_attach_disk_later.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 put_object has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                          Open

                                  def put_object(bucket_name, object_name, data, options = {})
                                    acl = options["x-goog-acl"] || "private"
                                    if !Utils::VALID_ACLS.include?(acl)
                                      raise Excon::Errors::BadRequest.new("invalid x-goog-acl")
                                    else
                          Severity: Minor
                          Found in lib/fog/storage/google_xml/requests/put_object.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_bucket has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                  def get_bucket(bucket_name, options = {})
                                    raise ArgumentError.new("bucket_name is required") unless bucket_name
                                    response = Excon::Response.new
                                    name = /(\w+\.?)*/.match(bucket_name)
                                    if bucket_name == name.to_s
                          Severity: Minor
                          Found in lib/fog/storage/google_xml/requests/get_bucket.rb - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language