Cimpress-MCP/LambdaWrap

View on GitHub

Showing 26 of 26 total issues

File dynamo_db_manager.rb has 276 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module LambdaWrap
  # The DynamoTable class simplifies Creation, Updating, and Destroying Dynamo DB Tables.
  # @since 1.0
  class DynamoTable < AwsService
    # Sets up the DynamoTable for the Dynamo DB Manager. Preloading the configuration in the constructor.
Severity: Minor
Found in lib/lambda_wrap/dynamo_db_manager.rb - About 2 hrs to fix

    Method initialize has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def initialize(options)
          defaults = {
            description: 'Deployed with LambdaWrap', subnet_ids: [], security_group_ids: [], timeout: 30, memory_size: 128,
            delete_unreferenced_versions: true, dead_letter_queue_arn: ''
          }
    Severity: Minor
    Found in lib/lambda_wrap/lambda_manager.rb - 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

    Method initialize has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def initialize(name, variables = {}, description = 'Managed by LambdaWrap')
          raise ArgumentError, 'name must be provided (String)!' unless name && name.is_a?(String)
          # Max Alias Name length is 20 characters.
          raise ArgumentError, "Invalid name format: #{name}" unless /^[a-zA-Z0-9\-\_]{3,20}$/ =~ name
          @name = name
    Severity: Minor
    Found in lib/lambda_wrap/environment.rb - 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

    Class DynamoTable has 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class DynamoTable < AwsService
        # Sets up the DynamoTable for the Dynamo DB Manager. Preloading the configuration in the constructor.
        #
        # @param [Hash] options The configuration for the DynamoDB Table.
        # @option options [String] :table_name The name of the DynamoDB Table. A "Base Name" can be used here where the
    Severity: Minor
    Found in lib/lambda_wrap/dynamo_db_manager.rb - About 2 hrs to fix

      Method initialize has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def initialize(options)
            defaults = {
              description: 'Deployed with LambdaWrap', subnet_ids: [], security_group_ids: [], timeout: 30, memory_size: 128,
              delete_unreferenced_versions: true, dead_letter_queue_arn: ''
            }
      Severity: Minor
      Found in lib/lambda_wrap/lambda_manager.rb - About 1 hr to fix

        Method delete has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def delete
              if dynamo_tables.empty? && lambdas.empty? && api_gateways.empty?
                puts 'Nothing to Deleting.'
                return
              end
        Severity: Minor
        Found in lib/lambda_wrap/api_manager.rb - 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

        Consider simplifying this complex logical expression.
        Open

              unless options[:lambda_client] && options[:dynamo_client] && options[:api_gateway_client]
                access_key_id = options[:access_key_id] || ENV['AWS_ACCESS_KEY_ID'] || ENV['ACCESS_KEY'] ||
                                raise(ArgumentError, 'Cannot find AWS Access Key ID.')
        
                secret_access_key = options[:secret_access_key] || ENV['AWS_SECRET_ACCESS_KEY'] || ENV['SECRET_KEY'] ||
        Severity: Critical
        Found in lib/lambda_wrap/api_manager.rb - About 1 hr to fix

          Method deploy has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              def deploy(environment_options)
                environment_parameter_guard(environment_options)
                if no_op?
                  puts 'Nothing to deploy.'
                  return
          Severity: Minor
          Found in lib/lambda_wrap/api_manager.rb - 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

          Method teardown has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              def teardown(environment_options)
                environment_parameter_guard(environment_options)
                if no_op?
                  puts 'Nothing to teardown.'
                  return
          Severity: Minor
          Found in lib/lambda_wrap/api_manager.rb - 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

          Method initialize has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def initialize(options)
                default_options = { append_environment_on_deploy: false, read_capacity_units: 1, write_capacity_units: 1,
                                    local_secondary_indexes: nil, global_secondary_indexes: nil,
                                    attribute_definitions: [{ attribute_name: 'Id', attribute_type: 'S' }],
                                    key_schema: [{ attribute_name: 'Id', key_type: 'HASH' }] }
          Severity: Minor
          Found in lib/lambda_wrap/dynamo_db_manager.rb - About 1 hr to fix

            Method build_global_index_updates_array has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def build_global_index_updates_array(current_global_indexes)
                  indexes_to_update = []
                  return indexes_to_update if current_global_indexes.empty?
                  current_global_indexes.each do |current_index|
                    @global_secondary_indexes.each do |target_index|
            Severity: Minor
            Found in lib/lambda_wrap/dynamo_db_manager.rb - 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

            Method deploy has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def deploy(environment_options)
                  environment_parameter_guard(environment_options)
                  if no_op?
                    puts 'Nothing to deploy.'
                    return
            Severity: Minor
            Found in lib/lambda_wrap/api_manager.rb - About 1 hr to fix

              Method teardown has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def teardown(environment_options)
                    environment_parameter_guard(environment_options)
                    if no_op?
                      puts 'Nothing to teardown.'
                      return
              Severity: Minor
              Found in lib/lambda_wrap/api_manager.rb - About 1 hr to fix

                Method delete has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def delete
                      if dynamo_tables.empty? && lambdas.empty? && api_gateways.empty?
                        puts 'Nothing to Deleting.'
                        return
                      end
                Severity: Minor
                Found in lib/lambda_wrap/api_manager.rb - About 1 hr to fix

                  Method deploy has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def deploy(environment_options, client, region = 'AWS_REGION')
                        super
                        puts "Deploying API: #{@api_name} to Environment: #{environment_options.name}"
                        @stage_variables = environment_options.variables || {}
                        @stage_variables.store('environment', environment_options.name)
                  Severity: Minor
                  Found in lib/lambda_wrap/api_gateway_manager.rb - About 1 hr to fix

                    Method initialize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def initialize(options)
                          default_options = { append_environment_on_deploy: false, read_capacity_units: 1, write_capacity_units: 1,
                                              local_secondary_indexes: nil, global_secondary_indexes: nil,
                                              attribute_definitions: [{ attribute_name: 'Id', attribute_type: 'S' }],
                                              key_schema: [{ attribute_name: 'Id', key_type: 'HASH' }] }
                    Severity: Minor
                    Found in lib/lambda_wrap/dynamo_db_manager.rb - 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

                    Method update_table has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def update_table(full_table_name, table_details)
                          # Determine if Provisioned Throughput needs to be updated.
                          if  @read_capacity_units != table_details.provisioned_throughput.read_capacity_units &&
                              @write_capacity_units != table_details.provisioned_throughput.write_capacity_units
                    
                    
                    Severity: Minor
                    Found in lib/lambda_wrap/dynamo_db_manager.rb - About 55 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

                    Method get_id_for_api has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def get_id_for_api(api_name)
                          response = nil
                          loop do
                            options = {
                              limit: 500
                    Severity: Minor
                    Found in lib/lambda_wrap/api_gateway_manager.rb - 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

                    Method deploy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def deploy(environment_options, client, region = 'AWS_REGION')
                          super
                          puts "Deploying API: #{@api_name} to Environment: #{environment_options.name}"
                          @stage_variables = environment_options.variables || {}
                          @stage_variables.store('environment', environment_options.name)
                    Severity: Minor
                    Found in lib/lambda_wrap/api_gateway_manager.rb - 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

                    Method deploy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def deploy(environment_options, client, region = 'AWS_REGION')
                          super
                    
                          puts "Deploying Table: #{@table_name} to Environment: #{environment_options.name}"
                    
                    
                    Severity: Minor
                    Found in lib/lambda_wrap/dynamo_db_manager.rb - 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

                    Severity
                    Category
                    Status
                    Source
                    Language