thenetcircle/dino

View on GitHub
dino/validation/acl.py

Summary

Maintainability
F
6 days
Test Coverage

File acl.py has 560 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Severity: Major
Found in dino/validation/acl.py - About 1 day to fix

    Cyclomatic complexity is too high in method validate_acl_for_action. (27)
    Open

        def validate_acl_for_action(
                self,
                activity: Activity,
                target: str,
                action: str,
    Severity: Minor
    Found in dino/validation/acl.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Function validate_acl_for_action has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate_acl_for_action(
                self,
                activity: Activity,
                target: str,
                action: str,
    Severity: Minor
    Found in dino/validation/acl.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

    Cyclomatic complexity is too high in method __call__. (21)
    Open

        def __call__(self, *args, **kwargs):
            # activity = args[0]
            env = args[1]
            acl_type = args[2]
            acl_range = args[3]
    Severity: Minor
    Found in dino/validation/acl.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

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

        def _split_and_test_clause(self, groups, clause, is_validating_a_user: bool=False, activity: Activity=None, env=None):
            """
            The default value for is_validating_a_user is False, meaning we're validating a new acl rule someone set in the
            admin web interface. In this case the activity and env variables are not used. On the other hand, if
            is_validating_a_user is set to true, it means we're validating the "custom" acl rule for something a user did
    Severity: Minor
    Found in dino/validation/acl.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

    Cyclomatic complexity is too high in class AclValidator. (17)
    Open

    class AclValidator(object):
        def is_acl_valid(self, acl_type, acl_value):
            all_acls = environ.env.config.get(ConfigKeys.ACL)
            all_validators = all_acls['validation']
    
    
    Severity: Minor
    Found in dino/validation/acl.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in method _split_and_test_clause. (17)
    Open

        def _split_and_test_clause(self, groups, clause, is_validating_a_user: bool=False, activity: Activity=None, env=None):
            """
            The default value for is_validating_a_user is False, meaning we're validating a new acl rule someone set in the
            admin web interface. In this case the activity and env variables are not used. On the other hand, if
            is_validating_a_user is set to true, it means we're validating the "custom" acl rule for something a user did
    Severity: Minor
    Found in dino/validation/acl.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in method validate_new_acl. (16)
    Open

        def validate_new_acl(self, values: str):
            if values is None or len(values.strip()) == 0:
                raise ValidationException('blank pattern')
    
            if self.pattern.match(values) is None:
    Severity: Minor
    Found in dino/validation/acl.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Function __call__ has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        def __call__(self, *args, **kwargs):
            # activity = args[0]
            env = args[1]
            acl_type = args[2]
            acl_range = args[3]
    Severity: Minor
    Found in dino/validation/acl.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 check_acl_actions has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_acl_actions(check_acls: list, actions: dict, available_acls: list) -> None:
            for acl_target, acls in check_acls:
                if acls is None or len(acls) == 0:
                    continue
    
    
    Severity: Minor
    Found in dino/validation/acl.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

    Cyclomatic complexity is too high in class AclCsvInCsvValidator. (12)
    Open

    class AclCsvInCsvValidator(BaseInCsvAclValidator):
        def __call__(self, *args, **kwargs):
            # activity = args[0]
            env = args[1]
            acl_type = args[2]
    Severity: Minor
    Found in dino/validation/acl.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in method __call__. (12)
    Open

        def __call__(self, *args, **kwargs):
            # activity = args[0]
            env = args[1]
            acl_type = args[2]
            acl_values = args[3]
    Severity: Minor
    Found in dino/validation/acl.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in method check_acl_actions. (10)
    Open

        @staticmethod
        def check_acl_actions(check_acls: list, actions: dict, available_acls: list) -> None:
            for acl_target, acls in check_acls:
                if acls is None or len(acls) == 0:
                    continue
    Severity: Minor
    Found in dino/validation/acl.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in method check_acl_validation_methods. (10)
    Open

        @staticmethod
        def check_acl_validation_methods(acls: dict, available_acls: list) -> None:
            validation_methods = [
                'csv_in_csv', 'str_in_csv', 'range', 'samechannel', 'sameroom', 'disallow',
                'is_admin', 'is_super_user', 'anything', 'custom', 'is_room_owner'
    Severity: Minor
    Found in dino/validation/acl.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in class AclRangeValidator. (10)
    Open

    class AclRangeValidator(BaseAclValidator):
        def __init__(self):
            pass
    
        def validate_new_acl(self, values: str):
    Severity: Minor
    Found in dino/validation/acl.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in method __call__. (10)
    Open

        def __call__(self, *args, **kwargs):
            activity = args[0]
            # env = args[1]
            # acl_type = args[2]
            # acl_values = args[3]
    Severity: Minor
    Found in dino/validation/acl.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

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

        def __call__(self, *args, **kwargs):
            # activity = args[0]
            env = args[1]
            acl_type = args[2]
            acl_values = args[3]
    Severity: Minor
    Found in dino/validation/acl.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

    Cyclomatic complexity is too high in class AclPatternValidator. (9)
    Open

    class AclPatternValidator(BaseAclValidator):
        def __init__(self):
            self.acl_type = 'custom'
            pattern = '^[0-9a-z!\|,\(\):=_]*$'
    
    
    Severity: Minor
    Found in dino/validation/acl.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in method _test_a_clause. (9)
    Open

        def _test_a_clause(self, clause, is_validating_a_user: bool, activity: Activity=None, env=None):
            if '=' not in clause:
                raise ValidationException('no equal sign in clause: %s' % clause)
    
            if len(clause.split('=')) != 2:
    Severity: Minor
    Found in dino/validation/acl.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in method __call__. (9)
    Open

        def __call__(self, *args, **kwargs):
            activity = args[0]
            # env = args[1]
            # acl_type = args[2]
            # acl_values = args[3]
    Severity: Minor
    Found in dino/validation/acl.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Function check_acl_validation_methods has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_acl_validation_methods(acls: dict, available_acls: list) -> None:
            validation_methods = [
                'csv_in_csv', 'str_in_csv', 'range', 'samechannel', 'sameroom', 'disallow',
                'is_admin', 'is_super_user', 'anything', 'custom', 'is_room_owner'
            ]
    Severity: Minor
    Found in dino/validation/acl.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

    Cyclomatic complexity is too high in method __call__. (8)
    Open

        def __call__(self, *args, **kwargs):
            # activity = args[0]
            env = args[1]
            acl_type = args[2]
            acl_values = args[3]
    Severity: Minor
    Found in dino/validation/acl.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in class AclStrInCsvValidator. (8)
    Open

    class AclStrInCsvValidator(BaseInCsvAclValidator):
        def __call__(self, *args, **kwargs):
            # activity = args[0]
            env = args[1]
            acl_type = args[2]
    Severity: Minor
    Found in dino/validation/acl.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in method validate_new_acl. (8)
    Open

        def validate_new_acl(self, values: str):
            if values is None or len(values.strip()) == 0:
                raise ValidationException('blank range when creating AclRangeValidator')
    
            if ':' not in values:
    Severity: Minor
    Found in dino/validation/acl.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in method is_acl_valid. (6)
    Open

        def is_acl_valid(self, acl_type, acl_value):
            all_acls = environ.env.config.get(ConfigKeys.ACL)
            all_validators = all_acls['validation']
    
            if acl_type not in all_validators:
    Severity: Minor
    Found in dino/validation/acl.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in method validate_new_acl. (6)
    Open

        def validate_new_acl(self, values: str):
            # all new values accepted, e.g. for city or country
            if self.valid_csvs is None:
                return
    
    
    Severity: Minor
    Found in dino/validation/acl.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in method check_acl_rules. (6)
    Open

        @staticmethod
        def check_acl_rules(acls: dict, all_actions: dict, rules: list) -> None:
            for target, actions in acls.items():
                if target not in all_actions:
                    continue
    Severity: Minor
    Found in dino/validation/acl.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Function validate_new_acl has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate_new_acl(self, values: str):
            if values is None or len(values.strip()) == 0:
                raise ValidationException('blank pattern')
    
            if self.pattern.match(values) is None:
    Severity: Minor
    Found in dino/validation/acl.py - About 1 hr 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 check_acl_rules has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_acl_rules(acls: dict, all_actions: dict, rules: list) -> None:
            for target, actions in acls.items():
                if target not in all_actions:
                    continue
    
    
    Severity: Minor
    Found in dino/validation/acl.py - About 1 hr 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 _test_a_clause has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def _test_a_clause(self, clause, is_validating_a_user: bool, activity: Activity=None, env=None):
            if '=' not in clause:
                raise ValidationException('no equal sign in clause: %s' % clause)
    
            if len(clause.split('=')) != 2:
    Severity: Minor
    Found in dino/validation/acl.py - About 1 hr 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 validate_acl_for_action has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def validate_acl_for_action(
    Severity: Major
    Found in dino/validation/acl.py - About 1 hr to fix

      Function __call__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def __call__(self, *args, **kwargs):
              # activity = args[0]
              env = args[1]
              acl_type = args[2]
              acl_values = args[3]
      Severity: Minor
      Found in dino/validation/acl.py - About 45 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 validate_new_acl has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def validate_new_acl(self, values: str):
              if values is None or len(values.strip()) == 0:
                  raise ValidationException('blank range when creating AclRangeValidator')
      
              if ':' not in values:
      Severity: Minor
      Found in dino/validation/acl.py - About 45 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 __call__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def __call__(self, *args, **kwargs):
              activity = args[0]
              # env = args[1]
              # acl_type = args[2]
              # acl_values = args[3]
      Severity: Minor
      Found in dino/validation/acl.py - About 45 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 __call__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def __call__(self, *args, **kwargs):
              activity = args[0]
              # env = args[1]
              # acl_type = args[2]
              # acl_values = args[3]
      Severity: Minor
      Found in dino/validation/acl.py - About 45 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 _split_and_test_clause has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def _split_and_test_clause(self, groups, clause, is_validating_a_user: bool=False, activity: Activity=None, env=None):
      Severity: Minor
      Found in dino/validation/acl.py - About 35 mins to fix

        Avoid too many return statements within this function.
        Open

                    return True, None  # 'no acl set that allows action "%s" for target type "%s"' % (action, target)
        Severity: Major
        Found in dino/validation/acl.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return False, 'rooms are not the same'
          Severity: Major
          Found in dino/validation/acl.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return True, None
            Severity: Major
            Found in dino/validation/acl.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return True, None
              Severity: Major
              Found in dino/validation/acl.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                return True, None
                Severity: Major
                Found in dino/validation/acl.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return False, 'channels are not the same'
                  Severity: Major
                  Found in dino/validation/acl.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return False, 'session value %s not in allowed values [%s]' % (session_value, ','.join(acl_values))
                    Severity: Major
                    Found in dino/validation/acl.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                  return False, 'value too high'
                      Severity: Major
                      Found in dino/validation/acl.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                            return False, 'acl "%s" did not validate for target acl "%s": %s' % (
                        Severity: Major
                        Found in dino/validation/acl.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                          return True, None
                          Severity: Major
                          Found in dino/validation/acl.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                        return True, None
                            Severity: Major
                            Found in dino/validation/acl.py - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                          return True, None
                              Severity: Major
                              Found in dino/validation/acl.py - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                            return True, None
                                Severity: Major
                                Found in dino/validation/acl.py - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                              return True, None
                                  Severity: Major
                                  Found in dino/validation/acl.py - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                                        return False, 'value too low'
                                    Severity: Major
                                    Found in dino/validation/acl.py - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                                  return True, None
                                      Severity: Major
                                      Found in dino/validation/acl.py - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                return True, None
                                        Severity: Major
                                        Found in dino/validation/acl.py - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                      return False, 'rooms are the same (negated ACL)'
                                          Severity: Major
                                          Found in dino/validation/acl.py - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                    return True, None
                                            Severity: Major
                                            Found in dino/validation/acl.py - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                      return False, 'session values [%s] not in allowed values [%s]' % (session_values, ','.join(acl_values))
                                              Severity: Major
                                              Found in dino/validation/acl.py - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                                    return False, 'value too high'
                                                Severity: Major
                                                Found in dino/validation/acl.py - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                              return False, 'value too low'
                                                  Severity: Major
                                                  Found in dino/validation/acl.py - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                            return True, None
                                                    Severity: Major
                                                    Found in dino/validation/acl.py - About 30 mins to fix

                                                      There are no issues that match your filters.

                                                      Category
                                                      Status