saltstack/salt

View on GitHub
salt/modules/selinux.py

Summary

Maintainability
D
2 days
Test Coverage

File selinux.py has 640 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Execute calls on selinux

.. note::
Severity: Major
Found in salt/modules/selinux.py - About 1 day to fix

    Function list_semod has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def list_semod():
        '''
        Return a structure listing all of the selinux modules on the system and
        what state they are in
    
    
    Severity: Minor
    Found in salt/modules/selinux.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 setenforce has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def setenforce(mode):
        '''
        Set the SELinux enforcing mode
    
        CLI Example:
    Severity: Minor
    Found in salt/modules/selinux.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 fcontext_apply_policy has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def fcontext_apply_policy(name, recursive=False):
        '''
        .. versionadded:: 2017.7.0
    
        Applies SElinux policies to filespec using `restorecon [-R]
    Severity: Minor
    Found in salt/modules/selinux.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 selinux_fs_path has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def selinux_fs_path():
        '''
        Return the location of the SELinux VFS directory
    
        CLI Example:
    Severity: Minor
    Found in salt/modules/selinux.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 _fcontext_add_or_delete_policy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def _fcontext_add_or_delete_policy(action, name, filetype=None, sel_type=None, sel_user=None, sel_level=None):
        '''
        .. versionadded:: 2019.2.0
    
        Performs the action as called from ``fcontext_add_policy`` or ``fcontext_delete_policy``.
    Severity: Minor
    Found in salt/modules/selinux.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

    There are no issues that match your filters.

    Category
    Status