fog/fog-proxmox

View on GitHub

Showing 14 of 60 total issues

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

      class Server < Fog::Compute::Server
        identity  :vmid
        attribute :type
        attribute :node_id
        attribute :config
Severity: Minor
Found in lib/fog/proxmox/compute/models/server.rb - About 3 hrs to fix

    Method list_servers has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def list_servers(_options = {})
              if options[:type] == 'qemu'
                [
                  {
                    'vmid' => '100',
    Severity: Major
    Found in lib/fog/proxmox/compute/requests/list_servers.rb - About 2 hrs to fix

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

            def self.flatten(disk)
              id = disk[:id]
              value = ''
              if disk[:volid]
                value += disk[:volid]
      Severity: Minor
      Found in lib/fog/proxmox/helpers/disk_helper.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 request has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

            def request(params)
              retried = false
              begin
                authenticate! if expired?
                request_options = params.merge(path: "#{@path}/#{params[:path]}",
      Severity: Minor
      Found in lib/fog/proxmox/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 start_console has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

              def start_console(options = {})
                unless ready?
                  raise ::Fog::Proxmox::Errors::ServiceError,
                        'Unable to start console because server not running.'
                end
      Severity: Minor
      Found in lib/fog/proxmox/compute/models/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 start_console has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def start_console(options = {})
                unless ready?
                  raise ::Fog::Proxmox::Errors::ServiceError,
                        'Unable to start console because server not running.'
                end
      Severity: Minor
      Found in lib/fog/proxmox/compute/models/server.rb - About 1 hr to fix

        Method request has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def request(params)
                retried = false
                begin
                  authenticate! if expired?
                  request_options = params.merge(path: "#{@path}/#{params[:path]}",
        Severity: Minor
        Found in lib/fog/proxmox/core.rb - About 1 hr to fix

          Method setup has a Cognitive Complexity of 9 (exceeds 5 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/proxmox/core.rb - About 55 mins 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 extract_storage_volid_size has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def self.extract_storage_volid_size(disk_value)
                  # volid definition: <VOLUME_ID>:=<STORAGE_ID>:<storage type dependent volume name>
                  values_a = disk_value.scan(%r{^(([\w-]+):{0,1}([\w/.-]+))})
                  no_cdrom = !disk_value.match(CDROM_REGEXP)
                  creation = disk_value.split(',')[0].match(/^(([\w-]+):{1}(\d+))$/)
          Severity: Minor
          Found in lib/fog/proxmox/helpers/disk_helper.rb - About 55 mins 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 flatten has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def self.flatten(cpu_h)
                  return '' unless cpu_h['cpu_type']
          
                  cpu_type = "cputype=#{cpu_h['cpu_type']}"
                  num_flags = 0
          Severity: Minor
          Found in lib/fog/proxmox/helpers/cpu_helper.rb - About 55 mins 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 set_mac has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def self.set_mac(nic_id, nic_hash)
                  mac_keys = %i[macaddr hwaddr]
                  nic_value = ''
                  if (nic_hash.keys & mac_keys).empty?
                    nic_value = nic_name(nic_hash) + '=' + nic_id
          Severity: Minor
          Found in lib/fog/proxmox/helpers/nic_helper.rb - About 35 mins 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 missing_credentials has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                    def missing_credentials(options)
                      missing_credentials = []
                      missing_credentials << :proxmox_userid unless options[:proxmox_userid]
                      missing_credentials << :proxmox_tokenid unless options[:proxmox_tokenid]
                      missing_credentials << :proxmox_token unless options[:proxmox_token]
          Severity: Minor
          Found in lib/fog/proxmox/auth/token/user_token.rb - About 35 mins 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 flag_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def self.flag_value(cpu, flag_key)
                  flag_value = '0'
                  raw_values = extract_flags(cpu).split(';').select { |flag| ['+' + flag_key, '-' + flag_key].include?(flag) }
                  unless raw_values.empty?
                    flag_value = if raw_values[0].start_with?('+')
          Severity: Minor
          Found in lib/fog/proxmox/helpers/cpu_helper.rb - About 25 mins 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 flatten has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def self.flatten(nic_hash)
                  if nic_hash[:hwaddr].nil?
                    nic_id = nic_hash[nic_name(nic_hash).to_sym]
                    nic_value = set_mac(nic_id, nic_hash)
                    options = nic_hash.reject do |key, _value|
          Severity: Minor
          Found in lib/fog/proxmox/helpers/nic_helper.rb - About 25 mins 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