notCalle/ruby-keytree

View on GitHub

Showing 7 of 9 total issues

Method deep_fetch has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

        def deep_fetch(key_path, *default)
          catch do |ball|
            result = key_path.reduce(self) do |hash, key|
              throw ball unless hash.is_a?(Hash)
              hash.fetch(key) { throw ball }
Severity: Minor
Found in lib/key_tree/refine/deep_hash.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 open_all has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def open_all(dir_name, follow_links: false, recurse: false)
      Dir.children(dir_name).reduce(KeyTree::Forest.new) do |result, file|
        path = File.join(dir_name, file)
        next result if File.symlink?(path) && !follow_links

Severity: Minor
Found in lib/key_tree.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 deep_merge! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        def deep_merge!(other, prefix = [], &block)
          merge!(other) do |key, lhs, rhs|
            key_path = prefix + [key]
            both_are_hashes = lhs.is_a?(Hash) && rhs.is_a?(Hash)
            next lhs.deep_merge!(rhs, key_path, &block) if both_are_hashes
Severity: Minor
Found in lib/key_tree/refine/deep_hash.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 deep_merge has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        def deep_merge(other, prefix = [], &block)
          merge(other) do |key, lhs, rhs|
            key_path = prefix + [key]
            both_are_hashes = lhs.is_a?(Hash) && rhs.is_a?(Hash)
            next lhs.deep_merge(rhs, key_path, &block) if both_are_hashes
Severity: Minor
Found in lib/key_tree/refine/deep_hash.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 load has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def load(type, serialization, prefix: nil)
      type = type.to_sym unless type.nil?
      loader = Loader[type]
      contents = loader.load(serialization)
      contents = { prefix => contents } unless prefix.nil?
Severity: Minor
Found in lib/key_tree.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 [] has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def [](key)
      return super(key) if key.is_a?(Numeric)

      trees.lazy.each do |tree|
        result = tree[key]
Severity: Minor
Found in lib/key_tree/forest.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 prefix? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def prefix?(key_path)
      key_path.to_key_path.reduce(@hash) do |subtree, key|
        return false unless subtree.is_a?(Hash)
        return false unless subtree.key?(key)

Severity: Minor
Found in lib/key_tree/tree.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