atlassian/localstack

View on GitHub

Showing 195 of 195 total issues

Function deploy_resource has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

def deploy_resource(resource_id, resources, stack_name):
    resource = resources[resource_id]
    client = get_client(resource)
    if not client:
        return False
Severity: Minor
Found in localstack/utils/cloudformation/template_deployer.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

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

                if config.get('CloudFunction'):
                    lambda_client = aws_stack.connect_to_service('lambda')
                    try:
                        lambda_client.invoke(FunctionName=config['CloudFunction'], Payload=message)
                    except Exception as e:
Severity: Major
Found in localstack/services/s3/s3_listener.py and 2 other locations - About 4 hrs to fix
localstack/services/s3/s3_listener.py on lines 84..90
localstack/services/s3/s3_listener.py on lines 91..97

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

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 config.get('Queue'):
                    sqs_client = aws_stack.connect_to_service('sqs')
                    try:
                        sqs_client.send_message(QueueUrl=config['Queue'], MessageBody=message)
                    except Exception as e:
Severity: Major
Found in localstack/services/s3/s3_listener.py and 2 other locations - About 4 hrs to fix
localstack/services/s3/s3_listener.py on lines 91..97
localstack/services/s3/s3_listener.py on lines 98..104

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

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 config.get('Topic'):
                    sns_client = aws_stack.connect_to_service('sns')
                    try:
                        sns_client.publish(TopicArn=config['Topic'], Message=message)
                    except Exception as e:
Severity: Major
Found in localstack/services/s3/s3_listener.py and 2 other locations - About 4 hrs to fix
localstack/services/s3/s3_listener.py on lines 84..90
localstack/services/s3/s3_listener.py on lines 98..104

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

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 line in iter(self.process.stderr.readline, ''):
                        if not (line and line.strip()) and self.is_killed():
                            break
                        line = convert_line(line)
                        sys.stderr.write(line)
Severity: Major
Found in localstack/utils/common.py and 1 other location - About 3 hrs to fix
localstack/utils/common.py on lines 107..112

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

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 line in iter(self.process.stdout.readline, ''):
                        if not (line and line.strip()) and self.is_killed():
                            break
                        line = convert_line(line)
                        sys.stdout.write(line)
