morning-brew/sanity-ruby

View on GitHub

Showing 4 of 4 total issues

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

      def iterate(arg = args, nested_key: nil)
        arg.each do |key, val|
          if val.is_a?(String) || val.is_a?(Integer)
            filter_value << "#{filter(key: nested_key)} #{key} #{equal} #{cast_value(val)}"
          elsif val.is_a?(Array) && !val[0].is_a?(Hash)
Severity: Minor
Found in lib/sanity/groq/filter.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 iterate has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def iterate(arg = args, nested_key: nil)
        arg.each do |key, val|
          if val.is_a?(String) || val.is_a?(Integer)
            filter_value << "#{filter(key: nested_key)} #{key} #{equal} #{cast_value(val)}"
          elsif val.is_a?(Array) && !val[0].is_a?(Hash)
Severity: Minor
Found in lib/sanity/groq/filter.rb - About 1 hr to fix

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

          def initialize(**args)
            @resource_klass = args.delete(:resource_klass)
            @params = args.delete(:params)
            @query_set = Set.new
    
    
    Severity: Minor
    Found in lib/sanity/http/mutation.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 call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def call
            return unless order
    
            raise ArgumentError, "order must be hash" unless order.is_a?(Hash)
    
    
    Severity: Minor
    Found in lib/sanity/groq/order.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

    Severity
    Category
    Status
    Source
    Language