unixorn/sourdough

View on GitHub

Showing 6 of 28 total issues

Function volumeTag has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

def volumeTag():
  '''
  Read Volume tags and determine the Disk Bus number and Unit number

  Write those values into /etc/device-volumes.d directory
Severity: Minor
Found in sourdough/sourdough.py - 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

Avoid deeply nested control flow statements.
Open

          if type(d).__name__ == 'vim.vm.device.VirtualDisk' and re.match(pattern, d.backing.fileName):
            this.logger.info("Found disk match %s", d.backing.fileName)
            disk = d
          else:
            this.logger.info("Did not find disk")
Severity: Major
Found in sourdough/sourdough.py - About 45 mins to fix

    Function loadVSphereSettings has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def loadVSphereSettings(knobName=DEFAULT_VSPHERE_KNOB, knobDirectory=DEFAULT_KNOB_DIRECTORY):
      '''
      Load cached vSphere settings. If there's no cache, use detectVSphereHost
      to create one.
    
    
    Severity: Minor
    Found in sourdough/sourdough.py - About 45 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

    Avoid deeply nested control flow statements.
    Open

              for c in vm.config.hardware.device:
                if c.key == disk.controllerKey:
                   controller = c
              file_content = "scsi:{}:{}".format(str(controller.busNumber), str(disk.unitNumber))
    Severity: Major
    Found in sourdough/sourdough.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                with open(file_path, 'w') as f:
                  f.write(file_content)
              else:
      Severity: Major
      Found in sourdough/sourdough.py - About 45 mins to fix

        Function writeVSphereSettings has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def writeVSphereSettings(knobName=DEFAULT_VSPHERE_KNOB, knobDirectory=DEFAULT_KNOB_DIRECTORY, hostname=None, username=None, password=None):
        Severity: Minor
        Found in sourdough/sourdough.py - About 35 mins to fix
          Severity
          Category
          Status
          Source
          Language