CiscoUcs/ucsmsdk

View on GitHub
ucsmsdk/ucssession.py

Summary

Maintainability
D
2 days
Test Coverage

File ucssession.py has 531 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2015 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 ucsmsdk/ucssession.py - About 1 day to fix

    UcsSession has 48 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class UcsSession(object):
        """
        UcsSession class is session interface for any Ucs related communication.
        Parent class of UcsHandle, used internally by UcsHandle class.
        """
    Severity: Minor
    Found in ucsmsdk/ucssession.py - About 6 hrs to fix

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

          def __init__(self, ip, username, password, port=None, secure=None,
      Severity: Major
      Found in ucsmsdk/ucssession.py - About 50 mins to fix

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

            def __validate_connection(self, timeout=None):
                """
                Internal method to validate if needs to reconnect or if exist use the
                existing connection.
                """
        Severity: Minor
        Found in ucsmsdk/ucssession.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

        Method "__init__" has 8 parameters, which is greater than the 7 authorized.
        Open

            def __init__(self, ip, username, password, port=None, secure=None,
                         proxy=None, timeout=None):
        Severity: Major
        Found in ucsmsdk/ucssession.py by sonar-python

        A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.

        Noncompliant Code Example

        With a maximum number of 4 parameters:

        def do_something(param1, param2, param3, param4, param5):
            ...
        

        Compliant Solution

        def do_something(param1, param2, param3, param4):
            ...
        

        There are no issues that match your filters.

        Category
        Status