saltstack/salt

View on GitHub
salt/modules/solarisipspkg.py

Summary

Maintainability
D
2 days
Test Coverage

File solarisipspkg.py has 456 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
IPS pkg support for Solaris

.. important::
Severity: Minor
Found in salt/modules/solarisipspkg.py - About 6 hrs to fix

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

    def install(name=None, refresh=False, pkgs=None, version=None, test=False, **kwargs):
        '''
        Install the named package using the IPS pkg command.
        Accepts full or partial FMRI.
    
    
    Severity: Minor
    Found in salt/modules/solarisipspkg.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 latest_version has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def latest_version(*names, **kwargs):
        '''
        The available version of packages in the repository.
        Accepts full or partial FMRI. Partial FMRI is returned if the full FMRI
        could not be resolved.
    Severity: Minor
    Found in salt/modules/solarisipspkg.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 list_pkgs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def list_pkgs(versions_as_list=False, **kwargs):
        '''
        List the currently installed packages as a dict::
    
            {'<package_name>': '<version>'}
    Severity: Minor
    Found in salt/modules/solarisipspkg.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

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

    def version(*names, **kwargs):
        '''
        Common interface for obtaining the version of installed packages.
        Accepts full or partial FMRI. If called using pkg_resource, full FMRI is required.
        Partial FMRI is returned if the package is not installed.
    Severity: Minor
    Found in salt/modules/solarisipspkg.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 12 locations. Consider refactoring.
    Open

        if 'pkg.list_pkgs' in __context__:
            if versions_as_list:
                return __context__['pkg.list_pkgs']
            else:
                ret = copy.deepcopy(__context__['pkg.list_pkgs'])
    Severity: Major
    Found in salt/modules/solarisipspkg.py and 11 other locations - About 2 hrs to fix
    salt/modules/aixpkg.py on lines 107..114
    salt/modules/apkpkg.py on lines 139..145
    salt/modules/ebuildpkg.py on lines 424..430
    salt/modules/mac_brew_pkg.py on lines 117..123
    salt/modules/mac_portspkg.py on lines 105..111
    salt/modules/openbsdpkg.py on lines 75..81
    salt/modules/opkg.py on lines 990..996
    salt/modules/pacmanpkg.py on lines 211..217
    salt/modules/pkgin.py on lines 281..287
    salt/modules/pkgutil.py on lines 149..155
    salt/modules/solarispkg.py on lines 102..108

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

    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

        unmatched = list([name for name in names if not reduce(lambda x, y: x or name in y, ret, False)])  # pylint: disable=W0640
    Severity: Major
    Found in salt/modules/solarisipspkg.py and 1 other location - About 1 hr to fix
    salt/modules/solarisipspkg.py on lines 377..377

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

    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

        unmatched = list([name for name in names if not reduce(lambda x, y: x or name in y, ret, False)])
    Severity: Major
    Found in salt/modules/solarisipspkg.py and 1 other location - About 1 hr to fix
    salt/modules/solarisipspkg.py on lines 318..318

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

    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 out['retcode'] != 0:
            raise CommandExecutionError(
                'Error occurred installing package(s)',
                info={
                    'changes': ret,
    Severity: Major
    Found in salt/modules/solarisipspkg.py and 1 other location - About 1 hr to fix
    salt/modules/solarisipspkg.py on lines 635..641

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

    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 out['retcode'] != 0:
            raise CommandExecutionError(
                'Error occurred removing package(s)',
                info={
                    'changes': ret,
    Severity: Major
    Found in salt/modules/solarisipspkg.py and 1 other location - About 1 hr to fix
    salt/modules/solarisipspkg.py on lines 572..578

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

    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