eisen-dev/eisen_engine

View on GitHub
core/PackageListUpdate.py

Summary

Maintainability
F
1 wk
Test Coverage

Showing 17 of 17 total issues

Function get_installed_package has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

def get_installed_package(target_host_ip, command, target_host_os):
delete_user_machine_packages(target_host_ip)
a= AnsibleV1Inv.get_inv()
packages = RunTask(target_host_ip, command,"shell",a)
if target_host_os == 'Ubuntu':
Severity: Minor
Found in core/PackageListUpdate.py - About 5 hrs to fix

File PackageListUpdate.py has 337 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# coding=utf-8
# (c) 2015, Alice Ferrazzi <alice.ferrazzi@gmail.com>
#
# This file is part of Eisen
#
Severity: Minor
Found in core/PackageListUpdate.py - About 4 hrs to fix

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

    def get_all_package(target_host_ip, command, target_host_os):
    delete_repository_package_db(target_host_ip)
    a= AnsibleV1Inv.get_inv()
    packages = RunTask(target_host_ip, command,"shell",a)
    if target_host_os == 'Ubuntu':
    Severity: Minor
    Found in core/PackageListUpdate.py - About 3 hrs to fix

    Function package_update has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def package_update(targetHost, os, command):
    if os == 'Raspbian':
    os = 'Ubuntu'
    print (
    '\n------------------------------------' + targetHost
    Severity: Minor
    Found in core/PackageListUpdate.py - About 1 hr to fix

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

    def update_installed_package_db(package_name,package_version,package_summary,
    Severity: Minor
    Found in core/PackageListUpdate.py - About 35 mins to fix

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

      def update_repository_package_db(package_name,package_version,package_summary,
      Severity: Minor
      Found in core/PackageListUpdate.py - About 35 mins to fix

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

        elif target_host_os == 'Gentoo':
        package_line = packages['contacted'][target_host_ip]['stdout']
        package_list = package_line.split('\n')
        for package in package_list:
        category_name_version = package.split(' ')
        Severity: Major
        Found in core/PackageListUpdate.py and 1 other location - About 1 day to fix
        core/PackageListUpdate.py on lines 122..170

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

        elif target_host_os == 'Gentoo':
        try:
        package_line = packages['contacted'][target_host_ip]['stdout']
        except Exception, error:
        print error
        Severity: Major
        Found in core/PackageListUpdate.py and 1 other location - About 1 day to fix
        core/PackageListUpdate.py on lines 198..242

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

        for package in package_list:
        category_name_version = package.split(' ')
        package_category = category_name_version[0]
        package_name = category_name_version[1]
        packge_version = category_name_version[2]
        Severity: Major
        Found in core/PackageListUpdate.py and 1 other location - About 5 hrs to fix
        core/PackageListUpdate.py on lines 130..142

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

        for package in package_list:
        category_name_version = package.split(' ')
        package_category = category_name_version[0]
        package_name = category_name_version[1]
        packge_version = category_name_version[2]
        Severity: Major
        Found in core/PackageListUpdate.py and 1 other location - About 5 hrs to fix
        core/PackageListUpdate.py on lines 201..214

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

        def repository_installed(os):
        print os
        if os == 'Ubuntu' or os == 'Raspbian':
        command = "dpkg -l | awk 'NR>5{print $0}'"
        elif os == 'Gentoo':
        Severity: Major
        Found in core/PackageListUpdate.py and 1 other location - About 4 hrs to fix
        core/PackageListUpdate.py on lines 73..85

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

        def repository_all(os):
        print os
        if os == 'Ubuntu' or os == 'Raspbian':
        command = "apt-cache search ."
        elif os == 'Gentoo':
        Severity: Major
        Found in core/PackageListUpdate.py and 1 other location - About 4 hrs to fix
        core/PackageListUpdate.py on lines 60..71

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

        try:
        thr = Thread(target=get_installed_package, args=[targetHost, command_installed, os])
        thr.start()
        except Exception as e:
        print(traceback.format_exc())
        Severity: Major
        Found in core/PackageListUpdate.py and 2 other locations - About 1 hr to fix
        core/PackageListUpdate.py on lines 42..47
        core/PackageListUpdate.py on lines 54..58

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

        try:
        thr1 = Thread(target=get_all_package, args=[targetHost, command_all, os])
        thr1.start()
        except Exception as e:
        print(traceback.format_exc())
        Severity: Major
        Found in core/PackageListUpdate.py and 2 other locations - About 1 hr to fix
        core/PackageListUpdate.py on lines 42..47
        core/PackageListUpdate.py on lines 49..53

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

        if command == 'respository':
        try:
        thr1 = Thread(target=get_all_package, args=[targetHost, command_all, os])
        thr1.start()
        except Exception as e:
        Severity: Major
        Found in core/PackageListUpdate.py and 2 other locations - About 1 hr to fix
        core/PackageListUpdate.py on lines 49..53
        core/PackageListUpdate.py on lines 54..58

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

        try:
        dpkg_lines = packages['contacted'][target_host_ip]['stdout']
        except Exception, error:
        print error
        pass
        Severity: Minor
        Found in core/PackageListUpdate.py and 1 other location - About 50 mins to fix
        core/PackageListUpdate.py on lines 123..127

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

        try:
        package_line = packages['contacted'][target_host_ip]['stdout']
        except Exception, error:
        print error
        pass
        Severity: Minor
        Found in core/PackageListUpdate.py and 1 other location - About 50 mins to fix
        core/PackageListUpdate.py on lines 92..96

        There are no issues that match your filters.

        Category
        Status