fog/fog-vsphere

View on GitHub
lib/fog/vsphere/compute.rb

Summary

Maintainability
F
4 days
Test Coverage

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

require 'digest/sha2'
# rubocop:disable Lint/RescueWithoutErrorClass
# rubocop:disable Metrics/ModuleLength
module Fog
  module Vsphere
Severity: Major
Found in lib/fog/vsphere/compute.rb - About 1 day to fix

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

            def self.data
              @data ||= Hash.new do |hash, key|
                hash[key] = {
                  servers: {
                    '5032c8a5-9c5e-ba7a-3804-832a03e16381' => {
    Severity: Major
    Found in lib/fog/vsphere/compute.rb - About 1 day to fix

      Method props_to_attr_hash has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
      Open

              def props_to_attr_hash(vm_mob_ref, props)
                # NOTE: Object.tap is in 1.8.7 and later.
                # Here we create the hash object that this method returns, but first we need
                # to add a few more attributes that require additional calls to the vSphere
                # API. The hypervisor name and mac_addresses attributes may not be available
      Severity: Minor
      Found in lib/fog/vsphere/compute.rb - About 5 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 props_to_attr_hash has 62 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def props_to_attr_hash(vm_mob_ref, props)
                # NOTE: Object.tap is in 1.8.7 and later.
                # Here we create the hash object that this method returns, but first we need
                # to add a few more attributes that require additional calls to the vSphere
                # API. The hypervisor name and mac_addresses attributes may not be available
      Severity: Major
      Found in lib/fog/vsphere/compute.rb - About 2 hrs to fix

        Method connect has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def connect
                  # This is a state variable to allow digest validation of the SSL cert
                  bad_cert = false
                  loop do
                    begin
        Severity: Minor
        Found in lib/fog/vsphere/compute.rb - About 1 hr to fix

          Method connect has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                  def connect
                    # This is a state variable to allow digest validation of the SSL cert
                    bad_cert = false
                    loop do
                      begin
          Severity: Minor
          Found in lib/fog/vsphere/compute.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

          There are no issues that match your filters.

          Category
          Status