phoneyourrep/phone-your-rep-api

View on GitHub

Showing 8 of 8 total issues

Method create has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    issue_type = issue_params[:issue_type]

    if issue_type.is_a?(Array)
      @response = []
Severity: Minor
Found in app/controllers/issues_controller.rb - About 55 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 add_secondary_address has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def add_secondary_address(maker, office, index)
    return if index + 1 > ADDR_TYPES.length
    maker.add_addr do |addr|
      addr.preferred  = false
      addr.location   = ADDR_TYPES[index]
Severity: Minor
Found in app/services/v_card_builder.rb - About 55 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 update_fax_phone_and_address has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def update_fax_phone_and_address(rep, off, os_off)
    return set_michigan_senator_office_info(off, os_off) if a_michigan_senator?(rep)
    trim_maryland_legislator_office_address(os_off) if a_maryland_legislator?
    off.fax     = !os_off.fax.blank?     ? os_off.fax     : off.fax
    off.phone   = !os_off.phone.blank?   ? os_off.phone   : off.phone
Severity: Minor
Found in lib/state_rep_updater.rb - About 45 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 add_primary_address has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def add_primary_address(maker)
    maker.add_addr do |addr|
      addr.preferred  = true
      addr.location   = 'work'
      addr.street     = address_and_suite(office_location) if office_location.address
Severity: Minor
Found in app/services/v_card_builder.rb - About 45 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 add_rep_name has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def add_rep_name(maker)
    maker.add_name do |name|
      name.prefix   = ''
      name.fullname = rep.official_full if rep.official_full
      name.given    = rep.first if rep.first
Severity: Minor
Found in app/services/v_card_builder.rb - About 45 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 set_city_state_and_zip has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def set_city_state_and_zip
    return unless address && address_changed?
    phone_only = address.match(/[\p{Zs}\s]+Phone(\s?)+\z/)
    return add_fields_for_phone_only(phone_only) if phone_only
    trim_address_tail
Severity: Minor
Found in app/models/concerns/address_parser.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 update_rep_term_info has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def update_rep_term_info(rep, term)
      dis_code = format('%d', term['district']) if term['district']
      dis_code = dis_code.size == 1 ? "0#{dis_code}" : dis_code if dis_code
      rep.chamber  = determine_current_rep_chamber(term)
      rep.state    = State.find_by(abbr: term['state'])
Severity: Minor
Found in lib/db_pyr_update.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 fetch_photo_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def fetch_photo_data # rubocop:disable Metrics/MethodLength
    open(photo_url, &:read) unless photo_url.blank?
  rescue OpenURI::HTTPError => e
    logger.error e
    false
Severity: Minor
Found in app/models/rep.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

Severity
Category
Status
Source
Language