xeroc/python-graphenelib

View on GitHub

Showing 82 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

    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

                  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

                    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

                      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

                          File types.py has 301 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          # -*- coding: utf-8 -*-
                          import json
                          import struct
                          import time
                          from calendar import timegm
                          Severity: Minor
                          Found in graphenebase/types.py - About 3 hrs to fix

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

                                def history(self, first=0, last=0, limit=-1, only_ops=[], exclude_ops=[]):
                                    """Returns a generator for individual account transactions. The
                                    latest operation will be first. This call can be used in a
                                    ``for`` loop.
                            
                            
                            Severity: Minor
                            Found in graphenecommon/account.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

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

                            def recoverPubkeyParameter(message, digest, signature, pubkey):
                                """Use to derive a number that allows to easily recover the
                                public key from the signature
                                """
                                if not isinstance(message, bytes):
                            Severity: Minor
                            Found in graphenebase/ecdsa.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

                            File message.py has 281 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            # -*- coding: utf-8 -*-
                            import json
                            import logging
                            import re
                            
                            
                            Severity: Minor
                            Found in graphenecommon/message.py - About 2 hrs to fix

                              File amount.py has 275 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              # -*- coding: utf-8 -*-
                              from .asset import Asset
                              from .instance import AbstractBlockchainInstanceProvider
                              
                              
                              
                              Severity: Minor
                              Found in graphenecommon/amount.py - About 2 hrs to fix

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

                                    def __init__(self, data, klass=None, lazy=False, use_cache=True, *args, **kwargs):
                                        Caching.__init__(self, *args, **kwargs)
                                        self._use_cache = use_cache
                                        if self.perform_id_tests:
                                            assert self.type_id or self.type_ids, "Need type_id or type_ids"
                                Severity: Minor
                                Found in graphenecommon/blockchainobject.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

                                Severity
                                Category
                                Status
                                Source
                                Language