Showing 35 of 45 total issues
Method generate_reminders
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def self.generate_reminders(court_dates, court_locations, court_date_csv, options = {})
time_zone_offset = '-0600' # Make sure this is by instance eventually
total_rrs = 0
Message.transaction do
Rails.logger.tagged('court reminders') do
- 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 clientListInit
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
function clientListInit() {
var clientSearchOptions = {
valueNames: [
{ attr: 'data-category-order', name: 'category-order' },
{ attr: 'data-fullname', name: 'fullname' },
Class GcfFormBuilder
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class GcfFormBuilder < ActionView::Helpers::FormBuilder
# rubocop:disable Metrics/ParameterLists
def gcf_input_field(method, label_text, type: 'text', notes: [], options: {}, classes: [], prefix: nil, autofocus: nil, icon: nil)
classes = classes.append(%w[text-input])
<<-HTML.html_safe
Class Message
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class Message < ApplicationRecord
include Rails.application.routes.url_helpers
belongs_to :reporting_relationship, class_name: 'ReportingRelationship', foreign_key: 'reporting_relationship_id'
belongs_to :original_reporting_relationship, class_name: 'ReportingRelationship', foreign_key: 'original_reporting_relationship_id'
Method track
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def self.track(distinct_id:, label:, user_agent: nil, data: {})
if MIXPANEL_TRACKER.present?
if user_agent
client = DeviceDetector.new(user_agent)
data[:client_bot_name] = client.bot_name
- 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 generate_reminders
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.generate_reminders(court_dates, court_locations, court_date_csv, options = {})
time_zone_offset = '-0600' # Make sure this is by instance eventually
total_rrs = 0
Message.transaction do
Rails.logger.tagged('court reminders') do
Method incoming_voice
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def incoming_voice
voice_client = VoiceService.new
client = Client.find_by(phone_number: params['From'])
client_id = client.try(:id) || 'no client'
department = Department.find_by(phone_number: params['To'])
Method create_from_twilio!
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.create_from_twilio!(twilio_params)
from_phone_number = twilio_params[:From]
to_phone_number = twilio_params[:To]
department = Department.find_by(phone_number: to_phone_number)
Method create
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
@reporting_relationship = ReportingRelationship
.find_by(user: current_user.id, client_id: reporting_relationship_params['client_id'])
@client = Client.find(reporting_relationship_params['client_id'])
@transfer_reporting_relationship = ReportingRelationship.find_or_initialize_by(reporting_relationship_params)
Method create
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
rr_current = ReportingRelationship.find_by(
user: current_user,
client: Client.find(merge_params[:client_id])
)
Method create
has 37 lines of code (exceeds 25 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
Method create
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
client = current_user.clients.find params[:client_id]
rr = ReportingRelationship.find_by(user: current_user, client: client)
send_at = message_params[:send_at].present? ? DateParser.parse(message_params[:send_at][:date], message_params[:send_at][:time]) : Time.zone.now
valid_attachments = true
Method perform
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def perform(message:)
status_callback = Rails.application.routes.url_helpers.incoming_sms_status_url
return if message.sent || (message.send_at > Time.zone.now)
message.reporting_relationship.update!(last_contacted_at: message.send_at)
- 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 update
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
rr_id = params['id']
target_user_id = params['reporting_relationship']['user']['id']
transfer_note = params['transfer']['note']
department_id = params['reporting_relationship']['user']['department_id']
Method transfer_messages
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def transfer_messages(client:, old_users:, new_user:)
original_rrs = ReportingRelationship.where(client: client, user: old_users)
original_messages = Message.where(reporting_relationship: original_rrs).scheduled
new_rr = ReportingRelationship.find_by(client: client, user: new_user)
- 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 perform
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform(message:)
status_callback = Rails.application.routes.url_helpers.incoming_sms_status_url
return if message.sent || (message.send_at > Time.zone.now)
message.reporting_relationship.update!(last_contacted_at: message.send_at)
Method report_usage
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def report_usage(recipient, metrics, end_date)
@end_date = Time.zone.parse(end_date)
@start_date = @end_date - 7.days
@metrics = metrics
@total_outbound = 0
Method create
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def create
client = current_user.clients.find params[:client_id]
rr = ReportingRelationship.find_by(user: current_user, client: client)
send_at = message_params[:send_at].present? ? DateParser.parse(message_params[:send_at][:date], message_params[:send_at][:time]) : Time.zone.now
valid_attachments = true
- 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 update
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def update
rr_id = params['id']
target_user_id = params['reporting_relationship']['user']['id']
transfer_note = params['transfer']['note']
department_id = params['reporting_relationship']['user']['department_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
Function characterCount
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function characterCount(element) {
if(element.length === 0) { return; }
var
label = $("label[for='" + element.attr('id') + "']"),