xeroc/python-graphenelib

View on GitHub

Showing 136 of 136 total issues

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

def verify_message(message, signature, hashfn=hashlib.sha256):
    if not isinstance(message, bytes):
        message = bytes(message, "utf-8")
    if not isinstance(signature, bytes):  # pragma: no cover
        signature = bytes(signature, "utf-8")
Severity: Minor
Found in graphenebase/ecdsa.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 getKeyType has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def getKeyType(self, account, pub):
        """Get key type"""
        for authority in ["owner", "active"]:
            for key in account[authority]["key_auths"]:
                if str(pub) == key[0]:
Severity: Minor
Found in graphenecommon/wallet.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 __init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, *args, **kwargs):

        if len(args) == 1 and isinstance(args[0], self.__class__):
            # In this case, there is only one argument which is already an
            # instance of a class that inherits Graphene Object, hence, we copy
Severity: Minor
Found in graphenebase/objects.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

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

    def __init__(self, *args, **kwargs):
        EncryptedKeyInterface.__init__(self, *args, **kwargs)
        MasterPassword.__init__(self, *args, **kwargs)
Severity: Major
Found in graphenestorage/base.py and 3 other locations - About 30 mins to fix
graphenecommon/instance.py on lines 33..35
graphenestorage/base.py on lines 142..144
graphenestorage/base.py on lines 164..166

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

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

            def __init__(self, *args, **kwargs):
                slf.__init__(self, *args, **kwargs)
                cls.__init__(self, *args, **kwargs)
Severity: Major
Found in graphenecommon/instance.py and 3 other locations - About 30 mins to fix
graphenestorage/base.py on lines 108..110
graphenestorage/base.py on lines 142..144
graphenestorage/base.py on lines 164..166

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

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

Avoid too many return statements within this function.
Open

        return x ^ (y | ~z)
Severity: Major
Found in graphenebase/ripemd160.py - About 30 mins to fix

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

        def __init__(self, *args, **kwargs):
            InRamStore.__init__(self, *args, **kwargs)
            KeyEncryption.__init__(self, *args, **kwargs)
    Severity: Major
    Found in graphenestorage/base.py and 3 other locations - About 30 mins to fix
    graphenecommon/instance.py on lines 33..35
    graphenestorage/base.py on lines 108..110
    graphenestorage/base.py on lines 164..166

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

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

        def __init__(self, *args, **kwargs):
            SQLiteStore.__init__(self, *args, **kwargs)
            KeyEncryption.__init__(self, *args, **kwargs)
    Severity: Major
    Found in graphenestorage/base.py and 3 other locations - About 30 mins to fix
    graphenecommon/instance.py on lines 33..35
    graphenestorage/base.py on lines 108..110
    graphenestorage/base.py on lines 142..144

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

    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 refresh has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def refresh(self):
            if self.test_valid_objectid(self.identifier):
                _, i, _ = self.identifier.split(".")
                if int(i) == 6:
                    witness = self.blockchain.rpc.get_object(self.identifier)
    Severity: Minor
    Found in graphenecommon/witness.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 addSigningInformation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def addSigningInformation(self, account, permission):
            """This is a private method that adds side information to a
            unsigned/partial transaction in order to simplify later
            signing (e.g. for multisig or coldstorage)
    
    
    Severity: Minor
    Found in graphenecommon/transactionbuilder.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 fi has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def fi(x, y, z, i):
        """The f1, f2, f3, f4, and f5 functions from the specification."""
        if i == 0:
            return x ^ y ^ z
        elif i == 1:
    Severity: Minor
    Found in graphenebase/ripemd160.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 claimable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def claimable(self):
            if self["policy"][0] == 1:
                p = self["policy"][1]
                ratio = (
                    (
    Severity: Minor
    Found in graphenecommon/vesting.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 __init__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, *args, **kwargs):
            self.define_classes()
            assert self.privatekey_class
            assert self.default_key_store_app_name
    
    
    Severity: Minor
    Found in graphenecommon/wallet.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 broadcast has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def broadcast(self):
            """Broadcast a transaction to the blockchain network
    
            :param tx tx: Signed transaction to broadcast
            """
    Severity: Minor
    Found in graphenecommon/transactionbuilder.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 setup_proxy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def setup_proxy(self, options):
            proxy_url = options.pop("proxy", None)
            if proxy_url:  # pragma: no cover
                url = urllib.parse.urlparse(proxy_url)
                self.proxy_host = url.hostname
    Severity: Minor
    Found in grapheneapi/rpc.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 ops has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def ops(self, start=None, stop=None, **kwargs):
            """Yields all operations (excluding virtual operations) starting from
            ``start``.
    
            :param int start: Starting block
    Severity: Minor
    Found in graphenecommon/blockchain.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