freqtrade/freqtrade

View on GitHub
freqtrade/persistence/migrations.py

Summary

Maintainability
B
6 hrs
Test Coverage

File migrations.py has 263 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
from typing import List, Optional

from sqlalchemy import inspect, select, text, update

Severity: Minor
Found in freqtrade/persistence/migrations.py - About 2 hrs to fix

    Function migrate_trades_and_orders_table has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def migrate_trades_and_orders_table(
            decl_base, inspector, engine,
            trade_back_name: str, cols: List,
            order_back_name: str, cols_order: List):
        base_currency = get_column_def(cols, 'base_currency', 'null')
    Severity: Minor
    Found in freqtrade/persistence/migrations.py - About 1 hr to fix

      Function migrate_trades_and_orders_table has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def migrate_trades_and_orders_table(
      Severity: Major
      Found in freqtrade/persistence/migrations.py - About 50 mins to fix

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

        def migrate_pairlocks_table(
        Severity: Minor
        Found in freqtrade/persistence/migrations.py - About 35 mins to fix

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

          def set_sequence_ids(engine, order_id, trade_id, pairlock_id=None):
          
              if engine.name == 'postgresql':
                  with engine.begin() as connection:
                      if order_id:
          Severity: Minor
          Found in freqtrade/persistence/migrations.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