Severity: Major
Found in localstack/utils/common.py and 1 other location - About 3 hrs to fix
localstack/utils/common.py on lines 113..118

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

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 applyExtras has 91 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    joint.applyExtras = function(graph, paper, params) {
        if(!params) params = {};

        /* returnestrict children to parent's bounding box*/
        graph.on('change:position', function(cell, newPosition, opt) {
Severity: Major
Found in localstack/dashboard/web/js/joint.defs.js - About 3 hrs to fix

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

    def serve(port, quiet=True):
        if quiet:
            log = logging.getLogger('werkzeug')
            log.setLevel(logging.ERROR)
        ssl_context = GenericProxy.get_flask_ssl_context()
    Severity: Major
    Found in localstack/services/awslambda/lambda_api.py and 3 other locations - About 3 hrs to fix
    localstack/services/dynamodbstreams/dynamodbstreams_api.py on lines 109..114
    localstack/services/es/es_api.py on lines 91..96
    localstack/services/firehose/firehose_api.py on lines 168..173

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

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

    def serve(port, quiet=True):
        if quiet:
            log = logging.getLogger('werkzeug')
            log.setLevel(logging.ERROR)
        ssl_context = GenericProxy.get_flask_ssl_context()
    Severity: Major
    Found in localstack/services/es/es_api.py and 3 other locations - About 3 hrs to fix
    localstack/services/awslambda/lambda_api.py on lines 723..728
    localstack/services/dynamodbstreams/dynamodbstreams_api.py on lines 109..114
    localstack/services/firehose/firehose_api.py on lines 168..173

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

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

    def serve(port, quiet=True):
        if quiet:
            log = logging.getLogger('werkzeug')
            log.setLevel(logging.ERROR)
        ssl_context = GenericProxy.get_flask_ssl_context()
    Severity: Major
    Found in localstack/services/firehose/firehose_api.py and 3 other locations - About 3 hrs to fix
    localstack/services/awslambda/lambda_api.py on lines 723..728
    localstack/services/dynamodbstreams/dynamodbstreams_api.py on lines 109..114
    localstack/services/es/es_api.py on lines 91..96

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

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

    def serve(port, quiet=True):
        if quiet:
            log = logging.getLogger('werkzeug')
            log.setLevel(logging.ERROR)
        ssl_context = GenericProxy.get_flask_ssl_context()
    Severity: Major
    Found in localstack/services/dynamodbstreams/dynamodbstreams_api.py and 3 other locations - About 3 hrs to fix
    localstack/services/awslambda/lambda_api.py on lines 723..728
    localstack/services/es/es_api.py on lines 91..96
    localstack/services/firehose/firehose_api.py on lines 168..173

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

    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 find_object has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

    def find_object(expected_object, object_list):
        for obj in object_list:
            if isinstance(obj, list):
                found = find_object(expected_object, obj)
                if found:
    Severity: Minor
    Found in localstack/utils/testutil.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 set_function_code has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

    def set_function_code(code, lambda_name):
    
        def generic_handler(event, context):
            raise Exception(('Unable to find executor for Lambda function "%s". ' +
                'Note that non-Python Lambdas require LAMBDA_EXECUTOR=docker') % lambda_name)
    Severity: Minor
    Found in localstack/services/awslambda/lambda_api.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 start_reading has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        def start_reading(self, params):
            for line in self._tail(params['file']):
                # notify subscribers
                self.notify_subscribers(line)
                if self.log_level > 0:
    Severity: Minor
    Found in localstack/utils/kinesis/kinesis_connector.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 run_cmd has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        def run_cmd(self, params):
    
            def convert_line(line):
                line = to_str(line)
                return line.strip() + '\r\n'
    Severity: Minor
    Found in localstack/utils/common.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 get has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        def get(obj, pool={}, type=None):
            if not obj:
                return None
            if isinstance(obj, Component):
                obj = obj.id
    Severity: Minor
    Found in localstack/utils/aws/aws_models.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 run has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def run(cmd, cache_duration_secs=0, print_error=True, async=False, stdin=False,
            stderr=subprocess.STDOUT, outfile=None, env_vars=None, inherit_cwd=False):
        # don't use subprocess module as it is not thread-safe
        # http://stackoverflow.com/questions/21194380/is-subprocess-popen-not-thread-safe
        # import subprocess
    Severity: Minor
    Found in localstack/utils/common.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

    LocalstackTestRunner has 27 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class LocalstackTestRunner extends BlockJUnit4ClassRunner {
    
        private static final AtomicReference<Process> INFRA_STARTED = new AtomicReference<Process>();
        private static String CONFIG_FILE_CONTENT = "";
    
    

      Function extract_resource_attribute has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

      def extract_resource_attribute(resource_type, resource, attribute):
          LOGGER.debug('Extract resource attribute: %s %s' % (resource_type, attribute))
          # extract resource specific attributes
          if resource_type == 'Lambda::Function':
              actual_attribute = 'FunctionArn' if attribute == 'Arn' else attribute
      Severity: Minor
      Found in localstack/utils/cloudformation/template_deployer.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

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

              for es in re.findall(pattern, code):
                  if es not in identifiers:
                      identifiers.append(es)
                      es = EventSource.get(es, pool=pool, type=ElasticSearch)
                      if es:
      Severity: Major
      Found in localstack/dashboard/infra.py and 1 other location - About 3 hrs to fix
      localstack/dashboard/infra.py on lines 172..177

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

      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

      Severity
      Category
      Status
      Source
      Language