atlassian/localstack

View on GitHub

Showing 195 of 195 total issues

Avoid too many return statements within this function.
Open

                        return error_response('Stack with id %s does not exist' % stack_name, code=404)
Severity: Major
Found in localstack/services/cloudformation/cloudformation_listener.py - About 30 mins to fix

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

                result = list(filter(lambda api: api['name'] == resource_id, apis))
    Severity: Minor
    Found in localstack/utils/cloudformation/template_deployer.py and 1 other location - About 30 mins to fix
    localstack/utils/cloudformation/template_deployer.py on lines 246..246

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 32.

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

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

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

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

    Refactorings

    Further Reading

    Function map_all_s3_objects has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def map_all_s3_objects(to_json=True):
        s3_client = get_s3_client()
        result = {}
        for bucket in s3_client.buckets.all():
            for key in bucket.objects.all():
    Severity: Minor
    Found in localstack/utils/testutil.py - About 25 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function resources_to_deploy_next has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def resources_to_deploy_next(resources, stack_name):
        result = {}
        for resource_id, resource in iteritems(resources):
            if is_deployable_resource(resource) and not is_deployed(resource_id, resources, stack_name):
                res_deps = get_resource_dependencies(resource_id, resource, resources)
    Severity: Minor
    Found in localstack/utils/cloudformation/template_deployer.py - About 25 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function invoke_function has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def invoke_function(function):
        """ Invoke an existing function
            ---
            operationId: 'invokeFunction'
            parameters:
    Severity: Minor
    Found in localstack/services/awslambda/lambda_api.py - About 25 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function use_docker has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def use_docker():
        global DO_USE_DOCKER
        if DO_USE_DOCKER is None:
            DO_USE_DOCKER = False
            if config.LAMBDA_EXECUTOR == 'docker':
    Severity: Minor
    Found in localstack/services/awslambda/lambda_api.py - About 25 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function parse_request has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_request(self):
            result = BaseHTTPRequestHandler.parse_request(self)
            if not result:
                return result
            if sys.version_info[0] >= 3:
    Severity: Minor
    Found in localstack/services/generic_proxy.py - About 25 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function update_destination has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def update_destination(stream_name, destination_id,
            s3_update=None, elasticsearch_update=None, version_id=None):
        dest = get_destination(stream_name, destination_id)
        if elasticsearch_update:
            print('WARN: Firehose to Elasticsearch updates not yet implemented!')
    Severity: Minor
    Found in localstack/services/firehose/firehose_api.py - About 25 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function aws_cmd has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def aws_cmd(service, env):
        # TODO: use boto3 instead of running aws-cli commands here!
    
        cmd = '{ test `which aws` || . .venv/bin/activate; }; aws'
        endpoint_url = None
    Severity: Minor
    Found in localstack/dashboard/infra.py - About 25 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function get_subscription_by_arn has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_subscription_by_arn(sub_arn):
        # TODO maintain separate map instead of traversing all items
        for key, subscriptions in SNS_SUBSCRIPTIONS.items():
            for sub in subscriptions:
                if sub['SubscriptionArn'] == sub_arn:
    Severity: Minor
    Found in localstack/services/sns/sns_listener.py - About 25 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function cleanup_tmp_files has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def cleanup_tmp_files():
        for tmp in TMP_FILES:
            try:
                if os.path.isdir(tmp):
                    run('rm -rf "%s"' % tmp)
    Severity: Minor
    Found in localstack/utils/common.py - About 25 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function get_logger_for_level_in_log_line has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_logger_for_level_in_log_line(self, line):
            level = self.log_level
            for l in LOG_LEVELS:
                if l >= level:
                    level_name = logging.getLevelName(l)
    Severity: Minor
    Found in localstack/utils/kinesis/kinesis_connector.py - About 25 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function do_run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def do_run(cmd, async, print_output=False):
        sys.stdout.flush()
        if async:
            if is_debug():
                print_output = True
    Severity: Minor
    Found in localstack/services/infra.py - About 25 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function all_dependencies_satisfied has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def all_dependencies_satisfied(resources, stack_name, all_resources, depending_resource=None):
        for resource_id, resource in iteritems(resources):
            if is_deployable_resource(resource):
                if not is_deployed(resource_id, all_resources, stack_name):
                    return False
    Severity: Minor
    Found in localstack/utils/cloudformation/template_deployer.py - About 25 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function get_event_sources has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_event_sources(func_name=None, source_arn=None):
        result = []
        for m in event_source_mappings:
            if not func_name or m['FunctionArn'] in [func_name, func_arn(func_name)]:
                if not source_arn or m['EventSourceArn'].startswith(source_arn):
    Severity: Minor
    Found in localstack/services/awslambda/lambda_api.py - About 25 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

    Severity
    Category
    Status
    Source
    Language