jpsimonroy/looksist

View on GitHub

Showing 8 of 8 total issues

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

      def update_using_json_path(hash, at, opts)
        if hash.is_a?(Hash)
          if at.present?
            JsonPath.for(hash.with_indifferent_access).gsub!(at) do |i|
              i.is_a?(Array) ? inject_attributes_for(i, at, opts) : inject_attributes_at(i, opts) unless (i.nil? or i.empty?)
Severity: Minor
Found in lib/looksist/hashed.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 inject_attributes_at has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def inject_attributes_at(hash_offset, opts)
        return hash_offset if hash_offset.nil? or hash_offset.empty?
        opts.each do |opt|
          keys = hash_offset[opt[:using]]
          entity_name = __entity__(opt[:bucket_name] || opt[:using])
Severity: Minor
Found in lib/looksist/hashed.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 smart_lookup has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def smart_lookup(array_of_hashes, opts, all_values, at)
        ## populate is not a array
        array_of_hashes.collect do |elt|
          if at.present?
            JsonPath.for(elt.with_indifferent_access).gsub!(at) do |node|
Severity: Minor
Found in lib/looksist/hashed.rb - About 1 hr to fix

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

          def lookup(what, opts)
            @lookup_attributes ||= {}
            unless opts.keys.all? { |k| [:using, :bucket_name, :as].include? k }
              raise 'Incorrect usage: Invalid parameter specified'
            end
    Severity: Minor
    Found in lib/looksist/core.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 smart_lookup has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def smart_lookup(array_of_hashes, opts, all_values, at)
            ## populate is not a array
            array_of_hashes.collect do |elt|
              if at.present?
                JsonPath.for(elt.with_indifferent_access).gsub!(at) do |node|
    Severity: Minor
    Found in lib/looksist/hashed.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 do_populate has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def do_populate(elt, values, using, as, populate)
    Severity: Minor
    Found in lib/looksist/hashed.rb - About 35 mins to fix

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

            def inject(opts)
              raise 'Incorrect usage' unless [:after, :using, :populate].all? { |e| opts.keys.include? e }
      
              after = opts[:after]
              @rules ||= {}
      Severity: Minor
      Found in lib/looksist/hashed.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 find_all_values_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def find_all_values_for(key)
          result = []
          result << self[key]
          self.values.each do |hash_value|
            values = (hash_value.is_a?(Array) ? hash_value : [hash_value])
      Severity: Minor
      Found in lib/looksist/hash.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