Showing 30 of 35 total issues
Class TeaTime
has 37 methods (exceeds 20 allowed). Consider refactoring. Open
class TeaTime < ActiveRecord::Base
# Only soft-delete tea times
acts_as_paranoid
validates_presence_of :host, :start_time, :city, :duration
Class User
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
class User < ActiveRecord::Base
acts_as_paranoid
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
Method create
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def create
@user = current_user
@tea_time = TeaTime.find(params[:id])
@attendance = Attendance.where(tea_time_id: @tea_time.id, user_id: @user.id).first_or_initialize
- 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_list_from_segments
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def self.create_list_from_segments(name, segments, sample)
# Creates a SendGrid List corresponding to the union of the segments in
# `segments` and with a random sample of `sample` (which can be blank).
if @sg
all_recipients = get_recipients(segments).to_a
- 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 15 (exceeds 5 allowed). Consider refactoring. Open
def create
if params[:referral] == false
super
else
user_info = GetOrCreateNonWaitlistedUser.call(user_params)
- 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 mark
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def mark
@tea_time = TeaTime.find(params[:id])
respond_to do |format|
case params[:marking]
when 'email'
- 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 sync_user
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def self.sync_user(user, new_record = false)
# Ensure the user is not deleted
if @sg and !user.deleted_at
# When a user email changes, we delete the old recipient record
# Then we can insert the new one with the updated email
- 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_list_from_segments
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.create_list_from_segments(name, segments, sample)
# Creates a SendGrid List corresponding to the union of the segments in
# `segments` and with a random sample of `sample` (which can be blank).
if @sg
all_recipients = get_recipients(segments).to_a
Method followup
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def followup(tea_time_id, attendances, status)
sendgrid_category "Tea Time Post-Attendance Followup: #{status}"
@tea_time = TeaTime.find(tea_time_id)
Method filter_tea_times
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def filter_tea_times(tea_times, next_month = false)
# Return an array of tea times filtered based on this select block.
tea_times.select { |tt|
if tt.city.nil? or tt.city.timezone.blank?
# If no city or city timezone information, include by default
- 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 mark
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def mark
@tea_time = TeaTime.find(params[:id])
respond_to do |format|
case params[:marking]
when 'email'
Method create
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
@user = current_user
@tea_time = TeaTime.find(params[:id])
@attendance = Attendance.where(tea_time_id: @tea_time.id, user_id: @user.id).first_or_initialize
Method send_mail
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def send_mail
# THE FORM DOESN'T PASS IN A TO FIELD, so that is always set to default
opts = {
subject: params[:mass_mail][:subject],
body: params[:mass_mail][:body],
Function shareBootstrap
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
var shareBootstrap = function() {
// Set click behavior of the "Try This On For Size" button
$('.sharing-try-button').on('click', function(e) {
// Advance share item index
currentShareItem++;
Method create
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def create
if user_signed_in?
city = City.new(params.require(:city).permit(:name))
city.timezone = "Pacific Time (US & Canada)" if !city.timezone
city.city_code = CityCodeGenerator.generate if !city.city_code
- 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 add_to_unsubscribe_group
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.add_to_unsubscribe_group(email)
if @sg
data = {'recipient_emails': [email]}
response = @sg.client.asm.groups._(ENV['SENDGRID_NEWSLETTER_UNSUB_GROUP']).suppressions.post(request_body: data)
if response.status_code == '201'
- 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 shareBootstrap
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
var shareBootstrap = function() {
// Set click behavior of the "Try This On For Size" button
$('.sharing-try-button').on('click', function(e) {
// Advance share item index
currentShareItem++;
- 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 send_mail
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def send_mail
# THE FORM DOESN'T PASS IN A TO FIELD, so that is always set to default
opts = {
subject: params[:mass_mail][:subject],
body: params[:mass_mail][: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 get_segment_recipients
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.get_segment_recipients(segment_id)
if @sg
puts 'Fetching segment %s' % [segment_id]
query_params = {page: 1, page_size: 1000}
- 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 newsletter_unsubscribe
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.newsletter_unsubscribe(email)
if @sg
# Make 3 attempts to unsubscribe
for attempt in 1..3 do
if add_to_unsubscribe_group(email)
- 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"