mongoid/mongoid-scroll

View on GitHub

Showing 8 of 10 total issues

Method parse_field_value has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

      def parse_field_value(field_type, field_name, value)
        return nil unless value

        case field_type.to_s
        when 'BSON::ObjectId' then BSON::ObjectId.from_string(value)
Severity: Minor
Found in lib/mongoid/scroll/base_cursor.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 scroll has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def scroll(cursor_or_type = nil, options = nil, &_block)
      cursor, cursor_type = cursor_and_type(cursor_or_type)
      view = self
      # we don't support scrolling over a view with multiple fields
      raise Mongoid::Scroll::Errors::MultipleSortFieldsError.new(sort: view.sort) if view.sort && view.sort.keys.size != 1
Severity: Minor
Found in lib/mongo/scrollable.rb - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

      def initialize(value = nil, options = {})
        options = extract_field_options(options)
        raise ArgumentError.new 'Missing options[:field_name] and/or options[:field_type].' unless options
        if value
          parts = value.split(':') if value
Severity: Minor
Found in lib/mongoid/scroll/cursor.rb - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

      def initialize(value, options = {})
        options = extract_field_options(options)
        if value
          begin
            parsed = ::JSON.parse(::Base64.strict_decode64(value))
Severity: Minor
Found in lib/mongoid/scroll/base64_encoded_cursor.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 criteria has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def criteria
        mongo_value = value.class.mongoize(value) if value
        cursor_criteria = { field_name => { compare_direction => mongo_value } } if mongo_value
        tiebreak_criteria = { field_name => mongo_value, :_id => { tiebreak_compare_direction => tiebreak_id } } if mongo_value && tiebreak_id
        cursor_selector = if Mongoid::Compatibility::Version.mongoid6_or_newer?
Severity: Minor
Found in lib/mongoid/scroll/base_cursor.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 scroll has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def scroll(cursor_or_type = nil, &_block)
        cursor, cursor_type = cursor_and_type(cursor_or_type)
        raise_multiple_sort_fields_error if multiple_sort_fields?
        criteria = dup
        criteria.merge!(default_sort) if no_sort_option?
Severity: Minor
Found in lib/mongoid/criteria/scrollable.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 cursor_and_type has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def cursor_and_type(cursor_or_type)
          cursor = cursor_or_type.is_a?(Class) ? nil : cursor_or_type
          cursor_type = cursor_or_type.is_a?(Class) ? cursor_or_type : nil
          cursor_type ||= cursor.class if cursor.is_a?(Mongoid::Scroll::BaseCursor)
          cursor_type ||= Mongoid::Scroll::Cursor
Severity: Minor
Found in lib/mongoid/criteria/scrollable/cursors.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 extract_field_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def extract_field_options(options)
        if options && (field_name = options[:field_name]) && (field_type = options[:field_type])
          {
            field_type: field_type.to_s,
            field_name: field_name.to_s,
Severity: Minor
Found in lib/mongoid/scroll/base_cursor.rb - About 25 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Severity
Category
Status
Source
Language