xeroc/python-graphenelib

View on GitHub

Showing 136 of 136 total issues

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

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

        def sql_fetchall(self, query):
            connection = sqlite3.connect(self.sqlite_file)
            try:
                cursor = connection.cursor()
                cursor.execute(*query)
    Severity: Major
    Found in graphenestorage/sqlite.py and 1 other location - About 2 hrs to fix
    graphenestorage/sqlite.py on lines 70..78

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

    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

        def sql_fetchone(self, query):
            connection = sqlite3.connect(self.sqlite_file)
            try:
                cursor = connection.cursor()
                cursor.execute(*query)
    Severity: Major
    Found in graphenestorage/sqlite.py and 1 other location - About 2 hrs to fix
    graphenestorage/sqlite.py on lines 80..88

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

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

        Price has 23 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Price(dict, AbstractBlockchainInstanceProvider):
            """This class deals with all sorts of prices of any pair of assets to
            simplify dealing with the tuple::
        
                (quote, base)
        Severity: Minor
        Found in graphenecommon/price.py - About 2 hrs to fix

          AbstractGrapheneChain has 23 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class AbstractGrapheneChain:
              def define_classes(self):
                  raise NotImplementedError
          
              def __init__(
          Severity: Minor
          Found in graphenecommon/chain.py - About 2 hrs to fix

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

                def _fetchkeys(self, account, perm, level=0, required_treshold=1):
            
                    # Do not travel recursion more than 2 levels
                    if level > 2:
                        return []
            Severity: Minor
            Found in graphenecommon/transactionbuilder.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 appendSigner has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

                def appendSigner(self, accounts, permission):
                    """Try to obtain the wif key from the wallet by telling which account
                    and permission is supposed to sign the transaction
            
                    :param str,list,tuple,set accounts: accounts to sign transaction with
            Severity: Minor
            Found in graphenecommon/transactionbuilder.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

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

            class Uint16:
                def __init__(self, d):
                    self.data = int(d)
            
                def __bytes__(self):
            Severity: Major
            Found in graphenebase/types.py and 4 other locations - About 2 hrs to fix
            graphenebase/types.py on lines 56..64
            graphenebase/types.py on lines 89..97
            graphenebase/types.py on lines 100..108
            graphenebase/types.py on lines 122..130

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

            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 5 locations. Consider refactoring.
            Open

            class Uint32:
                def __init__(self, d):
                    self.data = int(d)
            
                def __bytes__(self):
            Severity: Major
            Found in graphenebase/types.py and 4 other locations - About 2 hrs to fix
            graphenebase/types.py on lines 56..64
            graphenebase/types.py on lines 78..86
            graphenebase/types.py on lines 100..108
            graphenebase/types.py on lines 122..130

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

            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 5 locations. Consider refactoring.
            Open

            class Int64:
                def __init__(self, d):
                    self.data = int(d)
            
                def __bytes__(self):
            Severity: Major
            Found in graphenebase/types.py and 4 other locations - About 2 hrs to fix
            graphenebase/types.py on lines 56..64
            graphenebase/types.py on lines 78..86
            graphenebase/types.py on lines 89..97
            graphenebase/types.py on lines 100..108

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

            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 5 locations. Consider refactoring.
            Open

            class Uint64:
                def __init__(self, d):
                    self.data = int(d)
            
                def __bytes__(self):
            Severity: Major
            Found in graphenebase/types.py and 4 other locations - About 2 hrs to fix
            graphenebase/types.py on lines 56..64
            graphenebase/types.py on lines 78..86
            graphenebase/types.py on lines 89..97
            graphenebase/types.py on lines 122..130

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

            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 5 locations. Consider refactoring.
            Open

            class Uint8:
                def __init__(self, d):
                    self.data = int(d)
            
                def __bytes__(self):
            Severity: Major
            Found in graphenebase/types.py and 4 other locations - About 2 hrs to fix
            graphenebase/types.py on lines 78..86
            graphenebase/types.py on lines 89..97
            graphenebase/types.py on lines 100..108
            graphenebase/types.py on lines 122..130

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

            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"]
            Severity: Major
            Found in graphenecommon/amount.py and 1 other location - About 2 hrs to fix
            graphenecommon/amount.py on lines 252..254

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

            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"]
                        self["amount"] -= other["amount"]
            Severity: Major
            Found in graphenecommon/amount.py and 1 other location - About 2 hrs to fix
            graphenecommon/amount.py on lines 195..197

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

            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

            File chain.py has 257 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            # -*- coding: utf-8 -*-
            import logging
            from graphenestorage import SqliteConfigurationStore
            
            log = logging.getLogger(__name__)
            Severity: Minor
            Found in graphenecommon/chain.py - About 2 hrs to fix
              Severity
              Category
              Status
              Source
              Language