saltstack/salt

View on GitHub
salt/modules/test.py

Summary

Maintainability
D
1 day
Test Coverage

File test.py has 469 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Module for running arbitrary tests
'''
from __future__ import absolute_import, print_function, unicode_literals
Severity: Minor
Found in salt/modules/test.py - About 7 hrs to fix

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

    def module_report():
        '''
        Return a dict containing all of the execution modules with a report on
        the overall availability via different references
    
    
    Severity: Minor
    Found in salt/modules/test.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 not_loaded has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def not_loaded():
        '''
        List the modules that were not loaded by the salt loader system
    
        CLI Example:
    Severity: Minor
    Found in salt/modules/test.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 raise_exception has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def raise_exception(name, *args, **kwargs):
        '''
        Raise an exception. Built-in exceptions and those in ``salt.exceptions``
        can be raised by this test function. If no matching exception is found,
        then no exception will be raised and this function will return ``False``.
    Severity: Minor
    Found in salt/modules/test.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 collatz has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def collatz(start):
        '''
        Execute the collatz conjecture from the passed starting number,
        returns the sequence and the time it took to compute. Used for
        performance tests.
    Severity: Minor
    Found in salt/modules/test.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

    There are no issues that match your filters.

    Category
    Status