SpeciesFileGroup/taxonworks

View on GitHub
lib/utilities/hashes.rb

Summary

Maintainability
A
35 mins
Test Coverage

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

  def self.symbolize_keys(hash)
    hash.inject({}) do |h, (k, v)|
      h[k.is_a?(String) ? k.to_sym : k] = (v.is_a?(Hash) ? symbolize_keys(v) : v)
      h
    end
Severity: Minor
Found in lib/utilities/hashes.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

Do not write to stdout. Use Rails's logger if you want to log.
Open

        puts "#{i}: [#{j}] != [#{b[i]}]"
Severity: Minor
Found in lib/utilities/hashes.rb by rubocop

This cop checks for the use of output calls like puts and print

Example:

# bad
puts 'A debug message'
pp 'A debug message'
print 'A debug message'

# good
Rails.logger.debug 'A debug message'

Use j.present? instead of !j.blank?.
Open

      if b[i] && !j.blank? && b[i] != j
Severity: Minor
Found in lib/utilities/hashes.rb by rubocop

This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

Example: NotNilAndNotEmpty: true (default)

# Converts usages of `!nil? && !empty?` to `present?`

# bad
!foo.nil? && !foo.empty?

# bad
foo != nil && !foo.empty?

# good
foo.present?

Example: NotBlank: true (default)

# Converts usages of `!blank?` to `present?`

# bad
!foo.blank?

# bad
not foo.blank?

# good
foo.present?

Example: UnlessBlank: true (default)

# Converts usages of `unless blank?` to `if present?`

# bad
something unless foo.blank?

# good
something if foo.present?

There are no issues that match your filters.

Category
Status