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
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. """
__init__ has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, ip, username, password, port=None, secure=None,
__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. """
- Read upRead up
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"
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):
- Read upRead up
- Exclude checks
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): ...
def do_something(param1, param2, param3, param4): ...