opengovernment/askthem

View on GitHub
app/models/cached_officials_from_google.rb

Summary

Maintainability
A
3 hrs
Test Coverage

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

  def guess_division_scope(office, division)
    if office.is_governor? ||
        (office.is_federal_legislator? &&
         office.roles.include?("legislatorUpperBody"))
      GoogleCivicInfo::Division::STATEWIDE
Severity: Minor
Found in app/models/cached_officials_from_google.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 legacy_skip_for_now has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def legacy_skip_for_now(office, division)
    (office.level == "county" && (office.name.downcase != "mayor" &&
                                  !office.name.downcase.include?("council"))) ||
      (office.level == "federal" && division.scope == "national") ||
      ((office.level == "city" || office.level == "other") &&
Severity: Minor
Found in app/models/cached_officials_from_google.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

Method jurisdiction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def jurisdiction
      return jurisdiction_from_scope if legacy?

      jurisdiction = state
      if division.is_county?
Severity: Minor
Found in app/models/cached_officials_from_google.rb - About 25 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

Method guess_office_level has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def guess_office_level(office, division)
    if office.is_governor? || office.is_state_legislator?
      GoogleCivicInfo::Office::STATE
    elsif office.is_federal_legislator? || office.is_federal_executive_or_judicial?
      GoogleCivicInfo::Office::FEDERAL
Severity: Minor
Found in app/models/cached_officials_from_google.rb - About 25 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