intracom-telecom-sdn/nstat

View on GitHub
util/sysstats.py

Summary

Maintainability
C
1 day
Test Coverage

Showing 7 of 7 total issues

Cyclomatic complexity is too high in function command_exec_wrapper. (10)
Open

def command_exec_wrapper(cmd, ssh_client=None, return_type='str'):
"""
Executes a command either locally or remotely and returns the result
 
:param cmd: the command to be executed
Severity: Minor
Found in util/sysstats.py by radon

File sysstats.py has 257 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright (c) 2015 Intracom S.A. Telecom Solutions. All rights reserved.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v1.0 which accompanies this distribution,
# and is available at http://www.eclipse.org/legal/epl-v10.html
Severity: Minor
Found in util/sysstats.py - About 2 hrs to fix

    Function command_exec_wrapper has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def command_exec_wrapper(cmd, ssh_client=None, return_type='str'):
    """
    Executes a command either locally or remotely and returns the result
     
    :param cmd: the command to be executed
    Severity: Minor
    Found in util/sysstats.py - About 2 hrs to fix

    Avoid too many return statements within this function.
    Open

    return cmd_output
    Severity: Major
    Found in util/sysstats.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

      return '-1'
      Severity: Major
      Found in util/sysstats.py - About 30 mins to fix

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

        def sys_free_memory_bytes(ssh_client=None):
        """
        Returns system free memory in bytes
         
        :param ssh_client: SSH client provided by paramiko to run the command
        Severity: Major
        Found in util/sysstats.py and 1 other location - About 2 hrs to fix
        util/sysstats.py on lines 149..163

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

        def sys_total_memory_bytes(ssh_client=None):
        """
        Returns system total memory in bytes
         
        :param ssh_client: SSH client provided by paramiko to run the command
        Severity: Major
        Found in util/sysstats.py and 1 other location - About 2 hrs to fix
        util/sysstats.py on lines 132..146
        Category
        Status