SpeciesFileGroup/taxonworks

View on GitHub
lib/catalog/nomenclature/paper_catalog.rb

Summary

Maintainability
A
1 hr
Test Coverage

Method build_the_list has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def build_the_list
    results_hash
    return {} if project_id.nil?
    return {} if classification_scope.blank? && otu_filter.blank? && taxon_name_filter.blank?

Severity: Minor
Found in lib/catalog/nomenclature/paper_catalog.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

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

    if !taxon_name_filter.blank?

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