openjaf/cenit

View on GitHub
lib/mongoff/validator.rb

Summary

Maintainability
F
2 wks
Test Coverage

File validator.rb has 1158 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'resolv'

module Mongoff
  module Validator
    extend self
Severity: Major
Found in lib/mongoff/validator.rb - About 2 days to fix

    Method validate_instance has a Cognitive Complexity of 74 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate_instance(instance, options = {})
          unless (visited = options[:visited])
            visited = options[:visited] = Set.new
          end
          unless (soft_checked = visited.include?(instance))
    Severity: Minor
    Found in lib/mongoff/validator.rb - 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

    Method check_patternProperties has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_patternProperties(patterns, instance, state, data_type, options)
          path = options[:path] || '#'
          unless (checked_properties = state[:checked_properties])
            checked_properties = state[:checked_properties] = Set.new
          end
    Severity: Minor
    Found in lib/mongoff/validator.rb - About 6 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 check_type has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_type(types, instance, _, _, options, schema)
          return if instance.nil? && options[:skip_nulls]
          if types
            types = [types] unless types.is_a?(Array)
            types = types.map(&:to_s).map(&:to_sym)
    Severity: Minor
    Found in lib/mongoff/validator.rb - 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

    Method check_additionalProperties has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_additionalProperties(schema, instance, state, data_type, options)
          path = options[:path] || '#'
          unless (checked_properties = state[:checked_properties])
            checked_properties = state[:checked_properties] = Set.new
          end
    Severity: Minor
    Found in lib/mongoff/validator.rb - 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

    Method check_properties has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_properties(properties, instance, state, data_type, options)
          path = options[:path] || '#'
          unless (checked_properties = state[:checked_properties])
            checked_properties = state[:checked_properties] = Set.new
          end
    Severity: Minor
    Found in lib/mongoff/validator.rb - 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

    Method check_dependentRequired has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_dependentRequired(properties, instance)
          return unless instance
          if instance.is_a?(Mongoff::Record)
            has_errors = false
            stored_properties = instance.orm_model.stored_properties_on(instance).map(&:to_s)
    Severity: Minor
    Found in lib/mongoff/validator.rb - 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

    Method check_string_format has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_string_format(format, instance)
          case format
    
            when 'date', 'date-time', 'time'
              unless DATE_TIME_TYPES.any? { |type| instance.is_a?(type) }
    Severity: Minor
    Found in lib/mongoff/validator.rb - 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

    Method check_items has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_items(items_schema, items, state, data_type, options)
          path = options[:path] || '#'
          if items.is_a?(Mongoff::RecordArray)
            items_schema = items.orm_model.schema
            data_type = items.orm_model.data_type
    Severity: Minor
    Found in lib/mongoff/validator.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 check_dependentSchemas has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_dependentSchemas(properties, instance, _, data_type)
          return unless instance
          if instance.is_a?(Mongoff::Record)
            has_errors = false
            stored_properties = instance.orm_model.stored_properties_on(instance).map(&:to_s)
    Severity: Minor
    Found in lib/mongoff/validator.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 validate_instance has 65 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def validate_instance(instance, options = {})
          unless (visited = options[:visited])
            visited = options[:visited] = Set.new
          end
          unless (soft_checked = visited.include?(instance))
    Severity: Major
    Found in lib/mongoff/validator.rb - About 2 hrs to fix

      Method check_required has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def check_required(properties, instance)
            return unless instance && properties.is_a?(Array)
            if instance.is_a?(Mongoff::Record)
              has_errors = false
              stored_properties = instance.orm_model.stored_properties_on(instance)
      Severity: Minor
      Found in lib/mongoff/validator.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 check_patternProperties has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def check_patternProperties(patterns, instance, state, data_type, options)
            path = options[:path] || '#'
            unless (checked_properties = state[:checked_properties])
              checked_properties = state[:checked_properties] = Set.new
            end
      Severity: Major
      Found in lib/mongoff/validator.rb - About 2 hrs to fix

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

            def check_propertyNames(schema, instance, state, data_type, options)
              path = options[:path] || '#'
              schema = data_type.merge_schema(schema)
              if instance.is_a?(Mongoff::Record)
                unless state[:instance_clear]
        Severity: Minor
        Found in lib/mongoff/validator.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 check_additionalProperties has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def check_additionalProperties(schema, instance, state, data_type, options)
              path = options[:path] || '#'
              unless (checked_properties = state[:checked_properties])
                checked_properties = state[:checked_properties] = Set.new
              end
        Severity: Major
        Found in lib/mongoff/validator.rb - About 2 hrs to fix

          Method check_properties has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def check_properties(properties, instance, state, data_type, options)
                path = options[:path] || '#'
                unless (checked_properties = state[:checked_properties])
                  checked_properties = state[:checked_properties] = Set.new
                end
          Severity: Minor
          Found in lib/mongoff/validator.rb - About 2 hrs to fix

            Method check_items has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def check_items(items_schema, items, state, data_type, options)
                  path = options[:path] || '#'
                  if items.is_a?(Mongoff::RecordArray)
                    items_schema = items.orm_model.schema
                    data_type = items.orm_model.data_type
            Severity: Minor
            Found in lib/mongoff/validator.rb - About 1 hr to fix

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

                  def check_string_format(format, instance)
                    case format
              
                      when 'date', 'date-time', 'time'
                        unless DATE_TIME_TYPES.any? { |type| instance.is_a?(type) }
              Severity: Minor
              Found in lib/mongoff/validator.rb - About 1 hr to fix

                Method check_type has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def check_type(types, instance, _, _, options, schema)
                      return if instance.nil? && options[:skip_nulls]
                      if types
                        types = [types] unless types.is_a?(Array)
                        types = types.map(&:to_s).map(&:to_sym)
                Severity: Minor
                Found in lib/mongoff/validator.rb - About 1 hr to fix

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

                      def _handle_error(instance, err, property = :base)
                        return unless instance
                        msg = err.is_a?(String) ? err : err.message
                        if block_given?
                          msg = yield msg
                  Severity: Minor
                  Found in lib/mongoff/validator.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 check_propertyNames has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def check_propertyNames(schema, instance, state, data_type, options)
                        path = options[:path] || '#'
                        schema = data_type.merge_schema(schema)
                        if instance.is_a?(Mongoff::Record)
                          unless state[:instance_clear]
                  Severity: Minor
                  Found in lib/mongoff/validator.rb - About 1 hr to fix

                    Method check_dependentRequired has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def check_dependentRequired(properties, instance)
                          return unless instance
                          if instance.is_a?(Mongoff::Record)
                            has_errors = false
                            stored_properties = instance.orm_model.stored_properties_on(instance).map(&:to_s)
                    Severity: Minor
                    Found in lib/mongoff/validator.rb - About 1 hr to fix

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

                          def check_contains(contains_schema, items, state, data_type, options, schema)
                            return unless items.is_a?(Mongoff::RecordArray) || items.is_a?(Array)
                            contains_schema = data_type.merge_schema(contains_schema)
                            data_type = items.orm_model.data_type if items.is_a?(Mongoff::RecordArray)
                            max_min = schema['maxContains'] || schema['minContains']
                      Severity: Minor
                      Found in lib/mongoff/validator.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 check_dependentSchemas has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def check_dependentSchemas(properties, instance, _, data_type)
                            return unless instance
                            if instance.is_a?(Mongoff::Record)
                              has_errors = false
                              stored_properties = instance.orm_model.stored_properties_on(instance).map(&:to_s)
                      Severity: Minor
                      Found in lib/mongoff/validator.rb - About 1 hr to fix

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

                            def check_oneOf(schemas, instance, _, data_type)
                              one_index = nil
                              schemas.each_with_index do |schema, index|
                                valid =
                                  begin
                        Severity: Minor
                        Found in lib/mongoff/validator.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 check_schema_items has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def check_schema_items(items_schema)
                              _check_type(:items, items_schema, Hash, Array)
                              if items_schema.is_a?(Hash)
                                begin
                                  validate(items_schema)
                        Severity: Minor
                        Found in lib/mongoff/validator.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 check_additionalItems has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def check_additionalItems(items_schema, items, state, data_type, options)
                              if (start_index = state[:additional_items_index]) && start_index < items.length
                                path = options[:path] || '#'
                                items_schema = items_schema.is_a?(FalseClass) ? false : (items_schema || true)
                                items_schema = data_type.merge_schema(items_schema)
                        Severity: Minor
                        Found in lib/mongoff/validator.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 check_contains has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def check_contains(contains_schema, items, state, data_type, options, schema)
                        Severity: Minor
                        Found in lib/mongoff/validator.rb - About 45 mins to fix

                          Method check_maximum has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              def check_maximum(maximum, instance, _state, _data_type, _options, schema)
                          Severity: Minor
                          Found in lib/mongoff/validator.rb - About 45 mins to fix

                            Method check_type has 6 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                def check_type(types, instance, _, _, options, schema)
                            Severity: Minor
                            Found in lib/mongoff/validator.rb - About 45 mins to fix

                              Method check_format has 6 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  def check_format(format, instance, _state, _data_type, _options, schema)
                              Severity: Minor
                              Found in lib/mongoff/validator.rb - About 45 mins to fix

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

                                    def check_schema_type(types)
                                      return if types.nil?
                                      types = [types] unless types.is_a?(Array)
                                      types = types.map(&:to_s).map(&:to_sym)
                                      raise_path_less_error "types are not unique" unless types.uniq.length === types.length
                                Severity: Minor
                                Found in lib/mongoff/validator.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 check_minimum has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    def check_minimum(minimum, instance, _state, _data_type, _options, schema)
                                Severity: Minor
                                Found in lib/mongoff/validator.rb - About 45 mins to fix

                                  Method check_patternProperties has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                      def check_patternProperties(patterns, instance, state, data_type, options)
                                  Severity: Minor
                                  Found in lib/mongoff/validator.rb - About 35 mins to fix

                                    Method check_additionalProperties has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                        def check_additionalProperties(schema, instance, state, data_type, options)
                                    Severity: Minor
                                    Found in lib/mongoff/validator.rb - About 35 mins to fix

                                      Method check_properties has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                      Open

                                          def check_properties(properties, instance, state, data_type, options)
                                      Severity: Minor
                                      Found in lib/mongoff/validator.rb - About 35 mins to fix

                                        Method check_items has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                        Open

                                            def check_items(items_schema, items, state, data_type, options)
                                        Severity: Minor
                                        Found in lib/mongoff/validator.rb - About 35 mins to fix

                                          Method check_propertyNames has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                          Open

                                              def check_propertyNames(schema, instance, state, data_type, options)
                                          Severity: Minor
                                          Found in lib/mongoff/validator.rb - About 35 mins to fix

                                            Method check_additionalItems has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                            Open

                                                def check_additionalItems(items_schema, items, state, data_type, options)
                                            Severity: Minor
                                            Found in lib/mongoff/validator.rb - About 35 mins to fix

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

                                                  def check_maximum(maximum, instance, _state, _data_type, _options, schema)
                                                    if instance.is_a?(Numeric)
                                                      if schema['exclusiveMaximum'].is_a?(TrueClass)
                                                        raise_path_less_error "must be strictly less than #{maximum}" if instance >= maximum
                                                      else
                                              Severity: Minor
                                              Found in lib/mongoff/validator.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 check_minimum has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                                  def check_minimum(minimum, instance, _state, _data_type, _options, schema)
                                                    if instance.is_a?(Numeric)
                                                      if schema['exclusiveMinimum'].is_a?(TrueClass)
                                                        raise_path_less_error "must be strictly greater than #{minimum}" if instance <= minimum
                                                      else
                                              Severity: Minor
                                              Found in lib/mongoff/validator.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 check_maxProperties has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                                  def check_maxProperties(max, instance)
                                                    if instance.is_a?(Mongoff::Record) || instance.is_a?(Hash)
                                                      instance = instance.orm_model.stored_properties_on(instance) if instance.is_a?(Mongoff::Record)
                                                      raise_path_less_error "has too many properties (#{instance.size} of #{max} max)" if instance.size > max
                                                    end
                                              Severity: Minor
                                              Found in lib/mongoff/validator.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

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

                                                  def check_minProperties(min, instance)
                                                    if instance.is_a?(Mongoff::Record) || instance.is_a?(Hash)
                                                      instance = instance.orm_model.stored_properties_on(instance) if instance.is_a?(Mongoff::Record)
                                                      raise_path_less_error "has too few properties (#{instance.size} for #{min} min)" if instance.size < min
                                                    end
                                              Severity: Minor
                                              Found in lib/mongoff/validator.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

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

                                                  def check_format(format, instance, _state, _data_type, _options, schema)
                                                    if instance
                                                      if schema['type'] == 'string'
                                                        check_string_format(format, instance)
                                                      end
                                              Severity: Minor
                                              Found in lib/mongoff/validator.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

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

                                                  def check_minProperties(min, instance)
                                                    if instance.is_a?(Mongoff::Record) || instance.is_a?(Hash)
                                                      instance = instance.orm_model.stored_properties_on(instance) if instance.is_a?(Mongoff::Record)
                                                      raise_path_less_error "has too few properties (#{instance.size} for #{min} min)" if instance.size < min
                                                    end
                                              Severity: Minor
                                              Found in lib/mongoff/validator.rb and 1 other location - About 35 mins to fix
                                              lib/mongoff/validator.rb on lines 864..868

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

                                              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 check_maxProperties(max, instance)
                                                    if instance.is_a?(Mongoff::Record) || instance.is_a?(Hash)
                                                      instance = instance.orm_model.stored_properties_on(instance) if instance.is_a?(Mongoff::Record)
                                                      raise_path_less_error "has too many properties (#{instance.size} of #{max} max)" if instance.size > max
                                                    end
                                              Severity: Minor
                                              Found in lib/mongoff/validator.rb and 1 other location - About 35 mins to fix
                                              lib/mongoff/validator.rb on lines 876..880

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

                                              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_schema_oneOf(schemas)
                                                    _check_type(:oneOf, schemas, Array)
                                                    raise_path_less_error 'oneOf schemas should not be empty' if schemas.length == 0
                                                    schemas.each_with_index do |schema, index|
                                                      begin
                                              Severity: Minor
                                              Found in lib/mongoff/validator.rb and 2 other locations - About 30 mins to fix
                                              lib/mongoff/validator.rb on lines 1077..1085
                                              lib/mongoff/validator.rb on lines 1099..1107

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

                                              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

                                                        begin
                                                          validate_instance(value, options.merge(
                                                            path: "#{path}/#{property}",
                                                            schema: schema,
                                                            data_type: data_type
                                              Severity: Minor
                                              Found in lib/mongoff/validator.rb and 1 other location - About 30 mins to fix
                                              lib/mongoff/validator.rb on lines 1062..1070

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

                                              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

                                                        begin
                                                          validate_instance(property, options.merge(
                                                            path: "#{path}/#{property}",
                                                            schema: schema,
                                                            data_type: data_type
                                              Severity: Minor
                                              Found in lib/mongoff/validator.rb and 1 other location - About 30 mins to fix
                                              lib/mongoff/validator.rb on lines 948..956

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

                                              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_schema_allOf(schemas)
                                                    _check_type(:allOf, schemas, Array)
                                                    raise_path_less_error 'allOf schemas should not be empty' if schemas.length == 0
                                                    schemas.each_with_index do |schema, index|
                                                      begin
                                              Severity: Minor
                                              Found in lib/mongoff/validator.rb and 2 other locations - About 30 mins to fix
                                              lib/mongoff/validator.rb on lines 1099..1107
                                              lib/mongoff/validator.rb on lines 1122..1130

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

                                              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_schema_anyOf(schemas)
                                                    _check_type(:anyOf, schemas, Array)
                                                    raise_path_less_error 'anyOf schemas should not be empty' if schemas.length == 0
                                                    schemas.each_with_index do |schema, index|
                                                      begin
                                              Severity: Minor
                                              Found in lib/mongoff/validator.rb and 2 other locations - About 30 mins to fix
                                              lib/mongoff/validator.rb on lines 1077..1085
                                              lib/mongoff/validator.rb on lines 1122..1130

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

                                              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 check_minimum(minimum, instance, _state, _data_type, _options, schema)
                                                    if instance.is_a?(Numeric)
                                                      if schema['exclusiveMinimum'].is_a?(TrueClass)
                                                        raise_path_less_error "must be strictly greater than #{minimum}" if instance <= minimum
                                                      else
                                              Severity: Minor
                                              Found in lib/mongoff/validator.rb and 1 other location - About 20 mins to fix
                                              lib/mongoff/validator.rb on lines 268..273

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

                                              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 check_maximum(maximum, instance, _state, _data_type, _options, schema)
                                                    if instance.is_a?(Numeric)
                                                      if schema['exclusiveMaximum'].is_a?(TrueClass)
                                                        raise_path_less_error "must be strictly less than #{maximum}" if instance >= maximum
                                                      else
                                              Severity: Minor
                                              Found in lib/mongoff/validator.rb and 1 other location - About 20 mins to fix
                                              lib/mongoff/validator.rb on lines 292..297

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

                                              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 check_schema_properties(value)
                                                    _check_type(:properties, value, Hash)
                                                    value.each do |property, schema|
                                                      begin
                                                        validate(schema)
                                              Severity: Minor
                                              Found in lib/mongoff/validator.rb and 1 other location - About 15 mins to fix
                                              lib/mongoff/validator.rb on lines 1229..1236

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

                                              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 check_schema_dependentSchemas(properties)
                                                    _check_type(:dependentSchemas, properties, Hash)
                                                    properties.each do |property_name, dependent_schema|
                                                      begin
                                                        validate(dependent_schema)
                                              Severity: Minor
                                              Found in lib/mongoff/validator.rb and 1 other location - About 15 mins to fix
                                              lib/mongoff/validator.rb on lines 795..802

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

                                              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 check_maxItems(max, items)
                                                    if items.is_a?(Mongoff::RecordArray) || items.is_a?(Array)
                                                      raise_path_less_error "has too many items (#{items.count} of #{max} max)" if items.count > max
                                                    end
                                              Severity: Minor
                                              Found in lib/mongoff/validator.rb and 1 other location - About 15 mins to fix
                                              lib/mongoff/validator.rb on lines 625..628

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

                                              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 check_minItems(min, items)
                                                    if items.is_a?(Mongoff::RecordArray) || items.is_a?(Array)
                                                      raise_path_less_error "has too few items (#{items.count} for #{min} min)" if items.count < min
                                                    end
                                              Severity: Minor
                                              Found in lib/mongoff/validator.rb and 1 other location - About 15 mins to fix
                                              lib/mongoff/validator.rb on lines 614..617

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

                                              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

                                              There are no issues that match your filters.

                                              Category
                                              Status