holgern/beem

View on GitHub

Showing 2,332 of 2,332 total issues

Merge this if statement with the enclosing one.
Open

        if "default_account" in stm.config:
Severity: Major
Found in beem/cli.py by sonar-python

Merging collapsible if statements increases the code's readability.

Noncompliant Code Example

if condition1:
    if condition2:
        # ...

Compliant Solution

if condition1 and condition2:
    # ...

Either merge this branch with the identical one on line "111" or change one of the implementations.
Open

            raise exceptions.NoMethodWithName(msg)
Severity: Major
Found in beemapi/noderpc.py by sonar-python

Having two branches in the same if structure with the same implementation is at best duplicate code, and at worst a coding error. If the same logic is truly needed for both instances, then they should be combined.

Noncompliant Code Example

if 0 <= a < 10:
    do_the_thing()
elif 10 <= a < 20:
    do_the_other_thing()
elif 20 <= a < 50:
    do_the_thing()  # Noncompliant; duplicates first condition
else:
    do_the_rest()

b = 4 if a > 12 else 4

Compliant Solution

if (0 <= a < 10) or (20 <= a < 50):
    do_the_thing()
elif 10 <= a < 20:
    do_the_other_thing()
else:
    do_the_rest()

b = 4

or

if 0 <= a < 10:
    do_the_thing()
elif 10 <= a < 20:
    do_the_other_thing()
elif 20 <= a < 50:
    do_the_third_thing()
else:
    do_the_rest()

b = 8 if a > 12 else 4

Refactor this function to reduce its Cognitive Complexity from 23 to the 15 allowed.
Open

def listaccounts(role, max_account_index, max_sequence):
Severity: Critical
Found in beem/cli.py by sonar-python

Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

See

Refactor this function to reduce its Cognitive Complexity from 41 to the 15 allowed.
Open

    def _check_error_message(self, e, cnt):
Severity: Critical
Found in beemapi/noderpc.py by sonar-python

Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

See

Refactor this function to reduce its Cognitive Complexity from 18 to the 15 allowed.
Open

def changekeys(account, owner, active, posting, memo, import_pub, export):
Severity: Critical
Found in beem/cli.py by sonar-python

Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

See

Refactor this function to reduce its Cognitive Complexity from 43 to the 15 allowed.
Open

def draw(block, trx_id, draws, participants, hashtype, separator, account, reply, without_replacement, markdown):
Severity: Critical
Found in beem/cli.py by sonar-python

Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

See

Merge this if statement with the enclosing one.
Open

        if "default_account" in stm.config:
Severity: Major
Found in beem/cli.py by sonar-python

Merging collapsible if statements increases the code's readability.

Noncompliant Code Example

if condition1:
    if condition2:
        # ...

Compliant Solution

if condition1 and condition2:
    # ...

Merge this if statement with the enclosing one.
Open

        if "default_account" in stm.config:
Severity: Major
Found in beem/cli.py by sonar-python

Merging collapsible if statements increases the code's readability.

Noncompliant Code Example

if condition1:
    if condition2:
        # ...

Compliant Solution

if condition1 and condition2:
    # ...

Rename function "formatTimeString" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.
Open

def formatTimeString(t):
Severity: Major
Found in beem/utils.py by sonar-python

Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

Noncompliant Code Example

With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}$

def MyFunction(a,b):
    ...

Compliant Solution

def my_function(a,b):
    ...

Refactor this function to reduce its Cognitive Complexity from 75 to the 15 allowed.
Open

def keygen(import_word_list, strength, passphrase, path, network, role, account_keys, sequence, account, wif, export_pub, export):
Severity: Critical
Found in beem/cli.py by sonar-python

Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

See

Refactor this function to reduce its Cognitive Complexity from 17 to the 15 allowed.
Open

def buy(amount, asset, price, account, orderid, export):
Severity: Critical
Found in beem/cli.py by sonar-python

Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

See

Refactor this function to reduce its Cognitive Complexity from 17 to the 15 allowed.
Open

def sell(amount, asset, price, account, orderid, export):
Severity: Critical
Found in beem/cli.py by sonar-python

Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

See

Refactor this function to reduce its Cognitive Complexity from 40 to the 15 allowed.
Open

def witnessfeed(witness, wif, base, quote, support_peg):
Severity: Critical
Found in beem/cli.py by sonar-python

Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

See

Merge this if statement with the enclosing one.
Open

        if "default_account" in stm.config:
Severity: Major
Found in beem/cli.py by sonar-python

Merging collapsible if statements increases the code's readability.

Noncompliant Code Example

if condition1:
    if condition2:
        # ...

Compliant Solution

if condition1 and condition2:
    # ...

Either merge this branch with the identical one on line "304" or change one of the implementations.
Open

            sbd = Amount(sbd, blockchain_instance=self)
Severity: Major
Found in beem/blurt.py by sonar-python

Having two branches in the same if structure with the same implementation is at best duplicate code, and at worst a coding error. If the same logic is truly needed for both instances, then they should be combined.

Noncompliant Code Example

if 0 <= a < 10:
    do_the_thing()
elif 10 <= a < 20:
    do_the_other_thing()
elif 20 <= a < 50:
    do_the_thing()  # Noncompliant; duplicates first condition
else:
    do_the_rest()

b = 4 if a > 12 else 4

Compliant Solution

if (0 <= a < 10) or (20 <= a < 50):
    do_the_thing()
elif 10 <= a < 20:
    do_the_other_thing()
else:
    do_the_rest()

b = 4

or

if 0 <= a < 10:
    do_the_thing()
elif 10 <= a < 20:
    do_the_other_thing()
elif 20 <= a < 50:
    do_the_third_thing()
else:
    do_the_rest()

b = 8 if a > 12 else 4

Method "__init__" has 11 parameters, which is greater than the 7 authorized.
Open

        self,
        data,
        klass=None,
        space_id=1,
        object_id=None,
Severity: Major
Found in beem/blockchainobject.py by sonar-python

A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.

Noncompliant Code Example

With a maximum number of 4 parameters:

def do_something(param1, param2, param3, param4, param5):
    ...

Compliant Solution

def do_something(param1, param2, param3, param4):
    ...

Refactor this function to reduce its Cognitive Complexity from 18 to the 15 allowed.
Open

def claimaccount(creator, fee, number, export):
Severity: Critical
Found in beem/cli.py by sonar-python

Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

See

Refactor this function to reduce its Cognitive Complexity from 29 to the 15 allowed.
Open

    def __init__(
Severity: Critical
Found in beem/blockchainobject.py by sonar-python

Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

See

Refactor this function to reduce its Cognitive Complexity from 37 to the 15 allowed.
Open

def stream(lines, head, table, follow):
Severity: Critical
Found in beem/cli.py by sonar-python

Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

See

Merge this if statement with the enclosing one.
Open

                if os.path.isfile(backup_file):
Severity: Major
Found in beemstorage/sqlite.py by sonar-python

Merging collapsible if statements increases the code's readability.

Noncompliant Code Example

if condition1:
    if condition2:
        # ...

Compliant Solution

if condition1 and condition2:
    # ...
Severity
Category
Status
Source
Language