Dynamoid/dynamoid

View on GitHub

Showing 61 of 61 total issues

Class Chain has 37 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Chain
      attr_reader :query, :source, :consistent_read, :key_fields_detector

      include Enumerable
      # Create a new criteria chain.
Severity: Minor
Found in lib/dynamoid/criteria/chain.rb - About 4 hrs to fix

    File aws_sdk_v3.rb has 339 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require_relative 'aws_sdk_v3/query'
    require_relative 'aws_sdk_v3/scan'
    require_relative 'aws_sdk_v3/create_table'
    require_relative 'aws_sdk_v3/batch_get_item'
    require_relative 'aws_sdk_v3/item_updater'
    Severity: Minor
    Found in lib/dynamoid/adapter_plugin/aws_sdk_v3.rb - About 4 hrs to fix

      File chain.rb has 333 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require_relative 'key_fields_detector'
      require_relative 'ignored_conditions_detector'
      require_relative 'overwritten_conditions_detector'
      require_relative 'nonexistent_fields_detector'
      
      
      Severity: Minor
      Found in lib/dynamoid/criteria/chain.rb - About 4 hrs to fix

        Class AwsSdkV3 has 28 methods (exceeds 20 allowed). Consider refactoring.
        Open

            class AwsSdkV3
              EQ = 'EQ'
              RANGE_MAP = {
                range_greater_than: 'GT',
                range_less_than:    'LT',
        Severity: Minor
        Found in lib/dynamoid/adapter_plugin/aws_sdk_v3.rb - About 3 hrs to fix

          Method _find_all has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

                def _find_all(ids, options = {})
                  raise Errors::MissingRangeKey if range_key && ids.any? { |pk, sk| sk.nil? }
          
                  if range_key
                    ids = ids.map do |pk, sk|
          Severity: Minor
          Found in lib/dynamoid/finders.rb - About 3 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 dynamodb_type has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.dynamodb_type(type, options)
                if type.is_a?(Class)
                  type = type.respond_to?(:dynamoid_field_type) ? type.dynamoid_field_type : :string
                end
          
          
          Severity: Minor
          Found in lib/dynamoid/primary_key_type_mapping.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

          File type_casting.rb has 257 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module Dynamoid
            # @private
            module TypeCasting
              def self.cast_attributes(attributes, attributes_options)
                {}.tap do |h|
          Severity: Minor
          Found in lib/dynamoid/type_casting.rb - About 2 hrs to fix

            Method call has 54 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def call
                      billing_mode = options[:billing_mode]
                      read_capacity = options[:read_capacity] || Dynamoid::Config.read_capacity
                      write_capacity = options[:write_capacity] || Dynamoid::Config.write_capacity
            
            
            Severity: Major
            Found in lib/dynamoid/adapter_plugin/aws_sdk_v3/create_table.rb - About 2 hrs to fix

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

                      def call
                        results = {}
              
                        tables_with_ids.each do |table, ids|
                          if ids.blank?
              Severity: Minor
              Found in lib/dynamoid/adapter_plugin/aws_sdk_v3/batch_get_item.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

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

                  def self.find_undumper(options)
                    undumper_class = case options[:type]
                                     when :string     then StringUndumper
                                     when :integer    then IntegerUndumper
                                     when :number     then NumberUndumper
              Severity: Major
              Found in lib/dynamoid/undumping.rb and 2 other locations - About 1 hr to fix
              lib/dynamoid/dumping.rb on lines 26..44
              lib/dynamoid/type_casting.rb on lines 26..44

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

              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 self.find_type_caster(options)
                    type_caster_class = case options[:type]
                                        when :string     then StringTypeCaster
                                        when :integer    then IntegerTypeCaster
                                        when :number     then NumberTypeCaster
              Severity: Major
              Found in lib/dynamoid/type_casting.rb and 2 other locations - About 1 hr to fix
              lib/dynamoid/dumping.rb on lines 26..44
              lib/dynamoid/undumping.rb on lines 29..47

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

              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 self.find_dumper(options)
                    dumper_class = case options[:type]
                                   when :string     then StringDumper
                                   when :integer    then IntegerDumper
                                   when :number     then NumberDumper
              Severity: Major
              Found in lib/dynamoid/dumping.rb and 2 other locations - About 1 hr to fix
              lib/dynamoid/type_casting.rb on lines 26..44
              lib/dynamoid/undumping.rb on lines 29..47

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

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

                      def call
                        billing_mode = options[:billing_mode]
                        read_capacity = options[:read_capacity] || Dynamoid::Config.read_capacity
                        write_capacity = options[:write_capacity] || Dynamoid::Config.write_capacity
              
              
              Severity: Minor
              Found in lib/dynamoid/adapter_plugin/aws_sdk_v3/create_table.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 _find_all has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def _find_all(ids, options = {})
                      raise Errors::MissingRangeKey if range_key && ids.any? { |pk, sk| sk.nil? }
              
                      if range_key
                        ids = ids.map do |pk, sk|
              Severity: Minor
              Found in lib/dynamoid/finders.rb - About 1 hr to fix

                Method update! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    def update!(conditions = {})
                      run_callbacks(:update) do
                        options = range_key ? { range_key: Dumping.dump_field(read_attribute(range_key), self.class.attributes[range_key]) } : {}
                
                        begin
                Severity: Minor
                Found in lib/dynamoid/persistence.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

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

                      def upsert(hash_key_value, range_key_value = nil, attrs = {}, conditions = {})
                        optional_params = [range_key_value, attrs, conditions].compact
                        if optional_params.first.is_a?(Hash)
                          range_key_value = nil
                          attrs, conditions = optional_params[0..1]
                Severity: Major
                Found in lib/dynamoid/persistence.rb and 1 other location - About 1 hr to fix
                lib/dynamoid/persistence.rb on lines 284..298

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

                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 update_fields(hash_key_value, range_key_value = nil, attrs = {}, conditions = {})
                        optional_params = [range_key_value, attrs, conditions].compact
                        if optional_params.first.is_a?(Hash)
                          range_key_value = nil
                          attrs, conditions = optional_params[0..1]
                Severity: Major
                Found in lib/dynamoid/persistence.rb and 1 other location - About 1 hr to fix
                lib/dynamoid/persistence.rb on lines 332..346

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

                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 field_hash has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def field_hash(key)
                        name, operation = key.to_s.split('.')
                        val = type_cast_condition_parameter(name, query[key])
                
                        hash = case operation
                Severity: Minor
                Found in lib/dynamoid/criteria/chain.rb - About 1 hr to fix

                  Method find_all_by_secondary_index has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def find_all_by_secondary_index(hash, options = {})
                          ActiveSupport::Deprecation.warn('[Dynamoid] .find_all_by_secondary_index is deprecated! Call .where instead of')
                  
                          range = options[:range] || {}
                          hash_key_field, hash_key_value = hash.first
                  Severity: Minor
                  Found in lib/dynamoid/finders.rb - About 1 hr to fix

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

                        def delete
                          options = range_key ? { range_key: Dumping.dump_field(read_attribute(range_key), self.class.attributes[range_key]) } : {}
                    
                          # Add an optimistic locking check if the lock_version column exists
                          if self.class.attributes[:lock_version]
                    Severity: Minor
                    Found in lib/dynamoid/persistence.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

                    Severity
                    Category
                    Status
                    Source
                    Language