saltstack/salt

View on GitHub
salt/modules/systemd_service.py

Summary

Maintainability
F
1 wk
Test Coverage

File systemd_service.py has 1051 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Provides the service module for systemd

.. versionadded:: 0.10.0
Severity: Major
Found in salt/modules/systemd_service.py - About 2 days to fix

    Function _get_systemd_services has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def _get_systemd_services(root):
        '''
        Use os.listdir() to get all the unit files
        '''
        ret = set()
    Severity: Minor
    Found in salt/modules/systemd_service.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 _default_runlevel has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def _default_runlevel():
        '''
        Try to figure out the default runlevel.  It is kept in
        /etc/init/rc-sysinit.conf, but can be overridden with entries
        in /etc/inittab, or via the kernel command-line at boot
    Severity: Minor
    Found in salt/modules/systemd_service.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_running has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_running():
        '''
        Return a list of all running services, so far as systemd is concerned
    
        CLI Example:
    Severity: Minor
    Found in salt/modules/systemd_service.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_disabled has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_disabled(root=None):
        '''
        Return a list of all disabled services
    
        root
    Severity: Minor
    Found in salt/modules/systemd_service.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_static has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_static(root=None):
        '''
        .. versionadded:: 2015.8.5
    
        Return a list of all static services
    Severity: Minor
    Found in salt/modules/systemd_service.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_enabled has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_enabled(root=None):
        '''
        Return a list of all enabled services
    
        root
    Severity: Minor
    Found in salt/modules/systemd_service.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_sysv_services has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def _get_sysv_services(root, systemd_services=None):
        '''
        Use os.listdir() and os.access() to get all the initscripts
        '''
        initscript_path = _root(INITSCRIPT_PATH, root)
    Severity: Minor
    Found in salt/modules/systemd_service.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 show has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def show(name, root=None):
        '''
        .. versionadded:: 2014.7.0
    
        Show properties of one or more units/jobs or the manager
    Severity: Minor
    Found in salt/modules/systemd_service.py - About 45 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 enable has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def enable(name, no_block=False, unmask=False, unmask_runtime=False,
               root=None, **kwargs):  # pylint: disable=unused-argument
        '''
        .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0
            On minions running systemd>=205, `systemd-run(1)`_ is now used to
    Severity: Minor
    Found in salt/modules/systemd_service.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 _get_service_exec has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def _get_service_exec():
        '''
        Returns the path to the sysv service manager (either update-rc.d or
        chkconfig)
        '''
    Severity: Minor
    Found in salt/modules/systemd_service.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 disable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def disable(name, no_block=False, root=None, **kwargs):  # pylint: disable=unused-argument
        '''
        .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0
            On minions running systemd>=205, `systemd-run(1)`_ is now used to
            isolate commands run by this function from the ``salt-minion`` daemon's
    Severity: Minor
    Found in salt/modules/systemd_service.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

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

    def _check_available(name):
        '''
        Returns boolean telling whether or not the named service is available
        '''
        _status = _systemctl_status(name)
    Severity: Minor
    Found in salt/modules/systemd_service.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

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

    def _systemctl_cmd(action, name=None, systemd_scope=False, no_block=False,
                       root=None):
        '''
        Build a systemctl command line. Treat unit names without one
        of the valid suffixes as a service.
    Severity: Minor
    Found in salt/modules/systemd_service.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

    def _default_runlevel():
        '''
        Try to figure out the default runlevel.  It is kept in
        /etc/init/rc-sysinit.conf, but can be overridden with entries
        in /etc/inittab, or via the kernel command-line at boot
    Severity: Major
    Found in salt/modules/systemd_service.py and 1 other location - About 2 days to fix
    salt/modules/upstart_service.py on lines 107..149

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

    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 3 locations. Consider refactoring.
    Open

        for line in salt.utils.itertools.split(out, '\n'):
            try:
                fullname, unit_state = line.strip().split(None, 1)
            except ValueError:
                continue
    Severity: Major
    Found in salt/modules/systemd_service.py and 2 other locations - About 6 hrs to fix
    salt/modules/systemd_service.py on lines 482..495
    salt/modules/systemd_service.py on lines 570..583

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

    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 3 locations. Consider refactoring.
    Open

        for line in salt.utils.itertools.split(out, '\n'):
            try:
                fullname, unit_state = line.strip().split(None, 1)
            except ValueError:
                continue
    Severity: Major
    Found in salt/modules/systemd_service.py and 2 other locations - About 6 hrs to fix
    salt/modules/systemd_service.py on lines 482..495
    salt/modules/systemd_service.py on lines 525..538

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

    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 3 locations. Consider refactoring.
    Open

        for line in salt.utils.itertools.split(out, '\n'):
            try:
                fullname, unit_state = line.strip().split(None, 1)
            except ValueError:
                continue
    Severity: Major
    Found in salt/modules/systemd_service.py and 2 other locations - About 6 hrs to fix
    salt/modules/systemd_service.py on lines 525..538
    salt/modules/systemd_service.py on lines 570..583

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

    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 4 locations. Consider refactoring.
    Open

    def restart(name, no_block=False, unmask=False, unmask_runtime=False):
        '''
        .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0
            On minions running systemd>=205, `systemd-run(1)`_ is now used to
            isolate commands run by this function from the ``salt-minion`` daemon's
    Severity: Major
    Found in salt/modules/systemd_service.py and 3 other locations - About 5 hrs to fix
    salt/modules/systemd_service.py on lines 808..861
    salt/modules/systemd_service.py on lines 953..1006
    salt/modules/systemd_service.py on lines 1009..1065

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

    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 4 locations. Consider refactoring.
    Open

    def reload_(name, no_block=False, unmask=False, unmask_runtime=False):
        '''
        .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0
            On minions running systemd>=205, `systemd-run(1)`_ is now used to
            isolate commands run by this function from the ``salt-minion`` daemon's
    Severity: Major
    Found in salt/modules/systemd_service.py and 3 other locations - About 5 hrs to fix
    salt/modules/systemd_service.py on lines 808..861
    salt/modules/systemd_service.py on lines 897..950
    salt/modules/systemd_service.py on lines 1009..1065

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

    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 4 locations. Consider refactoring.
    Open

    def start(name, no_block=False, unmask=False, unmask_runtime=False):
        '''
        .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0
            On minions running systemd>=205, `systemd-run(1)`_ is now used to
            isolate commands run by this function from the ``salt-minion`` daemon's
    Severity: Major
    Found in salt/modules/systemd_service.py and 3 other locations - About 5 hrs to fix
    salt/modules/systemd_service.py on lines 897..950
    salt/modules/systemd_service.py on lines 953..1006
    salt/modules/systemd_service.py on lines 1009..1065

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

    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 4 locations. Consider refactoring.
    Open

    def force_reload(name, no_block=True, unmask=False, unmask_runtime=False):
        '''
        .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0
            On minions running systemd>=205, `systemd-run(1)`_ is now used to
            isolate commands run by this function from the ``salt-minion`` daemon's
    Severity: Major
    Found in salt/modules/systemd_service.py and 3 other locations - About 5 hrs to fix
    salt/modules/systemd_service.py on lines 808..861
    salt/modules/systemd_service.py on lines 897..950
    salt/modules/systemd_service.py on lines 953..1006

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

    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 11 locations. Consider refactoring.
    Open

            if salt.utils.systemd.has_scope(__context__) \
                    and __salt__['config.get']('systemd.scope', True):
                cmd.extend(['systemd-run', '--scope'])
    Severity: Major
    Found in salt/modules/systemd_service.py and 10 other locations - About 1 hr to fix
    salt/modules/ebuildpkg.py on lines 740..742
    salt/modules/ebuildpkg.py on lines 831..833
    salt/modules/ebuildpkg.py on lines 923..925
    salt/modules/ebuildpkg.py on lines 1019..1021
    salt/modules/kernelpkg_linux_yum.py on lines 222..224
    salt/modules/pacmanpkg.py on lines 539..541
    salt/modules/pacmanpkg.py on lines 680..682
    salt/modules/pacmanpkg.py on lines 724..726
    salt/modules/systemd_service.py on lines 1221..1223
    salt/modules/yumpkg.py on lines 165..166

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

    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 11 locations. Consider refactoring.
    Open

            if salt.utils.systemd.has_scope(__context__) \
                    and __salt__['config.get']('systemd.scope', True):
                cmd.extend(['systemd-run', '--scope'])
    Severity: Major
    Found in salt/modules/systemd_service.py and 10 other locations - About 1 hr to fix
    salt/modules/ebuildpkg.py on lines 740..742
    salt/modules/ebuildpkg.py on lines 831..833
    salt/modules/ebuildpkg.py on lines 923..925
    salt/modules/ebuildpkg.py on lines 1019..1021
    salt/modules/kernelpkg_linux_yum.py on lines 222..224
    salt/modules/pacmanpkg.py on lines 539..541
    salt/modules/pacmanpkg.py on lines 680..682
    salt/modules/pacmanpkg.py on lines 724..726
    salt/modules/systemd_service.py on lines 1162..1164
    salt/modules/yumpkg.py on lines 165..166

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

    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 systemd_scope \
                and salt.utils.systemd.has_scope(__context__) \
                and __salt__['config.get']('systemd.scope', True):
            ret.extend(['systemd-run', '--scope'])
    Severity: Minor
    Found in salt/modules/systemd_service.py and 1 other location - About 45 mins to fix
    salt/modules/aptpkg.py on lines 166..167

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

    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