agile-alliance-brazil/submissions

View on GitHub
app/helpers/diversity_helper.rb

Summary

Maintainability
B
4 hrs
Test Coverage
A
100%

Method translated_age_range has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def translated_age_range(a_birth_date)
    return '' unless a_birth_date.respond_to?(:beginning_of_day)

    date = a_birth_date.beginning_of_day
    today = DateTime.current.beginning_of_day
Severity: Minor
Found in app/helpers/diversity_helper.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

Avoid too many return statements within this method.
Open

    return t('age_range.45_to_49') if today.advance(years: -50) < date
Severity: Major
Found in app/helpers/diversity_helper.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

        return t('age_range.55_to_59') if today.advance(years: -60) < date
    Severity: Major
    Found in app/helpers/diversity_helper.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

          return t('age_range.40_to_44') if today.advance(years: -45) < date
      Severity: Major
      Found in app/helpers/diversity_helper.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

            return t('age_range.50_to_54') if today.advance(years: -55) < date
        Severity: Major
        Found in app/helpers/diversity_helper.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

              return t('age_range.30_to_34') if today.advance(years: -35) < date
          Severity: Major
          Found in app/helpers/diversity_helper.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                return t('age_range.35_to_39') if today.advance(years: -40) < date
            Severity: Major
            Found in app/helpers/diversity_helper.rb - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status