CiscoUcs/ucsmsdk

Showing 492 of 492 total issues

Cyclomatic complexity is too high in function _generate_config_resolve_cmdlet. (23) Open

``````def _generate_config_resolve_cmdlet(xml_string, method):
"""
Internal method which takes xmlstring, and generate script for
configResolveDn, configResolveDns, configResolveClass and
configResolveClasses methods.``````
Found in ucsmsdk/utils/converttopython.py by radon

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Function `from_xml` has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open

``````    def from_xml(self, elem, handle=None):
"""Method updates/fills the object from the xml representation
of the external method object. """

self._handle = handle``````
Found in ucsmsdk/ucsmethod.py - About 4 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"

Cyclomatic complexity is too high in function get_ucs_cco_image_list. (22) Open

``````def get_ucs_cco_image_list(username=None, password=None, mdf_id_list=None,
proxy=None):
"""
Gets the list of images available on CCO

``````
Found in ucsmsdk/utils/ccoimage.py by radon

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Cyclomatic complexity is too high in function get_ucs_tech_support. (22) Open

``````@deprecated(get_tech_support)
def get_ucs_tech_support(handle,
ucs_manager=False,
ucs_mgmt=False,
chassis_id=None, cimc_id=None,``````
Found in ucsmsdk/utils/ucstechsupport.py by radon

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Function `_create_python_filter_code` has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open

``````def _create_python_filter_code(parent_node, parent_filter_name):
"""
Internal method to provide filter support.
"""

``````
Found in ucsmsdk/utils/converttopython.py - About 4 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"

Function `_form_configconf_cmdlet` has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open

``````def _form_configconf_cmdlet(class_node, key, tag, import_list, parent_tag=None,
sub_cmdlet=False):
"""
Internal method to process configConf request.
"""``````
Found in ucsmsdk/utils/converttopython.py - About 4 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"

Cyclomatic complexity is too high in function sync_ucs_mo. (21) Open

``````def sync_ucs_mo(ref_handle, difference,
delete_not_present=False,
version_filter=True):
"""
syncs the difference object on reference ucsm.``````
Found in ucsmsdk/utils/comparesyncmo.py by radon

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Function `ucs_gui_launch` has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open

``````def ucs_gui_launch(handle, need_url=False):
"""
ucs_gui_launch launches the Java based UCSM GUI.
This method requires the necessary Jdk to be in place, for it to be
successful.``````
Found in ucsmsdk/utils/ucsguilaunch.py - About 4 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"

Cyclomatic complexity is too high in function _generate_multiple_clone_cmdlets. (20) Open

``````def _generate_multiple_clone_cmdlets(xml_string, is_prefix_based):
"""
Internal method which takes xmlstring, and generate script for
lsInstantiateNTemplate and  lsInstantiateNNamedTemplate methods.
"""``````
Found in ucsmsdk/utils/converttopython.py by radon

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

`UcsHandle` has 32 functions (exceeds 20 allowed). Consider refactoring. Open

``````class UcsHandle(UcsSession):
"""
UcsHandle class is the user interface point for any Ucs related communication.

Args:``````
Found in ucsmsdk/ucshandle.py - About 4 hrs to fix

`UcsEventHandle` has 32 functions (exceeds 20 allowed). Consider refactoring. Open

``````class UcsEventHandle(object):
"""This class provides api to add and remove event handler."""

def __init__(self, handle):
self._handle = handle``````
Found in ucsmsdk/ucseventhandler.py - About 4 hrs to fix

Cyclomatic complexity is too high in function _create_property_map_from_node. (19) Open

``````def _create_property_map_from_node(class_node, class_status):
gmo_flag = False
property_map = {}

if ucscoreutils.find_class_id_in_mo_meta_ignore_case(``````
Found in ucsmsdk/utils/converttopython.py by radon

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Function `_get_config_conf_cmdlet` has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open

``````def _get_config_conf_cmdlet(node, is_pair_node):
"""
Internal method to process configConf request.
"""

``````
Found in ucsmsdk/utils/converttopython.py - About 3 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"

Function `to_xml` has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open

``````    def to_xml(self, xml_doc=None, option=None, elem_name=None):
"""
Method writes the xml representation of the managed object.
"""

``````
Found in ucsmsdk/ucsmo.py - About 3 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"

Function `from_xml` has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open

``````    def from_xml(self, elem, handle=None):
"""
Method updates the object from the xml representation of the managed
object.
"""``````
Found in ucsmsdk/ucsmo.py - About 3 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"

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

``````def sp_assoc_wait_done_cb(mce):
log.debug("sp_assoc_wait_done_cb")
log.debug("SP:" + mce.mo.dn + " Assoc Done Callback. assoc_state: " +
mce.mo.assoc_state)
if mce.mo.assoc_state == LsServerConsts.ASSOC_STATE_ASSOCIATED:``````
Found in samples/sp_assoc_deassoc_with_events.py and 1 other location - About 3 hrs to fix
samples/sp_assoc_deassoc_with_events.py on lines 115..120

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

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

``````def sp_deassoc_wait_done_cb(mce):
log.debug("sp_deassoc_wait_done_cb")
log.debug("SP:" + mce.mo.dn + " Deassoc Done Callback. assoc_state: " +
mce.mo.assoc_state)
if mce.mo.assoc_state == LsServerConsts.ASSOC_STATE_UNASSOCIATED:``````
Found in samples/sp_assoc_deassoc_with_events.py and 1 other location - About 3 hrs to fix
samples/sp_assoc_deassoc_with_events.py on lines 93..98

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

Cyclomatic complexity is too high in method _dequeue_function. (17) Open

``````    def _dequeue_function(self):
"""
Internal method to dequeue to events.
"""
while len(self._wbs):``````
Found in ucsmsdk/ucseventhandler.py by radon

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Function `handle_filter_max_component_limit` has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open

``````def handle_filter_max_component_limit(handle, l_filter):
"""
Method checks the filter count and if the filter count exceeds
the max_components(number of filters), then the given filter
objects get distributed among small groups and then again binded``````
Found in ucsmsdk/ucsfilter.py - About 3 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"

Function `_get_class_id_for_rn` has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open

``````def _get_class_id_for_rn(rn, prev_class_id=None):
"""
Internal method to get the class id for a given rn
"""

``````
Found in ucsmsdk/utils/converttopython.py - About 3 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"