sirfoga/pyhodl

View on GitHub

Showing 18 of 18 total issues

Function _color_table has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def _color_table(table, floats, eps=1e-3):
        """
        :param table: [] of []
            Matrix
        :param floats: [] of int
Severity: Minor
Found in pyhodl/tools/balance.py - About 2 hrs 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 handle_rate_limits has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def handle_rate_limits(func, time_wait=60, max_attempts=2):
    """
    :param func: callback function
        function to wrap
    :param time_wait: int
Severity: Minor
Found in pyhodl/utils/network.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 get_prices has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def get_prices(self, coins, **kwargs):
        if "dates" in kwargs:
            dates = kwargs["dates"]
        else:  # args since, until and hours provided
            dates = generate_dates(
Severity: Minor
Found in pyhodl/api/price/coinmarketcap.py - About 55 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 parse_timedelta has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def parse_timedelta(raw):
    """
    :param raw: str
        Time interval written in short format
    :return: timedelta
Severity: Minor
Found in pyhodl/utils/dates.py - About 55 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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, raw_dict, coin_in, coin_out, date,
Severity: Major
Found in pyhodl/core/transactions.py - About 50 mins to fix

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

    def download_prices(coins, since, until, where_to, verbose, currency="USD",
    Severity: Major
    Found in pyhodl/cli.py - About 50 mins to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      Severity: Minor
      Found in pyhodl/api/markets/coinbase.py and 1 other location - About 45 mins to fix
      pyhodl/api/markets/binance.py on lines 0..18

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 35.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      Severity: Minor
      Found in pyhodl/api/markets/binance.py and 1 other location - About 45 mins to fix
      pyhodl/api/markets/coinbase.py on lines 0..18

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 35.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

      def normalize(val, min_val, max_val, min_range=-1.0, max_range=1.0):
      Severity: Minor
      Found in pyhodl/utils/misc.py - About 35 mins to fix

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

        def print_balance_info(total_value, delta, percentage, last_time, color=False):
        Severity: Minor
        Found in pyhodl/utils/misc.py - About 35 mins to fix

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

          def color_number(number, low_color=Fore.RED,
          Severity: Minor
          Found in pyhodl/utils/misc.py - About 35 mins to fix

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

            def build_parser(input_file):
                """
                :param input_file: str
                    File to parse
                :return: CryptoExchange
            Severity: Minor
            Found in pyhodl/data/parse/build.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

            Avoid too many return statements within this function.
            Open

                    return timedelta(days=7 * time_token)
            Severity: Major
            Found in pyhodl/utils/dates.py - About 30 mins to fix

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

                  def build_wallets(self):
                      """
                      :return: {} of str -> Wallet
                          Build a wallet for each currency traded and put trading history
                          there
              Severity: Minor
              Found in pyhodl/core/exchanges.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

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

                  def get_values_on(self, date_time):
                      """
                      :param date_time: datetime
                          Date to get values of
                      :return: {}
              Severity: Minor
              Found in pyhodl/data/tables.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

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

                  def has(self, item):
                      """
                      :param item: str
                          Item to look for
                      :return: bool
              Severity: Minor
              Found in pyhodl/core/transactions.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

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

                  def get_amount_buy_sell(self, coin):
                      """
                      :param coin: Coin
                          Coin to get
                      :return: float
              Severity: Minor
              Found in pyhodl/core/transactions.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

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

                  def fetch_prices(self, coins, date_time, currency):
                      """
                      :param coins: [] of str
                          List of coins
                      :param date_time: datetime
              Severity: Minor
              Found in pyhodl/api/price/cryptocompare.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