hpi-schuelerklub/workshop-portal

View on GitHub
app/models/event.rb

Summary

Maintainability
C
1 day
Test Coverage

Showing 10 of 10 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
Severity: Minor
Found in app/models/event.rb - About 5 hrs to fix

    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
    Severity: Minor
    Found in app/models/event.rb - About 1 hr to fix

    Avoid too many return statements within this method.
    Open

    return 1
    Severity: Major
    Found in app/models/event.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

      return -1 if participant2.agreement_letter_for_event?(self)
      Severity: Major
      Found in app/models/event.rb - About 30 mins to fix

        Method phase has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def phase
        return :draft unless published
        return :application if published && !after_deadline?
        return :selection if published && after_deadline? && !(acceptances_have_been_sent && rejections_have_been_sent)
        return :execution if published && after_deadline? && acceptances_have_been_sent && rejections_have_been_sent
        Severity: Minor
        Found in app/models/event.rb - About 25 mins to fix

        Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
        Open

        if participant_group.nil?
        Severity: Minor
        Found in app/models/event.rb by rubocop

        Avoid comparing a variable with multiple items in a conditional, use Array#include? instead.
        Open

        order_by = 'asc' unless order_by == 'asc' || order_by == 'desc'
        Severity: Minor
        Found in app/models/event.rb by rubocop

        Favor modifier unless usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
        Open

        unless participant2.requires_agreement_letter_for_event?(self)
        Severity: Minor
        Found in app/models/event.rb by rubocop

        Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
        Open

        if custom_image.filename.present? && errors[:custom_image].empty?
        Severity: Minor
        Found in app/models/event.rb by rubocop

        Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
        Open

        if participant2.agreement_letter_for_event?(self)
        Severity: Minor
        Found in app/models/event.rb by rubocop

        There are no issues that match your filters.

        Category
        Status