freqtrade/freqtrade

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

Summary

Maintainability
C
1 day
Test Coverage

File optimize_reports.py has 450 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
from copy import deepcopy
from datetime import datetime, timedelta, timezone
from typing import Any, Dict, List, Tuple, Union

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

    Function generate_strategy_stats has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def generate_strategy_stats(pairlist: List[str],
                                strategy: str,
                                content: Dict[str, Any],
                                min_date: datetime, max_date: datetime,
                                market_change: float,
    Severity: Minor
    Found in freqtrade/optimize/optimize_reports/optimize_reports.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_strategy_stats has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def generate_strategy_stats(pairlist: List[str],
    Severity: Major
    Found in freqtrade/optimize/optimize_reports/optimize_reports.py - About 50 mins to fix

      Function generate_pair_metrics has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def generate_pair_metrics(pairlist: List[str], stake_currency: str, starting_balance: int,
      Severity: Minor
      Found in freqtrade/optimize/optimize_reports/optimize_reports.py - About 35 mins to fix

        Function generate_tag_metrics has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def generate_tag_metrics(tag_type: str,
                                 starting_balance: int,
                                 results: DataFrame,
                                 skip_nan: bool = False) -> List[Dict]:
            """
        Severity: Minor
        Found in freqtrade/optimize/optimize_reports/optimize_reports.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 generate_trade_signal_candles has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def generate_trade_signal_candles(preprocessed_df: Dict[str, DataFrame],
                                          bt_results: Dict[str, Any]) -> DataFrame:
            signal_candles_only = {}
            for pair in preprocessed_df.keys():
                signal_candles_only_df = DataFrame()
        Severity: Minor
        Found in freqtrade/optimize/optimize_reports/optimize_reports.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