a2design-company/json-compare

View on GitHub

Showing 5 of 5 total issues

Method compare_hashes has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def compare_hashes(old_hash, new_hash)
      old_hash = old_hash == nil ? {} : old_hash
      new_hash = new_hash == nil ? {} : new_hash
      keys = (old_hash.keys + new_hash.keys).uniq
      result = get_diffs_struct
Severity: Minor
Found in lib/json-compare/comparer.rb - About 2 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 compare_elements has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def compare_elements(old, new)
      diff = {}
      if old.kind_of? Hash
        if new.kind_of? Array
          diff_hash = compare_hash_array(old, new)
Severity: Minor
Found in lib/json-compare/comparer.rb - About 2 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 filter_results has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def filter_results(result)
      return {} if result.nil?
      out_result = {}
      result.each_key do |change_type|
        next if result[change_type].nil?
Severity: Minor
Found in lib/json-compare/comparer.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 compare_hash_array has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def compare_hash_array(old_hash, new_array)
      result = get_diffs_struct

      (0..new_array.count).map do |n|
        next if new_array[n].nil?
Severity: Minor
Found in lib/json-compare/comparer.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 compare_arrays has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def compare_arrays(old_array, new_array)
      old_array_length = old_array.count
      new_array_length = new_array.count
      inters = [old_array.count, new_array.count].min

Severity: Minor
Found in lib/json-compare/comparer.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

Severity
Category
Status
Source
Language