localstack/localstack

View on GitHub
localstack-core/localstack/services/s3/provider.py

Summary

Maintainability
F
1 wk
Test Coverage

File provider.py has 1656 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import copy
import datetime
import logging
import os
from collections import defaultdict
Severity: Major
Found in localstack-core/localstack/services/s3/provider.py - About 4 days to fix

    S3Provider has 67 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class S3Provider(S3Api, ServiceLifecycleHook):
        @staticmethod
        def get_store(account_id: Optional[str] = None, region: Optional[str] = None) -> S3Store:
            return s3_stores[account_id or DEFAULT_AWS_ACCOUNT_ID][region or AWS_REGION_US_EAST_1]
    
    
    Severity: Major
    Found in localstack-core/localstack/services/s3/provider.py - About 1 day to fix

      Function apply_moto_patches has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
      Open

      def apply_moto_patches():
          # importing here in case we need InvalidObjectState from `localstack.aws.api.s3`
          import moto.s3.models as moto_s3_models
          import moto.s3.responses as moto_s3_responses
          from moto.iam.access_control import PermissionResult
      Severity: Minor
      Found in localstack-core/localstack/services/s3/provider.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 put_object has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def put_object(
              self,
              context: RequestContext,
              request: PutObjectRequest,
          ) -> PutObjectOutput:
      Severity: Minor
      Found in localstack-core/localstack/services/s3/provider.py - About 2 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_object has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_object(self, context: RequestContext, request: GetObjectRequest) -> GetObjectOutput:
              key = request["Key"]
              bucket = request["Bucket"]
              version_id = request.get("VersionId")
              moto_backend = get_moto_s3_backend(context)
      Severity: Minor
      Found in localstack-core/localstack/services/s3/provider.py - About 2 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 put_bucket_acl has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def put_bucket_acl(
              self,
              context: RequestContext,
              request: PutBucketAclRequest,
          ) -> None:
      Severity: Minor
      Found in localstack-core/localstack/services/s3/provider.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 copy_object has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def copy_object(
              self,
              context: RequestContext,
              request: CopyObjectRequest,
          ) -> CopyObjectOutput:
      Severity: Minor
      Found in localstack-core/localstack/services/s3/provider.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 select_object_content has 14 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def select_object_content(
      Severity: Major
      Found in localstack-core/localstack/services/s3/provider.py - About 1 hr to fix

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

            def upload_part(self, context: RequestContext, request: UploadPartRequest) -> UploadPartOutput:
                bucket_name = request["Bucket"]
                moto_backend = get_moto_s3_backend(context)
                moto_bucket = get_bucket_from_moto(moto_backend, bucket=bucket_name)
                upload_id = request.get("UploadId")
        Severity: Minor
        Found in localstack-core/localstack/services/s3/provider.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 head_object has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def head_object(
                self,
                context: RequestContext,
                request: HeadObjectRequest,
            ) -> HeadObjectOutput:
        Severity: Minor
        Found in localstack-core/localstack/services/s3/provider.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 put_object_retention has 11 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def put_object_retention(
        Severity: Major
        Found in localstack-core/localstack/services/s3/provider.py - About 1 hr to fix

          Function delete_objects has 9 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def delete_objects(
          Severity: Major
          Found in localstack-core/localstack/services/s3/provider.py - About 1 hr to fix

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

                def post_object(
                    self, context: RequestContext, bucket: BucketName, body: IO[Body] = None, **kwargs
                ) -> PostResponse:
                    # see https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPOST.html
                    # TODO: signature validation is not implemented for pre-signed POST
            Severity: Minor
            Found in localstack-core/localstack/services/s3/provider.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 put_bucket_replication has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def put_bucket_replication(
                    self,
                    context: RequestContext,
                    bucket: BucketName,
                    replication_configuration: ReplicationConfiguration,
            Severity: Minor
            Found in localstack-core/localstack/services/s3/provider.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 put_bucket_replication has 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def put_bucket_replication(
            Severity: Major
            Found in localstack-core/localstack/services/s3/provider.py - About 1 hr to fix

              Function put_bucket_cors has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def put_bucket_cors(
              Severity: Major
              Found in localstack-core/localstack/services/s3/provider.py - About 50 mins to fix

                Function put_bucket_website has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def put_bucket_website(
                Severity: Major
                Found in localstack-core/localstack/services/s3/provider.py - About 50 mins to fix

                  Function get_object_acl has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def get_object_acl(
                  Severity: Major
                  Found in localstack-core/localstack/services/s3/provider.py - About 50 mins to fix

                    Function put_bucket_logging has 7 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def put_bucket_logging(
                    Severity: Major
                    Found in localstack-core/localstack/services/s3/provider.py - About 50 mins to fix

                      Function get_object_retention has 7 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def get_object_retention(
                      Severity: Major
                      Found in localstack-core/localstack/services/s3/provider.py - About 50 mins to fix

                        Function _fix_key_response_post has 7 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def _fix_key_response_post(fn, self, request, body, bucket_name, *args, **kwargs):
                        Severity: Major
                        Found in localstack-core/localstack/services/s3/provider.py - About 50 mins to fix

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

                              def put_bucket_inventory_configuration(
                          Severity: Minor
                          Found in localstack-core/localstack/services/s3/provider.py - About 45 mins to fix

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

                                def put_bucket_analytics_configuration(
                            Severity: Minor
                            Found in localstack-core/localstack/services/s3/provider.py - About 45 mins to fix

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

                                  def delete_objects(
                                      self,
                                      context: RequestContext,
                                      bucket: BucketName,
                                      delete: Delete,
                              Severity: Minor
                              Found in localstack-core/localstack/services/s3/provider.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 list_objects has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def list_objects(
                                      self,
                                      context: RequestContext,
                                      request: ListObjectsRequest,
                                  ) -> ListObjectsOutput:
                              Severity: Minor
                              Found in localstack-core/localstack/services/s3/provider.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 put_bucket_notification_configuration has 6 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  def put_bucket_notification_configuration(
                              Severity: Minor
                              Found in localstack-core/localstack/services/s3/provider.py - About 45 mins to fix

                                Consider simplifying this complex logical expression.
                                Open

                                        if not (canned_acl or present_headers or is_acp_in_body):
                                            raise MissingSecurityHeader(
                                                "Your request was missing a required header", MissingHeaderName="x-amz-acl"
                                            )
                                
                                
                                Severity: Major
                                Found in localstack-core/localstack/services/s3/provider.py - About 40 mins to fix

                                  Function list_bucket_analytics_configurations has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                      def list_bucket_analytics_configurations(
                                  Severity: Minor
                                  Found in localstack-core/localstack/services/s3/provider.py - About 35 mins to fix

                                    Function list_bucket_inventory_configurations has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                        def list_bucket_inventory_configurations(
                                    Severity: Minor
                                    Found in localstack-core/localstack/services/s3/provider.py - About 35 mins to fix

                                      Function delete_bucket_inventory_configuration has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                      Open

                                          def delete_bucket_inventory_configuration(
                                      Severity: Minor
                                      Found in localstack-core/localstack/services/s3/provider.py - About 35 mins to fix

                                        Function put_bucket_intelligent_tiering_configuration has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                        Open

                                            def put_bucket_intelligent_tiering_configuration(
                                        Severity: Minor
                                        Found in localstack-core/localstack/services/s3/provider.py - About 35 mins to fix

                                          Function _fix_bucket_response_head has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                          Open

                                              def _fix_bucket_response_head(fn, self, bucket_name, *args, **kwargs):
                                          Severity: Minor
                                          Found in localstack-core/localstack/services/s3/provider.py - About 35 mins to fix

                                            Function delete_bucket_analytics_configuration has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                            Open

                                                def delete_bucket_analytics_configuration(
                                            Severity: Minor
                                            Found in localstack-core/localstack/services/s3/provider.py - About 35 mins to fix

                                              Function get_bucket_inventory_configuration has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                              Open

                                                  def get_bucket_inventory_configuration(
                                              Severity: Minor
                                              Found in localstack-core/localstack/services/s3/provider.py - About 35 mins to fix

                                                Function get_bucket_analytics_configuration has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                Open

                                                    def get_bucket_analytics_configuration(
                                                Severity: Minor
                                                Found in localstack-core/localstack/services/s3/provider.py - About 35 mins to fix

                                                  Function get_object_attributes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                      def get_object_attributes(
                                                          self,
                                                          context: RequestContext,
                                                          request: GetObjectAttributesRequest,
                                                      ) -> GetObjectAttributesOutput:
                                                  Severity: Minor
                                                  Found in localstack-core/localstack/services/s3/provider.py - About 35 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 put_bucket_logging has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                      def put_bucket_logging(
                                                          self,
                                                          context: RequestContext,
                                                          bucket: BucketName,
                                                          bucket_logging_status: BucketLoggingStatus,
                                                  Severity: Minor
                                                  Found in localstack-core/localstack/services/s3/provider.py - About 35 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 create_bucket has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                      def create_bucket(
                                                          self,
                                                          context: RequestContext,
                                                          request: CreateBucketRequest,
                                                      ) -> CreateBucketOutput:
                                                  Severity: Minor
                                                  Found in localstack-core/localstack/services/s3/provider.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

                                                  There are no issues that match your filters.

                                                  Category
                                                  Status