CiscoUcs/imcsdk

View on GitHub
imcsdk/apis/server/boot.py

Summary

Maintainability
F
1 wk
Test Coverage

File boot.py has 352 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/server/boot.py - About 4 hrs to fix

    Function _get_device has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def _get_device(parent_dn, device_type, device_name):
        from imcsdk.imccoreutils import load_class
    
        if _is_boot_order_precision(parent_dn):
            if device_type not in precision_device_dict:
    Severity: Minor
    Found in imcsdk/apis/server/boot.py - 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

    Function boot_order_precision_exists has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def boot_order_precision_exists(handle, **kwargs):
        from imcsdk.imccoreutils import _set_server_dn
        from imcsdk.apis.utils import _is_valid_arg
    
        server_dn = _set_server_dn(handle, kwargs)
    Severity: Minor
    Found in imcsdk/apis/server/boot.py - 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

    Function boot_order_precision_set has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def boot_order_precision_set(
    Severity: Minor
    Found in imcsdk/apis/server/boot.py - About 45 mins to fix

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

      def boot_order_policy_get(handle, dump=False, server_id=1):
          """
          Gets the boot order. This is the legacy boot order
      
          Args:
      Severity: Minor
      Found in imcsdk/apis/server/boot.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

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

      def boot_order_policy_set(handle, reboot_on_update="no",
      Severity: Minor
      Found in imcsdk/apis/server/boot.py - About 35 mins to fix

        Function _get_device_type has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def _get_device_type(policy_type, in_device):
            if policy_type == "boot-order-policy":
                for device_type, device_props in policy_device_dict.items():
                    if device_props["class_id"] == in_device._class_id and \
                            device_props["access"] == in_device.access:
        Severity: Minor
        Found in imcsdk/apis/server/boot.py - 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

        Avoid too many return statements within this function.
        Open

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

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

          def boot_order_precision_get(handle, dump=False, server_id=1):
              """
              Gets the precision boot order.
              This is supported from EP release onwards only
          
          
          Severity: Minor
          Found in imcsdk/apis/server/boot.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

              if _is_boot_order_precision(parent_dn):
                  if device_type not in precision_device_dict:
                      return None
                  class_struct = load_class(
                      precision_device_dict[device_type]["class_id"])
          Severity: Major
          Found in imcsdk/apis/server/boot.py and 1 other location - About 2 days to fix
          imcsdk/apis/v2/server/boot.py on lines 167..193

          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 239.

          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 boot_order_precision_get(handle, dump=False, server_id=1):
              """
              Gets the precision boot order.
              This is supported from EP release onwards only
          
          
          Severity: Major
          Found in imcsdk/apis/server/boot.py and 1 other location - About 1 day to fix
          imcsdk/apis/v2/server/boot.py on lines 31..73

          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 217.

          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

                  for i in range(0, len(in_boot_order)):
                      bt_ord = in_boot_order[i]
                      cfg_bt_ord = configured_boot_order[i]
                      if not (bt_ord["order"] == cfg_bt_ord["order"] and
                              bt_ord["device-type"] == cfg_bt_ord["device-type"] and
          Severity: Major
          Found in imcsdk/apis/server/boot.py and 1 other location - About 7 hrs to fix
          imcsdk/apis/v2/server/boot.py on lines 423..429

          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 111.

          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 _get_device_type(policy_type, in_device):
              if policy_type == "boot-order-policy":
                  for device_type, device_props in policy_device_dict.items():
                      if device_props["class_id"] == in_device._class_id and \
                              device_props["access"] == in_device.access:
          Severity: Major
          Found in imcsdk/apis/server/boot.py and 1 other location - About 3 hrs to fix
          imcsdk/apis/v2/server/boot.py on lines 144..150

          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 73.

          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

              for device in child_mo_list:
                  if device.dn == boot_security_policy.dn:
                      continue
          
                  device_name = "NA"
          Severity: Major
          Found in imcsdk/apis/server/boot.py and 1 other location - About 3 hrs to fix
          imcsdk/apis/v2/server/boot.py on lines 462..473

          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 71.

          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

          policy_device_dict = {
              "efi": {"class_id": "LsbootEfi", "access": "read-only"},
              "lan": {"class_id": "LsbootLan", "access": "read-only"},
              "storage": {"class_id": "LsbootStorage", "access": "read-write"},
              "cdrom": {"class_id": "LsbootVirtualMedia", "access": "read-only"},
          Severity: Major
          Found in imcsdk/apis/server/boot.py and 1 other location - About 1 hr to fix
          imcsdk/apis/v2/server/boot.py on lines 127..132

          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 47.

          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 device is None:
                  raise ValueError(
                      "Unsupported boot-device %s with label %s" %
                      (boot_device["device-type"], boot_device["name"]))
          Severity: Major
          Found in imcsdk/apis/server/boot.py and 1 other location - About 1 hr to fix
          imcsdk/apis/v2/server/boot.py on lines 218..221

          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 38.

          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