Showing 23 of 208 total issues
Class Event
has 40 methods (exceeds 20 allowed). Consider refactoring. Open
class Event < ActiveRecord::Base
UNREASONABLY_LONG_DATE_SPAN = 300
TRUNCATE_DESCRIPTION_TEXT_LENGTH = 250
serialize :custom_application_fields, Array
Method download_agreement_letters
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def download_agreement_letters
@event = Event.find(params[:id])
unless params.key?(:selected_participants)
redirect_to(event_participants_url(@event), notice: I18n.t('events.agreement_letters_download.notices.no_participants_selected')) && return
end
- 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
Class EventsController
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
class EventsController < ApplicationController
include EventImageUploadHelper
load_and_authorize_resource
skip_authorize_resource only: %i(badges download_agreement_letters send_participants_email)
before_action :set_event, only: %i(show edit update destroy participants
File events_controller.rb
has 255 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'pdf_generation/badges_pdf'
require 'pdf_generation/applications_pdf'
require 'pdf_generation/participants_pdf'
require 'rubygems'
require 'zip'
Method download_agreement_letters
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
def download_agreement_letters
@event = Event.find(params[:id])
unless params.key?(:selected_participants)
redirect_to(event_participants_url(@event), notice: I18n.t('events.agreement_letters_download.notices.no_participants_selected')) && return
end
Method initialize
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(user)
# Define abilities for the passed in user here. For example:
#
# user ||= User.new # guest user (not logged in)
# if user.admin?
Function _init
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
_init : function() {
var callback = this.options.callback;
var selectValue = this.$select.val();
Method compare_participants_by_agreement
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def compare_participants_by_agreement(participant1, participant2)
unless participant1.requires_agreement_letter_for_event?(self)
unless participant2.requires_agreement_letter_for_event?(self)
return participant1.email <=> participant2.email
end
- 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 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
@application_letter = ApplicationLetter.new(application_params)
# event must be param to new_application_letter_path
seminar_name = ''
if params[:event_id]
Method new
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def new
if !current_user
message = I18n.t('application_letters.login_before_creation')
flash[:event_id] = params[:event_id]
flash.keep(:event_id)
Consider simplifying this complex logical expression. Open
if event.phase == :execution
(status_was == 'accepted' && status == 'canceled') || (status_was == 'alternative' && status == 'accepted') || (status_was == 'rejected' && status == 'accepted' && !event.has_alternative_application_letters?)
elsif event.phase == :selection && event.participant_selection_locked
false
else
Method status_change_allowed?
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def status_change_allowed?
if event.phase == :execution
(status_was == 'accepted' && status == 'canceled') || (status_was == 'alternative' && status == 'accepted') || (status_was == 'rejected' && status == 'accepted' && !event.has_alternative_application_letters?)
elsif event.phase == :selection && event.participant_selection_locked
false
- 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_missing_permission_flashes
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def add_missing_permission_flashes
if current_user
flash.now[:warning] ||= []
current_user.events_with_missing_agreement_letters.each do |event|
- 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_generic_email
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.send_generic_email(hide_recipients, recipients, reply_to, subject, content, attachments = [])
Method generic_email
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def generic_email(recipients, reply_to, subject, content, attached_files = [])
Function ajaxUpdateApplicationStatus
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function ajaxUpdateApplicationStatus(form, errorMessage) {
if (!window.FormData)
return form.submit();
var xhr = new XMLHttpRequest();
- 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 initialize
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def initialize(user)
# Define abilities for the passed in user here. For example:
#
# user ||= User.new # guest user (not logged in)
# if user.admin?
- 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
Avoid too many return
statements within this method. Open
return 1
Avoid too many return
statements within this method. Open
return -1 if participant2.agreement_letter_for_event?(self)
Method new
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def new
if !current_user
message = I18n.t('application_letters.login_before_creation')
flash[:event_id] = params[:event_id]
flash.keep(:event_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"