Showing 35 of 45 total issues
Method merge_with
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def merge_with(rr_from, copy_name = false)
ActiveRecord::Base.transaction do
to_full_name = client.full_name
from_full_name = rr_from.client.full_name
Function setCounter
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function setCounter(counter, textField, modalVisible) {
var length = $(textField).val().length;
var fileEmpty = [undefined, ''].indexOf($('#message_attachments_0_media').val()) != -1;
isBlank = (length == 0) && (fileEmpty);
var tooLongForSingleText = length > 160;
Method create_client_edit_markers
has 26 lines of code (exceeds 25 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
Method incoming_sms_status
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def incoming_sms_status
message = Message.find_by twilio_sid: params[:SmsSid]
return if message.nil?
heroku_request_start = request.headers['X-Request-Start']
- Read upRead up
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
Function updateMessage
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
updateMessage: function(dom_id, message_id, message_html, status_html, status) {
Method create
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create
rr_current = ReportingRelationship.find_by(
user: current_user,
client: Client.find(merge_params[:client_id])
)
- Read upRead up
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 track_create
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def track_create(message:, send_at:, has_attachment:)
if send_at.present?
flash[:notice] = 'Your message has been scheduled'
analytics_track(
label: 'message_scheduled',
- Read upRead up
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_existing_relationship
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def handle_existing_relationship
return unless @client.errors.added?(:phone_number, :taken)
return if @conflicting_user
existing_relationship = current_user.reporting_relationships.find_by(client: @existing_client)
- Read upRead up
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
Function updateMessage
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
updateMessage: function(dom_id, message_id, message_html, status_html, status) {
// update the message in place, if it's on the page
var msgElement = $("#" + dom_id);
if (msgElement.length) {
var statusElement = msgElement.find(".message--label");
- Read upRead up
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
Function setCounter
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function setCounter(counter, textField, modalVisible) {
var length = $(textField).val().length;
var fileEmpty = [undefined, ''].indexOf($('#message_attachments_0_media').val()) != -1;
isBlank = (length == 0) && (fileEmpty);
var tooLongForSingleText = length > 160;
- Read upRead up
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
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
- Read upRead up
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: '')
- Read upRead up
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
- Read upRead up
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
- Read upRead up
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)
- Read upRead up
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"