saltstack/salt

View on GitHub
salt/modules/boto_cognitoidentity.py

Summary

Maintainability
F
3 days
Test Coverage

File boto_cognitoidentity.py has 294 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Connection module for Amazon CognitoIdentity

.. versionadded:: 2016.11.0
Severity: Minor
Found in salt/modules/boto_cognitoidentity.py - About 3 hrs to fix

    Function update_identity_pool has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def update_identity_pool(IdentityPoolId,
                             IdentityPoolName=None,
                             AllowUnauthenticatedIdentities=False,
                             SupportedLoginProviders=None,
                             DeveloperProviderName=None,
    Severity: Minor
    Found in salt/modules/boto_cognitoidentity.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 _find_identity_pool_ids has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def _find_identity_pool_ids(name, pool_id, conn):
        '''
        Given identity pool name (or optionally a pool_id and name will be ignored),
        find and return list of matching identity pool id's.
        '''
    Severity: Minor
    Found in salt/modules/boto_cognitoidentity.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 set_identity_pool_roles has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def set_identity_pool_roles(IdentityPoolId, AuthenticatedRole=None, UnauthenticatedRole=None,
            region=None, key=None, keyid=None, profile=None):
        '''
        Given an identity pool id, set the given AuthenticatedRole and UnauthenticatedRole (the Role
        can be an iam arn, or a role name)  If AuthenticatedRole or UnauthenticatedRole is not given,
    Severity: Minor
    Found in salt/modules/boto_cognitoidentity.py - About 55 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 2 locations. Consider refactoring.
    Open

    def describe_identity_pools(IdentityPoolName, IdentityPoolId=None,
                   region=None, key=None, keyid=None, profile=None):
    
        '''
        Given an identity pool name, (optionally if an identity pool id is given,
    Severity: Major
    Found in salt/modules/boto_cognitoidentity.py and 1 other location - About 1 day to fix
    salt/modules/boto_cognitoidentity.py on lines 255..286

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

    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 get_identity_pool_roles(IdentityPoolName, IdentityPoolId=None,
                    region=None, key=None, keyid=None, profile=None):
        '''
        Given an identity pool name, (optionally if an identity pool id if given,
        the given name will be ignored)
    Severity: Major
    Found in salt/modules/boto_cognitoidentity.py and 1 other location - About 1 day to fix
    salt/modules/boto_cognitoidentity.py on lines 144..176

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

    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

    Identical blocks of code found in 3 locations. Consider refactoring.
    Open

    try:
        # pylint: disable=unused-import
        import boto
        import boto3
        # pylint: enable=unused-import
    Severity: Major
    Found in salt/modules/boto_cognitoidentity.py and 2 other locations - About 2 hrs to fix
    salt/modules/boto_elasticsearch_domain.py on lines 93..103
    salt/modules/boto_rds.py on lines 66..76

    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

            if UnauthenticatedRole:
                role_arn = _get_role_arn(UnauthenticatedRole, **conn_params)
                if role_arn is None:
                    return {'set': False, 'error': 'invalid UnauthenticatedRole {0}'.format(UnauthenticatedRole)}
                UnauthenticatedRole = role_arn
    Severity: Minor
    Found in salt/modules/boto_cognitoidentity.py and 1 other location - About 55 mins to fix
    salt/modules/boto_cognitoidentity.py on lines 329..333

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

    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 AuthenticatedRole:
                role_arn = _get_role_arn(AuthenticatedRole, **conn_params)
                if role_arn is None:
                    return {'set': False, 'error': 'invalid AuthenticatedRole {0}'.format(AuthenticatedRole)}
                AuthenticatedRole = role_arn
    Severity: Minor
    Found in salt/modules/boto_cognitoidentity.py and 1 other location - About 55 mins to fix
    salt/modules/boto_cognitoidentity.py on lines 335..339

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

    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

            for pools in __utils__['boto3.paged_call'](conn.list_identity_pools,
                             marker_flag='NextToken', marker_arg='NextToken', MaxResults=25):
                for pool in pools['IdentityPools']:
                    if pool['IdentityPoolName'] == name:
                        ids.append(pool['IdentityPoolId'])
    Severity: Minor
    Found in salt/modules/boto_cognitoidentity.py and 1 other location - About 45 mins to fix
    salt/states/mongodb_user.py on lines 113..116

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

    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

    There are no issues that match your filters.

    Category
    Status