brndnmtthws/optimal-buy-cbpro

View on GitHub

Showing 12 of 14 total issues

File optimal_buy_cbpro.py has 399 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3

import cbpro
import argparse
import sys
Severity: Minor
Found in optimal_buy_cbpro/optimal_buy_cbpro.py - About 5 hrs to fix

    Function get_fiat_balances has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_fiat_balances(args, coins, accounts, withdrawn_balances, prices):
        balances = {}
        for a in accounts:
            if a["currency"] == args.fiat_currency:
                balances[args.fiat_currency] = float(a["balance"])
    Severity: Minor
    Found in optimal_buy_cbpro/optimal_buy_cbpro.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 main has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def main():
        default_coins = """
        {
          "BTC":{
            "name":"Bitcoin",
    Severity: Minor
    Found in optimal_buy_cbpro/optimal_buy_cbpro.py - About 1 hr to fix

      Function start_buy_orders has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def start_buy_orders(
      Severity: Major
      Found in optimal_buy_cbpro/optimal_buy_cbpro.py - About 1 hr to fix

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

        def place_buy_orders(args, amount_to_buy, coins, coin, price, cbpro_client, db_session):
        Severity: Major
        Found in optimal_buy_cbpro/optimal_buy_cbpro.py - About 50 mins to fix

          Function set_buy_order has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def set_buy_order(args, coin, price, size, cbpro_client, db_session):
          Severity: Minor
          Found in optimal_buy_cbpro/optimal_buy_cbpro.py - About 45 mins to fix

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

            def generate_buy_orders(coins, coin, args, amount_to_buy, price):
            Severity: Minor
            Found in optimal_buy_cbpro/optimal_buy_cbpro.py - About 35 mins to fix

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

              def execute_withdrawal(cbpro_client, amount, currency, crypto_address, db_session):
              Severity: Minor
              Found in optimal_buy_cbpro/optimal_buy_cbpro.py - About 35 mins to fix

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

                def get_fiat_balances(args, coins, accounts, withdrawn_balances, prices):
                Severity: Minor
                Found in optimal_buy_cbpro/optimal_buy_cbpro.py - About 35 mins to fix

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

                  def start_buy_orders(
                      args, coins, accounts, prices, fiat_balances, fiat_amount, cbpro_client, db_session
                  ):
                      weights = get_weights(coins, args.fiat_currency)
                  
                  
                  Severity: Minor
                  Found in optimal_buy_cbpro/optimal_buy_cbpro.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 withdraw has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def withdraw(coins, accounts, cbpro_client, db_session):
                      for coin in coins:
                          if (
                              "withdrawal_address" not in coins[coin]
                              or coins[coin]["withdrawal_address"] is None
                  Severity: Minor
                  Found in optimal_buy_cbpro/optimal_buy_cbpro.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 main has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def main():
                      default_coins = """
                      {
                        "BTC":{
                          "name":"Bitcoin",
                  Severity: Minor
                  Found in optimal_buy_cbpro/optimal_buy_cbpro.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

                  Severity
                  Category
                  Status
                  Source
                  Language