CiscoUcs/imcsdk

View on GitHub
imcsdk/apis/v2/admin/network.py

Summary

Maintainability
F
4 days
Test Coverage

File network.py has 508 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2017 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: Major
Found in imcsdk/apis/v2/admin/network.py - About 1 day to fix

    Function mgmt_if_configure has 41 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def mgmt_if_configure(handle,
    Severity: Major
    Found in imcsdk/apis/v2/admin/network.py - About 5 hrs to fix

      Function mgmt_if_exists has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      def mgmt_if_exists(handle, **kwargs):
      
          try:
              mo = _get_mgmtif_mo(handle)
          except:
      Severity: Minor
      Found in imcsdk/apis/v2/admin/network.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 ipv6_configure has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def ipv6_configure(handle, v6ext_enabled=None, v6dhcp_enable=None,
      Severity: Major
      Found in imcsdk/apis/v2/admin/network.py - About 1 hr to fix

        Function ipv4_configure has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def ipv4_configure(handle, dhcp_enable=None, ext_ip=None, ext_mask=None,
        Severity: Major
        Found in imcsdk/apis/v2/admin/network.py - About 1 hr to fix

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

          def ip_blocking_enable(handle, fail_count=None, fail_window=None,
          Severity: Minor
          Found in imcsdk/apis/v2/admin/network.py - About 35 mins to fix

            Avoid too many return statements within this function.
            Open

                return mo.check_prop_match(**kwargs), mo
            Severity: Major
            Found in imcsdk/apis/v2/admin/network.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

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

                Avoid too many return statements within this function.
                Open

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

                  Avoid too many return statements within this function.
                  Open

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

                    Avoid too many return statements within this function.
                    Open

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

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

                      def ip_blocking_disable(handle):
                          """
                          Disables IP Blocking.
                      
                          Args:
                      Severity: Major
                      Found in imcsdk/apis/v2/admin/network.py and 1 other location - About 4 hrs to fix
                      imcsdk/apis/v2/admin/network.py on lines 589..613

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

                      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 ip_filtering_disable(handle):
                          """
                          Disables IP Filtering.
                      
                          Args:
                      Severity: Major
                      Found in imcsdk/apis/v2/admin/network.py and 1 other location - About 4 hrs to fix
                      imcsdk/apis/v2/admin/network.py on lines 514..538

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

                      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 3 locations. Consider refactoring.
                      Open

                      def _set_ip_filters(mo, ip_filters):
                          if len(ip_filters) > len(_IP_FILTERS_LIST):
                              raise ImcOperationError("Set IP Filters",
                                                      "Cannot specify more than %d filters"
                                                      % len(_IP_FILTERS_LIST))
                      Severity: Major
                      Found in imcsdk/apis/v2/admin/network.py and 2 other locations - About 2 hrs to fix
                      imcsdk/apis/admin/ntp.py on lines 35..41
                      imcsdk/apis/v2/admin/ntp.py on lines 35..41

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

                      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 3 locations. Consider refactoring.
                      Open

                          if 'vlan_priority' in kwargs:
                              kwargs['vlan_priority'] = str(kwargs['vlan_priority']) if kwargs['vlan_priority'] is not None else None
                      Severity: Major
                      Found in imcsdk/apis/v2/admin/network.py and 2 other locations - About 1 hr to fix
                      imcsdk/apis/v2/admin/network.py on lines 432..433
                      imcsdk/apis/v2/admin/network.py on lines 435..436

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

                      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 3 locations. Consider refactoring.
                      Open

                          if 'v6prefix' in kwargs:
                              kwargs['v6prefix'] = str(kwargs['v6prefix']) if kwargs['v6prefix'] is not None else None
                      Severity: Major
                      Found in imcsdk/apis/v2/admin/network.py and 2 other locations - About 1 hr to fix
                      imcsdk/apis/v2/admin/network.py on lines 435..436
                      imcsdk/apis/v2/admin/network.py on lines 438..439

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

                      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 3 locations. Consider refactoring.
                      Open

                          if 'vlan_id' in kwargs:
                              kwargs['vlan_id'] = str(kwargs['vlan_id']) if kwargs['vlan_id'] is not None else None
                      Severity: Major
                      Found in imcsdk/apis/v2/admin/network.py and 2 other locations - About 1 hr to fix
                      imcsdk/apis/v2/admin/network.py on lines 432..433
                      imcsdk/apis/v2/admin/network.py on lines 438..439

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

                      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 3 locations. Consider refactoring.
                      Open

                      def _get_ip_filters(ip_filters):
                          return {"filter" + str(x["id"]): x["ip_filter"] for x in ip_filters}
                      Severity: Major
                      Found in imcsdk/apis/v2/admin/network.py and 2 other locations - About 1 hr to fix
                      imcsdk/apis/admin/ntp.py on lines 31..32
                      imcsdk/apis/v2/admin/ntp.py on lines 31..32

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

                      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