Showing 35 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 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 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 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 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_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
Similar blocks of code found in 2 locations. Consider refactoring. Open
$('#tea-time-month-next').on('click', function(e) {
e.preventDefault();
$(this).closest('.month-display-container').removeClass('show-left').addClass('show-right');
});
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 63.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
$('#tea-time-month-prev').on('click', function(e) {
e.preventDefault();
$(this).closest('.month-display-container').removeClass('show-right').addClass('show-left');
});
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 63.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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++;
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 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 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 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"