xeroc/python-graphenelib

View on GitHub

Showing 136 of 136 total issues

Consider simplifying this complex logical expression.
Open

        if len(args) == 1 and isinstance(args[0], str) and not base and not quote:
            import re

            price, assets = args[0].split(" ")
            base_symbol, quote_symbol = assets_from_string(assets)
Severity: Critical
Found in graphenecommon/price.py - About 7 hrs to fix

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

            elif (
                len(args) == 1
                and isinstance(args[0], dict)
                and "amount" in args[0]
                and "asset" in args[0]
    Severity: Major
    Found in graphenecommon/amount.py and 1 other location - About 7 hrs to fix
    graphenecommon/amount.py on lines 77..87

    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 110.

    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

            elif (
                len(args) == 1
                and isinstance(args[0], dict)
                and "amount" in args[0]
                and "asset_id" in args[0]
    Severity: Major
    Found in graphenecommon/amount.py and 1 other location - About 7 hrs to fix
    graphenecommon/amount.py on lines 89..99

    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 110.

    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

    Consider simplifying this complex logical expression.
    Open

            if len(args) == 1 and isinstance(args[0], str) and not base and not quote:
                import re
    
                price, assets = args[0].split(" ")
                base_symbol, quote_symbol = assets_from_string(assets)
    Severity: Critical
    Found in graphenecommon/aio/price.py - About 7 hrs to fix

      File transactionbuilder.py has 453 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # -*- coding: utf-8 -*-
      import struct
      import logging
      from datetime import datetime, timedelta
      from binascii import unhexlify
      Severity: Minor
      Found in graphenecommon/transactionbuilder.py - About 6 hrs to fix

        File price.py has 406 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # -*- coding: utf-8 -*-
        from fractions import Fraction
        from .exceptions import InvalidAssetException
        from .utils import assets_from_string, formatTimeString, parse_time
        from .instance import AbstractBlockchainInstanceProvider
        Severity: Minor
        Found in graphenecommon/price.py - About 5 hrs to fix

          File account.py has 382 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # -*- coding: utf-8 -*-
          from __future__ import absolute_import
          
          import hashlib
          import re
          Severity: Minor
          Found in graphenebase/account.py - About 5 hrs to fix

            File ripemd160.py has 369 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            # -*- coding: utf-8 -*-
            # Copyright (c) 2021 Pieter Wuille
            # Distributed under the MIT software license, see the accompanying
            # file COPYING or http://www.opensource.org/licenses/mit-license.php.
            
            
            Severity: Minor
            Found in graphenebase/ripemd160.py - About 4 hrs to fix

              Consider simplifying this complex logical expression.
              Open

                      if len(args) == 1 and isinstance(args[0], Amount):
                          # Copy Asset object
                          self["amount"] = args[0]["amount"]
                          self["symbol"] = args[0]["symbol"]
                          self["asset"] = args[0]["asset"]
              Severity: Critical
              Found in graphenecommon/aio/amount.py - About 4 hrs to fix

                Consider simplifying this complex logical expression.
                Open

                        if len(args) == 1 and isinstance(args[0], Amount):
                            # Copy Asset object
                            self["amount"] = args[0]["amount"]
                            self["symbol"] = args[0]["symbol"]
                            self["asset"] = args[0]["asset"]
                Severity: Critical
                Found in graphenecommon/amount.py - About 4 hrs to fix

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

                  def sign_message(message, wif, hashfn=hashlib.sha256):
                      """Sign a digest with a wif key
                  
                      :param str wif: Private key in
                      """
                  Severity: Minor
                  Found in graphenebase/ecdsa.py - About 4 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

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

                          if isinstance(other, Amount):
                              assert other["asset"]["id"] == self["asset"]["id"]
                              self["amount"] *= other["amount"]
                          else:
                              self["amount"] *= other
                  Severity: Major
                  Found in graphenecommon/amount.py and 1 other location - About 4 hrs to fix
                  graphenecommon/amount.py on lines 204..208

                  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 75.

                  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

                          if isinstance(other, Amount):
                              assert other["asset"]["id"] == self["asset"]["id"]
                              a["amount"] *= other["amount"]
                          else:
                              a["amount"] *= other
                  Severity: Major
                  Found in graphenecommon/amount.py and 1 other location - About 4 hrs to fix
                  graphenecommon/amount.py on lines 260..264

                  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 75.

                  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

                  Amount has 31 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class Amount(dict, AbstractBlockchainInstanceProvider):
                      """This class deals with Amounts of any asset to simplify dealing with the tuple::
                  
                          (amount, asset)
                  
                  
                  Severity: Minor
                  Found in graphenecommon/amount.py - About 3 hrs to fix

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

                        def __init__(
                            self,
                            *args,
                            base=None,
                            quote=None,
                    Severity: Minor
                    Found in graphenecommon/price.py - About 3 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

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

                            if not account["options"]["memo_key"] == memo_key:
                                raise WrongMemoKey(
                                    "Memo Key of account {} on the Blockchain ".format(account["name"])
                                    + "differs from memo key in the message: {} != {}".format(
                                        account["options"]["memo_key"], memo_key
                    Severity: Major
                    Found in graphenecommon/message.py and 1 other location - About 3 hrs to fix
                    graphenecommon/message.py on lines 290..294

                    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 70.

                    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

                    Wallet has 30 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class Wallet(AbstractBlockchainInstanceProvider):
                        """The wallet is meant to maintain access to private keys for
                        your accounts. It either uses manually provided private keys
                        or uses a SQLite database managed by storage.py.
                    
                    
                    Severity: Minor
                    Found in graphenecommon/wallet.py - About 3 hrs to fix

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

                              if not account["options"]["memo_key"] == memo_key:
                                  raise WrongMemoKey(
                                      "Memo Key of account {} on the Blockchain ".format(account["name"])
                                      + "differs from memo key in the message: {} != {}".format(
                                          account["options"]["memo_key"], memo_key
                      Severity: Major
                      Found in graphenecommon/message.py and 1 other location - About 3 hrs to fix
                      graphenecommon/message.py on lines 163..167

                      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 70.

                      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

                      TransactionBuilder has 29 functions (exceeds 20 allowed). Consider refactoring.
                      Open

                      class TransactionBuilder(dict, AbstractBlockchainInstanceProvider):
                          """This class simplifies the creation of transactions by adding
                          operations and signers.
                          """
                      
                      
                      Severity: Minor
                      Found in graphenecommon/transactionbuilder.py - About 3 hrs to fix

                        File transactionbuilder.py has 306 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        # -*- coding: utf-8 -*-
                        import struct
                        import logging
                        from binascii import unhexlify
                        from ..exceptions import (
                        Severity: Minor
                        Found in graphenecommon/aio/transactionbuilder.py - About 3 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language