atlassian/localstack

View on GitHub

Showing 195 of 195 total issues

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

        name = req_data.get('MessageAttributes.entry.' + str(x) + ".Name", [None])[0]
Severity: Major
Found in localstack/services/sns/sns_listener.py and 2 other locations - About 50 mins to fix
localstack/services/sns/sns_listener.py on lines 171..171
localstack/services/sns/sns_listener.py on lines 172..172

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

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

            binary_value = req_data.get('MessageAttributes.entry.' + str(x) + ".Value.BinaryValue", [None])[0]
Severity: Major
Found in localstack/services/sns/sns_listener.py and 2 other locations - About 50 mins to fix
localstack/services/sns/sns_listener.py on lines 167..167
localstack/services/sns/sns_listener.py on lines 171..171

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

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 text_(s, encoding='utf-8', errors='strict'):
    """If ``s`` is an instance of ``binary_type``, return
    ``s.decode(encoding, errors)``, otherwise return ``s``
    """
    return s.decode(encoding, errors) if isinstance(s, binary_type) else s
Severity: Minor
Found in localstack/utils/compat.py and 1 other location - About 45 mins to fix
localstack/utils/compat.py on lines 14..18

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

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

def get_file_path(api, create=False):
    if api not in API_FILE_PATHS:
        API_FILE_PATHS[api] = False
        if not DATA_DIR:
            return False
Severity: Minor
Found in localstack/utils/persistence.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

Avoid deeply nested control flow statements.
Open

                        for buffered_line in self.buffer:
                            logger_func(buffered_line)
                    self.buffer = []
Severity: Major
Found in localstack/utils/kinesis/kinesis_connector.py - About 45 mins to fix

    Function create_lambda_function has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def create_lambda_function(func_name, zip_file, event_source_arn=None, handler=LAMBDA_DEFAULT_HANDLER,
    Severity: Minor
    Found in localstack/utils/testutil.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if not find_recursive(k, v, obj):
                              all_ok = False
                              break
              if all_ok:
      Severity: Major
      Found in localstack/utils/testutil.py - About 45 mins to fix

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

        def merge_recursive(source, destination):
            for key, value in source.items():
                if isinstance(value, dict):
                    # get node or create one
                    node = destination.setdefault(key, {})
        Severity: Minor
        Found in localstack/utils/common.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 start_proxy has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def start_proxy(port, backend_port, update_listener, quiet=False,
        Severity: Minor
        Found in localstack/services/infra.py - About 45 mins to fix

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

          if __name__ == '__main__':
              port = DEFAULT_PORT_FIREHOSE
              print("Starting server on port %s" % port)
              serve(port)
          Severity: Minor
          Found in localstack/services/firehose/firehose_api.py and 1 other location - About 45 mins to fix
          localstack/services/awslambda/lambda_api.py on lines 731..734

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

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

          def update_event_source(uuid_value, function_name, enabled, batch_size):
              for m in event_source_mappings:
                  if uuid_value == m['UUID']:
                      if function_name:
                          m['FunctionArn'] = func_arn(function_name)
          Severity: Minor
          Found in localstack/services/awslambda/lambda_api.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(self, port, forward_host=None, ssl=False, update_listener=None, quiet=False, params={}):
          Severity: Minor
          Found in localstack/services/generic_proxy.py - About 45 mins to fix

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

            def bytes_(s, encoding='utf-8', errors='strict'):
                """ If ``s`` is an instance of ``text_type``, return
                ``s.encode(encoding, errors)``, otherwise return ``s``
                """
                return s.encode(encoding, errors) if isinstance(s, text_type) else s
            Severity: Minor
            Found in localstack/utils/compat.py and 1 other location - About 45 mins to fix
            localstack/utils/compat.py on lines 7..11

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

            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 __name__ == '__main__':
                port = DEFAULT_PORT_LAMBDA
                print("Starting server on port %s" % port)
                serve(port)
            Severity: Minor
            Found in localstack/services/awslambda/lambda_api.py and 1 other location - About 45 mins to fix
            localstack/services/firehose/firehose_api.py on lines 175..178

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

            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 start_moto_server has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def start_moto_server(key, port, name=None, backend_port=None, async=False, update_listener=None):
            Severity: Minor
            Found in localstack/services/infra.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if re.match(self.filter_regex, line):
                                          logger_func = self.get_logger_for_level_in_log_line(line)
                                          break
                                  if logger_func:
              Severity: Major
              Found in localstack/utils/kinesis/kinesis_connector.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if subscriber['Protocol'] == 'sqs':
                                        queue_name = subscriber['Endpoint'].split(':')[5]
                                        queue_url = subscriber.get('sqs_queue_url')
                                        if not queue_url:
                                            queue_url = aws_stack.get_sqs_queue_url(queue_name)
                Severity: Major
                Found in localstack/services/sns/sns_listener.py - About 45 mins to fix

                  Function update_s3 has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def update_s3(method, path, data, headers, response=None, return_forward_info=False):
                  Severity: Minor
                  Found in localstack/services/s3/s3_listener.py - About 45 mins to fix

                    Function update_dynamodb has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    def update_dynamodb(method, path, data, headers, response=None, return_forward_info=False):
                    Severity: Minor
                    Found in localstack/services/dynamodb/dynamodb_listener.py - About 45 mins to fix

                      Function update_cloudformation has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      def update_cloudformation(method, path, data, headers, response=None, return_forward_info=False):
                      Severity: Minor
                      Found in localstack/services/cloudformation/cloudformation_listener.py - About 45 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language