18F/identity-dashboard

View on GitHub
app/models/help_text.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Method to_localized_h has a Cognitive Complexity of 14 (exceeds 6 allowed). Consider refactoring.
Open

  def to_localized_h
    is_presets_only = presets_only?
    result = {}
    CONTEXTS.each do |context|
      result[context] = Hash.new
Severity: Minor
Found in app/models/help_text.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 revert_presets_to_short_name has a Cognitive Complexity of 13 (exceeds 6 allowed). Consider refactoring.
Open

  def revert_presets_to_short_name
    CONTEXTS.each do |context|
      next if help_text[context].blank?
      PRESETS[context].each do |preset|
        LOCALES.each do |locale|
Severity: Minor
Found in app/models/help_text.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 presets_only? has a Cognitive Complexity of 12 (exceeds 6 allowed). Consider refactoring.
Open

  def presets_only?
    CONTEXTS.each do |context|
      next unless help_text[context]
      LOCALES.each do |locale|
        next if help_text[context][locale].blank?
Severity: Minor
Found in app/models/help_text.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 blank? has a Cognitive Complexity of 8 (exceeds 6 allowed). Consider refactoring.
Open

  def blank?
    CONTEXTS.any? do |context|
      next unless help_text[context]
      help_text[context].values.any? do |value|
        return false unless blank_text?(value)
Severity: Minor
Found in app/models/help_text.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

There are no issues that match your filters.

Category
Status