freqtrade/freqtrade

View on GitHub
freqtrade/freqai/RL/BaseEnvironment.py

Summary

Maintainability
C
1 day
Test Coverage

File BaseEnvironment.py has 299 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
import random
from abc import abstractmethod
from enum import Enum
from typing import List, Optional, Type, Union
Severity: Minor
Found in freqtrade/freqai/RL/BaseEnvironment.py - About 3 hrs to fix

    BaseEnvironment has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class BaseEnvironment(gym.Env):
        """
        Base class for environments. This class is agnostic to action count.
        Inherited classes customize this to include varying action counts/types,
        See RL/Base5ActionRLEnv.py and RL/Base4ActionRLEnv.py
    Severity: Minor
    Found in freqtrade/freqai/RL/BaseEnvironment.py - About 2 hrs to fix

      Function __init__ has 13 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, df: DataFrame = DataFrame(), prices: DataFrame = DataFrame(),
      Severity: Major
      Found in freqtrade/freqai/RL/BaseEnvironment.py - About 1 hr to fix

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

            def reset_env(self, df: DataFrame, prices: DataFrame, window_size: int,
        Severity: Minor
        Found in freqtrade/freqai/RL/BaseEnvironment.py - About 35 mins to fix

          Avoid too many return statements within this function.
          Open

                      return 0.
          Severity: Major
          Found in freqtrade/freqai/RL/BaseEnvironment.py - About 30 mins to fix

            Function tensorboard_log has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def tensorboard_log(self, metric: str, value: Optional[Union[int, float]] = None,
                                    inc: Optional[bool] = None, category: str = "custom"):
                    """
                    Function builds the tensorboard_metrics dictionary
                    to be parsed by the TensorboardCallback. This
            Severity: Minor
            Found in freqtrade/freqai/RL/BaseEnvironment.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