CiscoUcs/imcsdk

View on GitHub
imcsdk/apis/v2/server/vmedia.py

Summary

Maintainability
F
1 wk
Test Coverage

File vmedia.py has 458 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2016 Cisco Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Severity: Minor
Found in imcsdk/apis/v2/server/vmedia.py - About 7 hrs to fix

    Function vmedia_mount_create_all has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
    Open

    def vmedia_mount_create_all(handle, mappings = None, server_id=1, timeout=60):
        """
            This method will make one request to create all the vmedia mappings
            Args:
                handle (ImcHandle)
    Severity: Minor
    Found in imcsdk/apis/v2/server/vmedia.py - About 6 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

    Function vmedia_mount_iso_uri has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    def vmedia_mount_iso_uri(handle, uri, user_id=None, password=None,
                             timeout=60, interval=5, server_id=1):
        """
        This method will setup the vmedia mapping
        Args:
    Severity: Minor
    Found in imcsdk/apis/v2/server/vmedia.py - 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

    Function vmedia_mount_create has 10 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def vmedia_mount_create(handle, volume_name, remote_share, remote_file,
    Severity: Major
    Found in imcsdk/apis/v2/server/vmedia.py - About 1 hr to fix

      Function vmedia_mount_exists has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def vmedia_mount_exists(handle, volume_name, server_id=1, **kwargs):
          import re
      
          try:
              mo = vmedia_mount_get(handle, volume_name)
      Severity: Minor
      Found in imcsdk/apis/v2/server/vmedia.py - 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

      Function vmedia_mount_iso_uri has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def vmedia_mount_iso_uri(handle, uri, user_id=None, password=None,
      Severity: Major
      Found in imcsdk/apis/v2/server/vmedia.py - About 50 mins to fix

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

        def _vmedia_setup(handle, admin_state, encryption_state, low_power_usb,
        Severity: Minor
        Found in imcsdk/apis/v2/server/vmedia.py - About 35 mins to fix

          Avoid too many return statements within this function.
          Open

                  return False, mo
          Severity: Major
          Found in imcsdk/apis/v2/server/vmedia.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return True, mo
            Severity: Major
            Found in imcsdk/apis/v2/server/vmedia.py - About 30 mins to fix

              Function vmedia_mount_remove_all has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              def vmedia_mount_remove_all(handle, volumes= None, server_id=1):
                  """
                  This method will remove all the mapped vmedia mappings and saved vmedia mappings with the specified volumes
              
                  Args:
              Severity: Minor
              Found in imcsdk/apis/v2/server/vmedia.py - 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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              def vmedia_mount_exists(handle, volume_name, server_id=1, **kwargs):
                  import re
              
                  try:
                      mo = vmedia_mount_get(handle, volume_name)
              Severity: Major
              Found in imcsdk/apis/v2/server/vmedia.py and 1 other location - About 2 days to fix
              imcsdk/apis/server/vmedia.py on lines 227..259

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 258.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              def vmedia_mount_create(handle, volume_name, remote_share, remote_file,
                                      map="www", mount_options="noauto", username="",
                                      password="", server_id=1, timeout=60):
                  """
                  This method will setup the vmedia mapping
              Severity: Major
              Found in imcsdk/apis/v2/server/vmedia.py and 1 other location - About 2 days to fix
              imcsdk/apis/server/vmedia.py on lines 164..223

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 233.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                  if uri in vmedia_get_existing_uri(handle, server_id):
                      # Loop until mapping moves out of 'In Progress' state
                      wait_time = 0
                      status_list = vmedia_get_existing_status(handle, server_id)
                      while 'In Progress' in status_list:
              Severity: Major
              Found in imcsdk/apis/v2/server/vmedia.py and 1 other location - About 1 day to fix
              imcsdk/apis/server/vmedia.py on lines 334..363

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 154.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 4 locations. Consider refactoring.
              Open

                  if response:
                      ret = process_conf_mos_response(response, api, False, 'Create Virtual Media mapping failed',vmedia_mounts_callback,
                                                             dn_to_vmedia_dict)
                      if len(ret) != 0:
                          error_msg = 'Create Virtual Media mapping failed:\n'
              Severity: Major
              Found in imcsdk/apis/v2/server/vmedia.py and 3 other locations - About 7 hrs to fix
              imcsdk/apis/v2/admin/snmp.py on lines 449..462
              imcsdk/apis/v2/admin/snmp.py on lines 868..881
              imcsdk/apis/v2/storage/sdcard.py on lines 383..396

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 114.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

              def vmedia_mount_remove_image(handle, image_type, server_id=1):
                  """
                  This method will remove the vmedia mapping of specific type
              
                  Args:
              Severity: Major
              Found in imcsdk/apis/v2/server/vmedia.py and 1 other location - About 5 hrs to fix
              imcsdk/apis/server/vmedia.py on lines 430..459

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 93.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

              def vmedia_mount_delete(handle, volume_name, server_id=1):
                  """
                  This method will remove the vmedia mapping referred to by the volume name
              
                  Args:
              Severity: Major
              Found in imcsdk/apis/v2/server/vmedia.py and 1 other location - About 4 hrs to fix
              imcsdk/apis/server/vmedia.py on lines 367..393

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 79.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

              def vmedia_mount_get(handle, volume_name, server_id=1):
                  parent_dn = _get_vmedia_mo_dn(handle, server_id)
                  dn = parent_dn + "/vmmap-" + volume_name
                  mo = handle.query_dn(dn)
                  if mo is None:
              Severity: Major
              Found in imcsdk/apis/v2/server/vmedia.py and 1 other location - About 4 hrs to fix
              imcsdk/apis/server/vmedia.py on lines 154..161

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 75.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

              def vmedia_get_existing_uri(handle, server_id=1):
                  """
                  This method will return list of URIs of existing mountd media
                  Args:
                      handle (ImcHandle)
              Severity: Major
              Found in imcsdk/apis/v2/server/vmedia.py and 1 other location - About 2 hrs to fix
              imcsdk/apis/server/vmedia.py on lines 117..133

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 51.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

              def vmedia_get_existing_status(handle, server_id=1):
                  """
                  This method will return list of status of existing mountd media
                  Args:
                      handle (ImcHandle)
              Severity: Major
              Found in imcsdk/apis/v2/server/vmedia.py and 1 other location - About 1 hr to fix
              imcsdk/apis/server/vmedia.py on lines 136..151

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 43.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              There are no issues that match your filters.

              Category
              Status