saltstack/salt

View on GitHub
salt/modules/keystone.py

Summary

Maintainability
F
1 wk
Test Coverage

File keystone.py has 1059 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Module for handling openstack keystone calls.

:optdepends:    - keystoneclient Python adapter
Severity: Major
Found in salt/modules/keystone.py - About 2 days to fix

    Function user_update has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

    def user_update(user_id=None, name=None, email=None, enabled=None,
                    tenant=None, profile=None, project=None, description=None, **connection_args):
        '''
        Update a user's information (keystone user-update)
        The following fields may be updated: name, email, enabled, tenant.
    Severity: Minor
    Found in salt/modules/keystone.py - About 5 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 user_role_list has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def user_role_list(user_id=None, tenant_id=None, user_name=None,
                       tenant_name=None, profile=None, project_id=None, project_name=None, **connection_args):
        '''
        Return a list of available user_roles (keystone user-roles-list)
    
    
    Severity: Minor
    Found in salt/modules/keystone.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 user_verify_password has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def user_verify_password(user_id=None, name=None, password=None,
                             profile=None, **connection_args):
        '''
        Verify a user's password
    
    
    Severity: Minor
    Found in salt/modules/keystone.py - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function user_role_add has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def user_role_add(user_id=None, user=None, tenant_id=None,
                      tenant=None, role_id=None, role=None, profile=None,
                      project_id=None, project_name=None, **connection_args):
        '''
        Add role for user in tenant (keystone user-role-add)
    Severity: Minor
    Found in salt/modules/keystone.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 user_role_remove has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def user_role_remove(user_id=None, user=None, tenant_id=None,
                         tenant=None, role_id=None, role=None,
                         profile=None, project_id=None, project_name=None, **connection_args):
        '''
        Remove role for user in tenant (keystone user-role-remove)
    Severity: Minor
    Found in salt/modules/keystone.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 user_password_update has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def user_password_update(user_id=None, name=None, password=None,
                             profile=None, **connection_args):
        '''
        Update a user's password (keystone user-password-update)
    
    
    Severity: Minor
    Found in salt/modules/keystone.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 endpoint_get has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def endpoint_get(service, region=None, profile=None, interface=None, **connection_args):
        '''
        Return a specific endpoint (keystone endpoint-get)
    
        CLI Example:
    Severity: Minor
    Found in salt/modules/keystone.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 tenant_update has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def tenant_update(tenant_id=None, name=None, description=None,
                      enabled=None, profile=None, **connection_args):
        '''
        Update a tenant's information (keystone tenant-update)
        The following fields may be updated: name, description, enabled.
    Severity: Minor
    Found in salt/modules/keystone.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 user_get has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def user_get(user_id=None, name=None, profile=None, **connection_args):
        '''
        Return a specific users (keystone user-get)
    
        CLI Examples:
    Severity: Minor
    Found in salt/modules/keystone.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

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

    def user_delete(user_id=None, name=None, profile=None, **connection_args):
        '''
        Delete a user (keystone user-delete)
    
        CLI Examples:
    Severity: Minor
    Found in salt/modules/keystone.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 tenant_delete has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def tenant_delete(tenant_id=None, name=None, profile=None, **connection_args):
        '''
        Delete a tenant (keystone tenant-delete)
    
        CLI Examples:
    Severity: Minor
    Found in salt/modules/keystone.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 role_delete has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def role_delete(role_id=None, name=None, profile=None,
                    **connection_args):
        '''
        Delete a role (keystone role-delete)
    
    
    Severity: Minor
    Found in salt/modules/keystone.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 ec2_credentials_get has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def ec2_credentials_get(user_id=None, name=None, access=None,
                            profile=None, **connection_args):
        '''
        Return ec2_credentials for a user (keystone ec2-credentials-get)
    
    
    Severity: Minor
    Found in salt/modules/keystone.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 ec2_credentials_list has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def ec2_credentials_list(user_id=None, name=None, profile=None,
                             **connection_args):
        '''
        Return a list of ec2_credentials for a specific user (keystone ec2-credentials-list)
    
    
    Severity: Minor
    Found in salt/modules/keystone.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 role_get has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def role_get(role_id=None, name=None, profile=None, **connection_args):
        '''
        Return a specific roles (keystone role-get)
    
        CLI Examples:
    Severity: Minor
    Found in salt/modules/keystone.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 service_get has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def service_get(service_id=None, name=None, profile=None, **connection_args):
        '''
        Return a specific services (keystone service-get)
    
        CLI Examples:
    Severity: Minor
    Found in salt/modules/keystone.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 tenant_get has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def tenant_get(tenant_id=None, name=None, profile=None,
                   **connection_args):
        '''
        Return a specific tenants (keystone tenant-get)
    
    
    Severity: Minor
    Found in salt/modules/keystone.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 _get_kwargs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def _get_kwargs(profile=None, **connection_args):
        '''
        get connection args
        '''
        if profile:
    Severity: Minor
    Found in salt/modules/keystone.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

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

    def endpoint_list(profile=None, **connection_args):
        '''
        Return a list of available endpoints (keystone endpoints-list)
    
        CLI Example:
    Severity: Major
    Found in salt/modules/keystone.py and 2 other locations - About 6 hrs to fix
    salt/modules/keystone.py on lines 506..522
    salt/modules/keystone.py on lines 589..605

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

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

    def service_list(profile=None, **connection_args):
        '''
        Return a list of available services (keystone services-list)
    
        CLI Example:
    Severity: Major
    Found in salt/modules/keystone.py and 2 other locations - About 6 hrs to fix
    salt/modules/keystone.py on lines 352..369
    salt/modules/keystone.py on lines 506..522

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

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

    def role_list(profile=None, **connection_args):
        '''
        Return a list of available roles (keystone role-list)
    
        CLI Example:
    Severity: Major
    Found in salt/modules/keystone.py and 2 other locations - About 6 hrs to fix
    salt/modules/keystone.py on lines 352..369
    salt/modules/keystone.py on lines 589..605

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

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

            ret[user.name] = dict((value, getattr(user, value, None)) for value in dir(user)
                                  if not value.startswith('_') and
                                  isinstance(getattr(user, value, None), (six.string_types, dict, bool)))
    Severity: Major
    Found in salt/modules/keystone.py and 1 other location - About 3 hrs to fix
    salt/modules/keystone.py on lines 978..980

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

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

        ret[user.name] = dict((value, getattr(user, value, None)) for value in dir(user)
                              if not value.startswith('_') and
                              isinstance(getattr(user, value, None), (six.string_types, dict, bool)))
    Severity: Major
    Found in salt/modules/keystone.py and 1 other location - About 3 hrs to fix
    salt/modules/keystone.py on lines 941..943

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

    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

        if tenant:
            tenant_id = tenant_get(name=tenant, profile=profile,
                                   **connection_args)[tenant].get('id')
        else:
            tenant = next(six.iterkeys(tenant_get(tenant_id, profile=profile,
    Severity: Major
    Found in salt/modules/keystone.py and 3 other locations - About 2 hrs to fix
    salt/modules/keystone.py on lines 1215..1219
    salt/modules/keystone.py on lines 1224..1228
    salt/modules/keystone.py on lines 1273..1277

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

    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

        if tenant:
            tenant_id = tenant_get(name=tenant, profile=profile,
                                   **connection_args)[tenant].get('id')
        else:
            tenant = next(six.iterkeys(tenant_get(tenant_id, profile=profile,
    Severity: Major
    Found in salt/modules/keystone.py and 3 other locations - About 2 hrs to fix
    salt/modules/keystone.py on lines 1215..1219
    salt/modules/keystone.py on lines 1273..1277
    salt/modules/keystone.py on lines 1282..1286

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

    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

        if user:
            user_id = user_get(name=user, profile=profile,
                               **connection_args)[user].get('id')
        else:
            user = next(six.iterkeys(user_get(user_id, profile=profile,
    Severity: Major
    Found in salt/modules/keystone.py and 3 other locations - About 2 hrs to fix
    salt/modules/keystone.py on lines 1224..1228
    salt/modules/keystone.py on lines 1273..1277
    salt/modules/keystone.py on lines 1282..1286

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

    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

        if user:
            user_id = user_get(name=user, profile=profile,
                               **connection_args)[user].get('id')
        else:
            user = next(six.iterkeys(user_get(user_id, profile=profile,
    Severity: Major
    Found in salt/modules/keystone.py and 3 other locations - About 2 hrs to fix
    salt/modules/keystone.py on lines 1215..1219
    salt/modules/keystone.py on lines 1224..1228
    salt/modules/keystone.py on lines 1282..1286

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

    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 project_get(project_id=None, name=None, profile=None, **connection_args):
        '''
        Return a specific projects (keystone project-get)
        Overrides keystone tenant-get form api V2.
        For keystone api V3 only.
    Severity: Major
    Found in salt/modules/keystone.py and 1 other location - About 1 hr to fix
    salt/modules/keystone.py on lines 689..718

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 55.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

    def project_delete(project_id=None, name=None, profile=None, **connection_args):
        '''
        Delete a project (keystone project-delete).
        Overrides keystone tenant-delete form api V2. For keystone api V3 only.
    
    
    Severity: Major
    Found in salt/modules/keystone.py and 1 other location - About 1 hr to fix
    salt/modules/keystone.py on lines 751..781

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 55.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

        def get(key, default=None):
            '''
            look in connection_args first, then default to config file
            '''
            return connection_args.get('connection_' + key,
    Severity: Major
    Found in salt/modules/keystone.py and 2 other locations - About 55 mins to fix
    salt/modules/glance.py on lines 119..125
    salt/modules/heat.py on lines 116..122

    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 _OS_IDENTITY_API_VERSION > 2:
            kstone.roles.revoke(role_id, user=user_id, project=tenant_id)
        else:
            kstone.roles.remove_user_role(user_id, role_id, tenant_id)
    Severity: Minor
    Found in salt/modules/keystone.py and 1 other location - About 40 mins to fix
    salt/modules/keystone.py on lines 1242..1245

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

    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 _OS_IDENTITY_API_VERSION > 2:
            kstone.roles.grant(role_id, user=user_id, project=tenant_id)
        else:
            kstone.roles.add_user_role(user_id, role_id, tenant_id)
    Severity: Minor
    Found in salt/modules/keystone.py and 1 other location - About 40 mins to fix
    salt/modules/keystone.py on lines 1299..1302

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

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

        if name:
            for tenant in getattr(kstone, _TENANTS, None).list():
                if tenant.name == name:
                    tenant_id = tenant.id
                    break
    Severity: Minor
    Found in salt/modules/keystone.py and 2 other locations - About 30 mins to fix
    salt/modules/keystone.py on lines 674..678
    salt/modules/keystone.py on lines 1334..1338

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

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

        if name:
            for tenant in getattr(kstone, _TENANTS, None).list():
                if tenant.name == name:
                    tenant_id = tenant.id
                    break
    Severity: Minor
    Found in salt/modules/keystone.py and 2 other locations - About 30 mins to fix
    salt/modules/keystone.py on lines 737..741
    salt/modules/keystone.py on lines 1334..1338

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

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

        if tenant_name:
            for tenant in getattr(kstone, _TENANTS, None).list():
                if tenant.name == tenant_name:
                    tenant_id = tenant.id
                    break
    Severity: Minor
    Found in salt/modules/keystone.py and 2 other locations - About 30 mins to fix
    salt/modules/keystone.py on lines 674..678
    salt/modules/keystone.py on lines 737..741

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

    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