freqtrade/freqtrade

View on GitHub
freqtrade/optimize/optimize_reports/bt_output.py

Summary

Maintainability
B
5 hrs
Test Coverage

File bt_output.py has 315 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
from typing import Any, Dict, List

from tabulate import tabulate

Severity: Minor
Found in freqtrade/optimize/optimize_reports/bt_output.py - About 3 hrs to fix

    Function text_table_add_metrics has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def text_table_add_metrics(strat_results: Dict) -> str:
        if len(strat_results['trades']) > 0:
            best_trade = max(strat_results['trades'], key=lambda x: x['profit_ratio'])
            worst_trade = min(strat_results['trades'], key=lambda x: x['profit_ratio'])
    
    
    Severity: Minor
    Found in freqtrade/optimize/optimize_reports/bt_output.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 generate_wins_draws_losses has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def generate_wins_draws_losses(wins, draws, losses):
        if wins > 0 and losses == 0:
            wl_ratio = '100'
        elif wins == 0:
            wl_ratio = '0'
    Severity: Minor
    Found in freqtrade/optimize/optimize_reports/bt_output.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