codeforamerica/clientcomm-rails

View on GitHub

Showing 45 of 45 total issues

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

  def create
    send_at = if params[:commit] == 'Schedule messages'
                DateParser.parse(mass_message_params[:send_at][:date], mass_message_params[:send_at][:time])
              else
                Time.zone.now
Severity: Minor
Found in app/controllers/mass_messages_controller.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 redact_message has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def redact_message(message:)
    Rails.logger.tagged('redact message') { Rails.logger.warn "redacting #{message.id}" }
    twilio_message = @client.api.account.messages(message.twilio_sid).fetch
    twilio_message.update(body: '')

Severity: Minor
Found in app/lib/sms_service.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 create_client_edit_markers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.create_client_edit_markers(user:, phone_number:, reporting_relationships:, as_admin:)
    if as_admin && user.admin
      user_full_name = I18n.t('messages.admin_user_description')
      user_id = nil
    else
Severity: Minor
Found in app/models/message.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 normalize_next_court_date_at has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def normalize_next_court_date_at
    bad_input = self.next_court_date_at.nil? && self.next_court_date_at_before_type_cast.class == String && !self.next_court_date_at_before_type_cast.empty?
    raw_input = self.next_court_date_at_before_type_cast.class == String && %r(\d{2}\/\d{2}\/\d{4}).match?(self.next_court_date_at_before_type_cast)
    return unless bad_input || raw_input

Severity: Minor
Found in app/models/client.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 handle_new_relationship_with_existing_client has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def handle_new_relationship_with_existing_client
    return unless @client.errors.added?(:phone_number, :taken)
    return if @conflicting_user
    return if current_user.clients.include?(@existing_client)

Severity: Minor
Found in app/controllers/clients_controller.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