nvbn/thefuck

View on GitHub
thefuck/utils.py

Summary

Maintainability
B
6 hrs
Test Coverage

File utils.py has 255 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import atexit
import os
import pickle
import re
import shelve
Severity: Minor
Found in thefuck/utils.py - About 2 hrs to fix

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

    def which(program):
        """Returns `program` path or `None`."""
        try:
            from shutil import which
    
    
    Severity: Minor
    Found in thefuck/utils.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_all_matched_commands has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_all_matched_commands(stderr, separator='Did you mean'):
        if not isinstance(separator, list):
            separator = [separator]
        should_yield = False
        for line in stderr.split('\n'):
    Severity: Minor
    Found in thefuck/utils.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_valid_history_without_current has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_valid_history_without_current(command):
        def _not_corrected(history, tf_alias):
            """Returns all lines from history except that comes before `fuck`."""
            previous = None
            for line in history:
    Severity: Minor
    Found in thefuck/utils.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 memoize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def memoize(fn):
        """Caches previous calls to the function."""
        memo = {}
    
        @wraps(fn)
    Severity: Minor
    Found in thefuck/utils.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