saltstack/salt

View on GitHub
salt/modules/dpkg_lowpkg.py

Summary

Maintainability
F
5 days
Test Coverage

File dpkg_lowpkg.py has 403 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Support for DEB packages
'''
from __future__ import absolute_import, print_function, unicode_literals
Severity: Minor
Found in salt/modules/dpkg_lowpkg.py - About 5 hrs to fix

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

    def info(*packages, **kwargs):
        '''
        Returns a detailed summary of package information for provided package names.
        If no packages are specified, all packages will be returned.
    
    
    Severity: Minor
    Found in salt/modules/dpkg_lowpkg.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"

    Further reading

    Function bin_pkg_info has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    def bin_pkg_info(path, saltenv='base'):
        '''
        .. versionadded:: 2015.8.0
    
        Parses RPM metadata and returns a dictionary of information about the
    Severity: Minor
    Found in salt/modules/dpkg_lowpkg.py - About 2 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"

    Further reading

    Function _get_pkg_info has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def _get_pkg_info(*packages, **kwargs):
        '''
        Return list of package information. If 'packages' parameter is empty,
        then data about all installed packages will be returned.
    
    
    Severity: Minor
    Found in salt/modules/dpkg_lowpkg.py - About 2 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"

    Further reading

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

    def _get_pkg_build_time(name):
        '''
        Get package build time, if possible.
    
        :param name:
    Severity: Minor
    Found in salt/modules/dpkg_lowpkg.py - About 2 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"

    Further reading

    Function _get_pkg_ds_avail has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def _get_pkg_ds_avail():
        '''
        Get the package information of the available packages, maintained by dselect.
        Note, this will be not very useful, if dselect isn't installed.
    
    
    Severity: Minor
    Found in salt/modules/dpkg_lowpkg.py - About 1 hr 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

    Function _get_pkg_install_time has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def _get_pkg_install_time(pkg, arch=None):
        '''
        Return package install time, based on the /var/lib/dpkg/info/<package>.list
    
        :return:
    Severity: Minor
    Found in salt/modules/dpkg_lowpkg.py - About 1 hr 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

    Function file_dict has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def file_dict(*packages, **kwargs):
        '''
        List the files that belong to a package, grouped by package. Not
        specifying any packages will return a list of _every_ file on the system's
        package database (not generally recommended).
    Severity: Minor
    Found in salt/modules/dpkg_lowpkg.py - About 55 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

    Function file_list has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def file_list(*packages, **kwargs):
        '''
        List the files that belong to a package. Not specifying any packages will
        return a list of _every_ file on the system's package database (not
        generally recommended).
    Severity: Minor
    Found in salt/modules/dpkg_lowpkg.py - About 55 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

    Function _get_pkg_license has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def _get_pkg_license(pkg):
        '''
        Try to get a license from the package.
        Based on https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
    
    
    Severity: Minor
    Found in salt/modules/dpkg_lowpkg.py - About 25 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

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

        if __salt__['config.valid_fileproto'](path):
            newpath = __salt__['cp.cache_file'](path, saltenv)
            if not newpath:
                raise CommandExecutionError(
                    'Unable to retrieve {0} from saltenv \'{1}\''
    Severity: Major
    Found in salt/modules/dpkg_lowpkg.py and 1 other location - About 7 hrs to fix
    salt/modules/rpm_lowpkg.py on lines 90..105

    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 117.

    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

    Further Reading

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

        for line in out.splitlines():
            if line.startswith('ii '):
                comps = line.split()
                pkgs[comps[1]] = {'version': comps[2],
                                  'description': ' '.join(comps[3:])}
    Severity: Major
    Found in salt/modules/dpkg_lowpkg.py and 1 other location - About 5 hrs to fix
    salt/modules/dpkg_lowpkg.py on lines 197..203

    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 89.

    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

    Further Reading

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

        for line in out.splitlines():
            if line.startswith('ii '):
                comps = line.split()
                pkgs[comps[1]] = {'version': comps[2],
                                  'description': ' '.join(comps[3:])}
    Severity: Major
    Found in salt/modules/dpkg_lowpkg.py and 1 other location - About 5 hrs to fix
    salt/modules/dpkg_lowpkg.py on lines 239..245

    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 89.

    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

    Further Reading

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

        if out['retcode'] != 0:
            msg = 'Error:  ' + out['stderr']
            log.error(msg)
            return msg
    Severity: Major
    Found in salt/modules/dpkg_lowpkg.py and 2 other locations - About 1 hr to fix
    salt/modules/dpkg_lowpkg.py on lines 159..162
    salt/modules/dpkg_lowpkg.py on lines 191..194

    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 45.

    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

    Further Reading

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

        if out['retcode'] != 0:
            msg = 'Error:  ' + out['stderr']
            log.error(msg)
            return msg
    Severity: Major
    Found in salt/modules/dpkg_lowpkg.py and 2 other locations - About 1 hr to fix
    salt/modules/dpkg_lowpkg.py on lines 159..162
    salt/modules/dpkg_lowpkg.py on lines 233..236

    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 45.

    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

    Further Reading

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

        if out['retcode'] != 0:
            msg = 'Error:  ' + out['stderr']
            log.error(msg)
            return msg
    Severity: Major
    Found in salt/modules/dpkg_lowpkg.py and 2 other locations - About 1 hr to fix
    salt/modules/dpkg_lowpkg.py on lines 191..194
    salt/modules/dpkg_lowpkg.py on lines 233..236

    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 45.

    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

    Further Reading

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

            for location in locations:
                try:
                    iso_time_t = int(os.path.getmtime(location))
                    iso_time = datetime.datetime.utcfromtimestamp(iso_time_t).isoformat() + 'Z'
                    break
    Severity: Major
    Found in salt/modules/dpkg_lowpkg.py and 1 other location - About 1 hr to fix
    salt/modules/dpkg_lowpkg.py on lines 276..281

    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 49.

    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

    Further Reading

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

                if 'changelog' in pkg_f_path.lower() and os.path.exists(pkg_f_path):
                    try:
                        iso_time_t = int(os.path.getmtime(pkg_f_path))
                        iso_time = datetime.datetime.utcfromtimestamp(iso_time_t).isoformat() + 'Z'
                        break
    Severity: Major
    Found in salt/modules/dpkg_lowpkg.py and 1 other location - About 1 hr to fix
    salt/modules/dpkg_lowpkg.py on lines 390..395

    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 49.

    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

    Further Reading

    There are no issues that match your filters.

    Category
    Status