fog/fog-profitbricks

View on GitHub

Showing 41 of 140 total issues

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

        def self.data
          dc1_id   = Fog::UUID.uuid
          dc2_id   = Fog::UUID.uuid
          serv1_id = Fog::UUID.uuid
          vol1_id  = Fog::UUID.uuid
Severity: Major
Found in lib/fog/profitbricks/compute.rb - About 5 days to fix

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

    module Fog
      module Compute
        class ProfitBricks < Fog::Service
          API_VERSION = 'v4'.freeze
    
    
    Severity: Major
    Found in lib/fog/profitbricks/compute.rb - About 3 days to fix

      Method create_server has 123 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def create_server(datacenter_id, properties = {}, entities = {})
                if properties[:cores] == nil
                  raise Excon::Error::HTTPStatus, "Attribute 'cores' is required"
                end
      
      
      Severity: Major
      Found in lib/fog/profitbricks/requests/compute/create_server.rb - About 4 hrs to fix

        Method create_datacenter has 66 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def create_datacenter(options, entities={})
                  dc = {
                    :properties => options,
                    :entities => entities
                  }
        Severity: Major
        Found in lib/fog/profitbricks/requests/compute/create_datacenter.rb - About 2 hrs to fix

          Method get_firewall_rules has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

                  def get_firewall_rules(firewall_rules)
                    items = []
                    for firewall_rule in firewall_rules do
                      item = {}
                      item[:name]           = firewall_rule[:name] if firewall_rule.key?(:name)
          Severity: Minor
          Found in lib/fog/profitbricks/models/compute/server.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 get_firewall_rules has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

                  def get_firewall_rules(firewall_rules)
                    items = []
                    firewall_rules.each do |firewall_rule|
                      item = {}
                      item[:name]           = firewall_rule[:name] if firewall_rule.key?(:name)
          Severity: Minor
          Found in lib/fog/profitbricks/models/compute/nic.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

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

                class Server < Fog::Models::ProfitBricks::Base
                  include Fog::Helpers::ProfitBricks::DataHelper
          
                  identity  :id
          
          
          Severity: Minor
          Found in lib/fog/profitbricks/models/compute/server.rb - About 2 hrs to fix

            Method get_all_flavors has 55 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def get_all_flavors
                      response = Excon::Response.new
                      response.status = 200
                      response.body   = {
                        'getAllFlavorsResponse' => [
            Severity: Major
            Found in lib/fog/profitbricks/requests/compute/get_all_flavors.rb - About 2 hrs to fix

              Method get_flavor has 55 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      def get_flavor(flavor_id)
                        response        = Excon::Response.new
                        response.status = 200
                        response.body   = {
                          "getFlavorResponse" => [
              Severity: Major
              Found in lib/fog/profitbricks/requests/compute/get_flavor.rb - About 2 hrs to fix

                Method create_volume has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        def create_volume(datacenter_id, options = {})
                          response = Excon::Response.new
                          response.status = 202
                
                          if options[:size] == nil
                Severity: Minor
                Found in lib/fog/profitbricks/requests/compute/create_volume.rb - About 2 hrs to fix

                  Method create_user has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          def create_user(options = {})
                            if options[:email] == nil
                              raise Excon::Error::HTTPStatus, "Attribute 'email' is required"
                            end
                  
                  
                  Severity: Minor
                  Found in lib/fog/profitbricks/requests/compute/create_user.rb - About 1 hr to fix

                    Method create_volume_snapshot has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            def create_volume_snapshot(datacenter_id, _volume_id, options = {})
                              response = Excon::Response.new
                              response.status = 202
                    
                              if datacenter = data[:datacenters]['items'].find do |attrib|
                    Severity: Minor
                    Found in lib/fog/profitbricks/requests/compute/create_volume_snapshot.rb - About 1 hr to fix

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

                              def update
                                requires :id
                      
                                options = {}
                                options[:name]                = name if name
                      Severity: Minor
                      Found in lib/fog/profitbricks/models/compute/snapshot.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_nics has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                              def get_nics(nics)
                                items = []
                                for nic in nics do
                                  firewall_rules = nil
                                  item = {}
                      Severity: Minor
                      Found in lib/fog/profitbricks/models/compute/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 update has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                              def update
                                requires :id
                      
                                options = {}
                                options[:name]                 = name if name
                      Severity: Minor
                      Found in lib/fog/profitbricks/models/compute/image.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_lan has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              def create_lan(datacenter_id, properties = {}, _entities = {})
                                response = Excon::Response.new
                                response.status = 202
                      
                                if datacenter = data[:datacenters]['items'].find do |attrib|
                      Severity: Minor
                      Found in lib/fog/profitbricks/requests/compute/create_lan.rb - About 1 hr to fix

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

                                def create_group(options = {})
                                  if options[:name] == nil
                                    raise Excon::Error::HTTPStatus, "Attribute 'name' is required"
                                  end
                        
                        
                        Severity: Minor
                        Found in lib/fog/profitbricks/requests/compute/create_group.rb - About 1 hr to fix

                          Method attach_volume has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                  def attach_volume(datacenter_id, server_id, storage_id)
                                    if volume = data[:volumes]['items'].find do |vlm|
                                      vlm["id"] == storage_id && vlm["datacenter_id"] == datacenter_id
                                    end
                                    else
                          Severity: Minor
                          Found in lib/fog/profitbricks/requests/compute/attach_volume.rb - About 1 hr to fix

                            Method create_firewall_rule has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                    def create_firewall_rule(datacenter_id, server_id, nic_id, options = {})
                                      response = Excon::Response.new
                                      response.status = 202
                            
                                      properties = {}
                            Severity: Minor
                            Found in lib/fog/profitbricks/requests/compute/create_firewall_rule.rb - About 1 hr to fix

                              Method attach_cdrom has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                      def attach_cdrom(datacenter_id, server_id, cdrom_image_id)
                                        if cdrom = data[:images]['items'].find do |cd|
                                          cd["id"] == cdrom_image_id
                                        end
                                        else
                              Severity: Minor
                              Found in lib/fog/profitbricks/requests/compute/attach_cdrom.rb - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language