hpi-schuelerklub/workshop-portal

View on GitHub

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

    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
    Severity: Minor
    Found in app/controllers/events_controller.rb - About 3 hrs to fix

    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
    Severity: Minor
    Found in app/controllers/events_controller.rb - About 2 hrs to fix

      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'
      Severity: Minor
      Found in app/controllers/events_controller.rb - About 2 hrs to fix

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

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

            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();
            Severity: Minor
            Found in app/assets/javascripts/bootstrap-colorselector.js - About 1 hr 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

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

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

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

                    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
                    Severity: Minor
                    Found in app/models/application_letter.rb - About 45 mins to fix

                    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|
                    Severity: Minor
                    Found in app/controllers/application_controller.rb - About 45 mins to fix

                    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 = [])
                    Severity: Minor
                    Found in app/services/mailer.rb - About 45 mins to fix

                      Method generic_email has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                        def generic_email(recipients, reply_to, subject, content, attached_files = [])
                      Severity: Minor
                      Found in app/mailers/portal_mailer.rb - About 35 mins to fix

                        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();
                        Severity: Minor
                        Found in app/assets/javascripts/applications.js - About 35 mins to fix

                        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?
                        Severity: Minor
                        Found in app/models/ability.rb - About 35 mins to fix

                        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
                        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 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)
                            Severity: Minor
                            Found in app/controllers/application_letters_controller.rb - About 25 mins to fix

                            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

                            Severity
                            Category
                            Status
                            Source
                            Language