atlassian/localstack

View on GitHub

Showing 195 of 195 total issues

Function listen_to_kinesis has 13 arguments (exceeds 4 allowed). Consider refactoring.
Open

def listen_to_kinesis(stream_name, listener_func=None, processor_script=None,
Severity: Major
Found in localstack/utils/kinesis/kinesis_connector.py - About 1 hr to fix

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

            for i in range(0, 6):
                if ord(data_new[-1]) in (10, 13):
                    data_new = data_new[:-1]
    Severity: Major
    Found in localstack/services/s3/s3_listener.py and 1 other location - About 1 hr to fix
    localstack/services/s3/s3_listener.py on lines 176..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 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

            for i in range(0, 2):
                if ord(data_new[0]) in (10, 13):
                    data_new = data_new[1:]
    Severity: Major
    Found in localstack/services/s3/s3_listener.py and 1 other location - About 1 hr to fix
    localstack/services/s3/s3_listener.py on lines 179..181

    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

    Method main has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        @SuppressWarnings("unchecked")
        public static void main(String[] args) throws Exception {
            if(args.length < 2) {
                System.err.println("Usage: java " + LambdaExecutor.class.getSimpleName() +
                        "<lambdaClass> <recordsFilePath>");

      Function load_plugins has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def load_plugins():
          loaded_files = []
          for module in pkgutil.iter_modules():
              if six.PY3 and not isinstance(module, tuple):
                  file_path = '%s/%s/plugins.py' % (module.module_finder.path, module.name)
      Severity: Minor
      Found in localstack/services/infra.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 post_request has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def post_request():
          action = request.headers.get('x-amz-target')
          data = json.loads(to_str(request.data))
          result = None
          kinesis = aws_stack.connect_to_service('kinesis')
      Severity: Minor
      Found in localstack/services/dynamodbstreams/dynamodbstreams_api.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 start_infra has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def start_infra(async=False, apis=None):
          try:
              # load plugins
              load_plugins()
      
      
      Severity: Minor
      Found in localstack/services/infra.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 append_cors_headers has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def append_cors_headers(bucket_name, request_method, request_headers, response):
          cors = BUCKET_CORS.get(bucket_name)
          if not cors:
              return
          origin = request_headers.get('Origin', '')
      Severity: Minor
      Found in localstack/services/s3/s3_listener.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

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

                    $("#" + v).css("top", marginTop + (g.node(v).y - ($("#" + v).height() / 2)) + "px");
      Severity: Major
      Found in localstack/dashboard/web/views/infra.graph.js and 1 other location - About 1 hr to fix
      localstack/dashboard/web/views/infra.graph.js on lines 114..114

      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

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

                    $("#" + v).css("left", marginLeft + (g.node(v).x - ($("#" + v).width() / 2)) + "px");
      Severity: Major
      Found in localstack/dashboard/web/views/infra.graph.js and 1 other location - About 1 hr to fix
      localstack/dashboard/web/views/infra.graph.js on lines 115..115

      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

      Method main has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static void main(String[] args) throws Exception {
      
              Properties props = loadProps(args[0]);
      
              if(props.containsKey("disableCertChecking")) {
      Severity: Minor
      Found in localstack/utils/kinesis/java/com/atlassian/KinesisStarter.java - About 1 hr to fix

        Function handle_connection has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def handle_connection(self, conn):
                socket_file = conn.makefile()
                while self.running:
                    line = socket_file.readline()
                    line = line[:-1]
        Severity: Minor
        Found in localstack/utils/kinesis/kinesis_util.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 connect_elasticsearch has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def connect_elasticsearch(endpoint=None, domain=None, region_name=None, env=None):
            from elasticsearch import Elasticsearch, RequestsHttpConnection
            from requests_aws4auth import AWS4Auth
        
            env = get_environment(env, region_name=region_name)
        Severity: Minor
        Found in localstack/utils/aws/aws_stack.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 strip_chunk_signatures has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def strip_chunk_signatures(data):
            # For clients that use streaming v4 authentication, the request contains chunk signatures
            # in the HTTP body (see example below) which we need to strip as moto cannot handle them
            #
            # 17;chunk-signature=6e162122ec4962bea0b18bc624025e6ae4e9322bdc632762d909e87793ac5921
        Severity: Minor
        Found in localstack/services/s3/s3_listener.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 process_records has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def process_records(self, records, checkpointer):
                if self.processor_func:
                    self.processor_func(records=records,
                        checkpointer=checkpointer, shard_id=self.shard_id)
                    for record in records:
        Severity: Minor
        Found in localstack/utils/kinesis/kinesis_connector.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 start_kcl_client_process has 10 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def start_kcl_client_process(stream_name, listener_script, log_file=None, env=None, configs={},
        Severity: Major
        Found in localstack/utils/kinesis/kinesis_connector.py - About 1 hr to fix

          Function check_infra has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          def check_infra(retries=8, expect_shutdown=False, apis=None, additional_checks=[]):
              try:
                  print_error = retries <= 0
          
                  # loop through plugins and check service status
          Severity: Minor
          Found in localstack/services/infra.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 run has 9 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def run(cmd, cache_duration_secs=0, print_error=True, async=False, stdin=False,
          Severity: Major
          Found in localstack/utils/common.py - About 1 hr to fix

            Function get_resource_dependencies has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            def get_resource_dependencies(resource_id, resource, resources):
                result = {}
                dumped = json.dumps(common.json_safe(resource))
                for other_id, other in iteritems(resources):
                    if resource != other:
            Severity: Minor
            Found in localstack/utils/cloudformation/template_deployer.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 deploy_template has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            def deploy_template(template, stack_name):
                if isinstance(template, string_types):
                    template = parse_template(template)
            
                if MARKER_DONT_REDEPLOY_STACK in template:
            Severity: Minor
            Found in localstack/utils/cloudformation/template_deployer.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

            Severity
            Category
            Status
            Source
            Language