atlassian/localstack

View on GitHub

Showing 195 of 195 total issues

File lambda_api.py has 601 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python
from __future__ import print_function

import os
import re
Severity: Major
Found in localstack/services/awslambda/lambda_api.py - About 1 day to fix

    Function update_sns has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
    Open

    def update_sns(method, path, data, headers, response=None, return_forward_info=False):
        if return_forward_info:
            if method == 'POST' and path == '/':
                req_data = urlparse.parse_qs(data)
                req_action = req_data['Action'][0]
    Severity: Minor
    Found in localstack/services/sns/sns_listener.py - About 1 day 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 retrieve_resource_details has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
    Open

    def retrieve_resource_details(resource_id, resource_status, resources, stack_name):
        resource = resources[resource_id]
        resource_id = resource_status.get('PhysicalResourceId') or resource_id
        resource_type = resource_status['ResourceType']
        if not resource:
    Severity: Minor
    Found in localstack/utils/cloudformation/template_deployer.py - About 7 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

    File common.py has 431 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from __future__ import print_function
    
    import threading
    import traceback
    import os
    Severity: Minor
    Found in localstack/utils/common.py - About 6 hrs to fix

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

      def check_s3(expect_shutdown=False, print_error=False):
          out = None
          try:
              # check S3
              out = aws_stack.connect_to_service(service_name='s3', client=True, env=ENV_DEV).list_buckets()
      Severity: Major
      Found in localstack/services/s3/s3_starter.py and 2 other locations - About 6 hrs to fix
      localstack/services/dynamodb/dynamodb_starter.py on lines 13..24
      localstack/services/kinesis/kinesis_starter.py on lines 28..39

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

      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 check_kinesis(expect_shutdown=False, print_error=False):
          out = None
          try:
              # check Kinesis
              out = aws_stack.connect_to_service(service_name='kinesis', client=True, env=ENV_DEV).list_streams()
      Severity: Major
      Found in localstack/services/kinesis/kinesis_starter.py and 2 other locations - About 6 hrs to fix
      localstack/services/dynamodb/dynamodb_starter.py on lines 13..24
      localstack/services/s3/s3_starter.py on lines 9..20

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

      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 check_dynamodb(expect_shutdown=False, print_error=False):
          out = None
          try:
              # check DynamoDB
              out = aws_stack.connect_to_service(service_name='dynamodb', client=True, env=ENV_DEV).list_tables()
      Severity: Major
      Found in localstack/services/dynamodb/dynamodb_starter.py and 2 other locations - About 6 hrs to fix
      localstack/services/kinesis/kinesis_starter.py on lines 28..39
      localstack/services/s3/s3_starter.py on lines 9..20

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

      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

      File template_deployer.py has 426 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import json
      import yaml
      import logging
      import traceback
      from threading import local
      Severity: Minor
      Found in localstack/utils/cloudformation/template_deployer.py - About 6 hrs to fix

        File infra.py has 400 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import re
        import os
        import json
        import logging
        import base64
        Severity: Minor
        Found in localstack/dashboard/infra.py - About 5 hrs to fix

          Function update_cloudformation has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
          Open

          def update_cloudformation(method, path, data, headers, response=None, return_forward_info=False):
              req_data = None
              if method == 'POST' and path == '/':
                  req_data = urlparse.parse_qs(data)
                  action = req_data.get('Action')[0]
          Severity: Minor
          Found in localstack/services/cloudformation/cloudformation_listener.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 extract_endpoints has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
          Open

          def extract_endpoints(code_map, pool={}):
              result = []
              identifiers = []
              for key, code in iteritems(code_map):
                  # Elasticsearch references
          Severity: Minor
          Found in localstack/dashboard/infra.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 send_notifications has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
          Open

          def send_notifications(method, bucket_name, object_path):
              for bucket, config in iteritems(S3_NOTIFICATIONS):
                  if bucket == bucket_name:
                      action = {'PUT': 'ObjectCreated', 'DELETE': 'ObjectRemoved'}[method]
                      # TODO: support more detailed methods, e.g., DeleteMarkerCreated
          Severity: Minor
          Found in localstack/services/s3/s3_listener.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

          File aws_stack.py has 399 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import os
          import boto3
          import json
          import base64
          import logging
          Severity: Minor
          Found in localstack/utils/aws/aws_stack.py - About 5 hrs to fix

            Function drawGraph has 136 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                var drawGraph = function() {
            
                  if(!graphData) return;
            
                  canvas.html('');
            Severity: Major
            Found in localstack/dashboard/web/views/infra.graph.js - About 5 hrs to fix

              Function get_graph has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_graph(name_filter='.*', env=None):
                  result = {
                      'nodes': [],
                      'edges': []
                  }
              Severity: Minor
              Found in localstack/dashboard/infra.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 update_apigateway has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
              Open

              def update_apigateway(method, path, data, headers, response=None, return_forward_info=False):
                  if return_forward_info:
              
                      regex2 = r'^/restapis/([A-Za-z0-9_\-]+)/([A-Za-z0-9_\-]+)/%s/(.*)$' % PATH_USER_REQUEST
                      if re.match(regex2, path):
              Severity: Minor
              Found in localstack/services/apigateway/apigateway_listener.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 forward has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
              Open

                  def forward(self, method):
                      path = self.path
                      if '://' in path:
                          path = '/' + path.split('://', 1)[1].split('/', 1)[1]
                      proxy_url = 'http://%s%s' % (self.proxy.forward_host, path)
              Severity: Minor
              Found in localstack/services/generic_proxy.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

              Function update_s3 has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
              Open

              def update_s3(method, path, data, headers, response=None, return_forward_info=False):
              
                  if return_forward_info:
              
                      modified_data = None
              Severity: Minor
              Found in localstack/services/s3/s3_listener.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

              Function update_dynamodb has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
              Open

              def update_dynamodb(method, path, data, headers, response=None, return_forward_info=False):
                  if return_forward_info:
                      if random.random() < config.DYNAMODB_ERROR_PROBABILITY:
                          return dynamodb_error_response(data)
                      return True
              Severity: Minor
              Found in localstack/services/dynamodb/dynamodb_listener.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

              File kinesis_connector.py has 351 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              #!/usr/bin/env python
              
              import os
              import sys
              import re
              Severity: Minor
              Found in localstack/utils/kinesis/kinesis_connector.py - About 4 hrs to fix
                Severity
                Category
                Status
                Source
                Language