toptal/chewy

View on GitHub
lib/chewy/search/request.rb

Summary

Maintainability
C
1 day
Test Coverage

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

    class Request
      include Enumerable
      include Scoping
      include Scrolling
      UNDEFINED = Class.new.freeze
Severity: Minor
Found in lib/chewy/search/request.rb - About 4 hrs to fix

    File request.rb has 273 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Chewy
      module Search
        # The main request DSL class. Supports multiple index requests.
        # Supports ES5 search API and query DSL.
        #
    Severity: Minor
    Found in lib/chewy/search/request.rb - About 2 hrs to fix

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

            def first(limit = UNDEFINED)
              request_limit = limit == UNDEFINED ? 1 : limit
      
              if performed? && (request_limit <= size || size == total)
                limit == UNDEFINED ? wrappers.first : wrappers.first(limit)
      Severity: Minor
      Found in lib/chewy/search/request.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 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def find(*ids)
              return super if block_given?
      
              ids = ids.flatten(1).map(&:to_s)
              scope = except(EXTRA_STORAGES).filter(ids: {values: ids})
      Severity: Minor
      Found in lib/chewy/search/request.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 pluck has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def pluck(*fields)
              fields = fields.flatten(1).reject(&:blank?).map(&:to_s)
      
              source_fields = fields - EVERFIELDS
              scope = except(FIELD_STORAGES, EXTRA_STORAGES)
      Severity: Minor
      Found in lib/chewy/search/request.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

      There are no issues that match your filters.

      Category
      Status