openSUSE/osem

View on GitHub

Showing 158 of 158 total issues

Class Conference has 81 methods (exceeds 20 allowed). Consider refactoring.
Open

class Conference < ApplicationRecord
  include RevisionCount
  require 'uri'
  serialize :events_per_week, Hash
  # Needed to call 'Conference.with_role' in /models/ability.rb
Severity: Major
Found in app/models/conference.rb - About 1 day to fix

    File conference.rb has 654 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class Conference < ApplicationRecord
      include RevisionCount
      require 'uri'
      serialize :events_per_week, Hash
      # Needed to call 'Conference.with_role' in /models/ability.rb
    Severity: Major
    Found in app/models/conference.rb - About 1 day to fix

      Method calendar has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
      Open

        def calendar
          respond_to do |format|
            format.ics do
              calendar = Icalendar::Calendar.new
              Conference.all.each do |conf|
      Severity: Minor
      Found in app/controllers/conferences_controller.rb - About 7 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

      Method icalendar_proposals has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

        def icalendar_proposals(calendar, proposals, conference)
          proposals.each do |proposal|
            calendar.event do |e|
              e.dtstart = proposal.time
              e.dtend = proposal.time + proposal.event_type.length * 60
      Severity: Minor
      Found in app/helpers/conference_helper.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 Event has 29 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class Event < ApplicationRecord
        include ActionView::Helpers::NumberHelper # for number_with_precision
        include ActiveRecord::Transitions
        include RevisionCount
        has_paper_trail on: [:create, :update], ignore: [:updated_at, :guid, :week], meta: { conference_id: :conference_id }
      Severity: Minor
      Found in app/models/event.rb - About 3 hrs to fix

        Class Program has 27 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class Program < ApplicationRecord
          has_paper_trail on: [:update], ignore: [:updated_at], meta: { conference_id: :conference_id }
        
          belongs_to :conference
        
        
        Severity: Minor
        Found in app/models/program.rb - About 3 hrs to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            $("#conference-start-datepicker").on("dp.change",function (e) {
                $('#conference-end-datepicker').data("DateTimePicker").minDate(e.date);
                if (!$('#conference-end-datepicker').val()) {
                   $('#conference-end-datepicker').data("DateTimePicker").date(e.date);
                }
          Severity: Major
          Found in app/assets/javascripts/osem-datepickers.js and 1 other location - About 3 hrs to fix
          app/assets/javascripts/osem-datepickers.js on lines 58..63

          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 96.

          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

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            $("#registration-period-start-datepicker").on("dp.change",function (e) {
                $('#registration-period-end-datepicker').data("DateTimePicker").minDate(e.date);
                if (!$('#registration-period-end-datepicker').val()) {
                   $('#registration-period-end-datepicker').data("DateTimePicker").date(e.date);
                }
          Severity: Major
          Found in app/assets/javascripts/osem-datepickers.js and 1 other location - About 3 hrs to fix
          app/assets/javascripts/osem-datepickers.js on lines 39..44

          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 96.

          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

          Further Reading

          Class User has 25 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class User < ApplicationRecord
            # prevent N+1 queries with has_cached_role? by preloading roles *always*
            default_scope { preload(:roles) }
          
            has_many :ticket_purchases, dependent: :destroy
          Severity: Minor
          Found in app/models/user.rb - About 2 hrs to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              $("#conference-end-datepicker").change(function (e) {
                  $('#conference-end-datepicker').val()?$('#conference-start-datepicker').data("DateTimePicker").maxDate(e.date):$('#conference-start-datepicker').data("DateTimePicker").maxDate(null);
              });
            Severity: Major
            Found in app/assets/javascripts/osem-datepickers.js and 1 other location - About 2 hrs to fix
            app/assets/javascripts/osem-datepickers.js on lines 46..48

            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 85.

            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

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              $("#conference-start-datepicker").change(function (e) {
                  $('#conference-start-datepicker').val()?$('#conference-end-datepicker').data("DateTimePicker").minDate(e.date):$('#conference-end-datepicker').data("DateTimePicker").minDate(null);
              });
            Severity: Major
            Found in app/assets/javascripts/osem-datepickers.js and 1 other location - About 2 hrs to fix
            app/assets/javascripts/osem-datepickers.js on lines 54..56

            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 85.

            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

            Further Reading

            Method signed_in_with_organizer_role has 55 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def signed_in_with_organizer_role(user, conf_ids_for_organization_admin = [])
                # ids of all the conferences for which the user has the 'organizer' role and
                # conferences that belong to organizations for which user is 'organization_admin'
                conf_ids = conf_ids_for_organization_admin.concat(Conference.with_role(:organizer, user).pluck(:id)).uniq
                # ids of all the tracks that belong to the programs of the above conferences
            Severity: Major
            Found in app/models/admin_ability.rb - About 2 hrs to fix

              Method state_dropdown has 53 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def state_dropdown(event, conference_id, email_settings)
                  selection = event.state.humanize
                  options = []
                  if event.transition_possible? :accept
                    options << [
              Severity: Major
              Found in app/helpers/events_helper.rb - About 2 hrs to fix

                Method show has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                  def show
                    event_schedules = @program.selected_event_schedules(
                      includes: [{ event: %i[event_type speakers submitter] }]
                    )
                
                
                Severity: Minor
                Found in app/controllers/schedules_controller.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 toggle_user has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                    def toggle_user
                      user = User.find_by(email: user_params[:email])
                      state = user_params[:state]
                
                      url = if @track
                Severity: Minor
                Found in app/controllers/admin/roles_controller.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 show has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                  def show
                    # load conference with header content
                    @conference = Conference.unscoped.eager_load(
                      :splashpage,
                      :program,
                Severity: Minor
                Found in app/controllers/conferences_controller.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 show has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def show
                    # load conference with header content
                    @conference = Conference.unscoped.eager_load(
                      :splashpage,
                      :program,
                Severity: Minor
                Found in app/controllers/conferences_controller.rb - About 1 hr to fix

                  Method overlapping has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def overlapping
                      return unless start_date && end_date && room && program.try(:tracks)
                  
                      (program.tracks.accepted + program.tracks.confirmed - [self]).each do |existing_track|
                        next unless existing_track.room == room && existing_track.start_date && existing_track.end_date
                  Severity: Minor
                  Found in app/models/track.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 signed_in has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def signed_in(user)
                      # Abilities from not_signed_in user are also inherited
                      not_signed_in
                      can :manage, User, id: user.id
                  
                  
                  Severity: Minor
                  Found in app/models/ability.rb - About 1 hr to fix

                    Method index has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def index
                          # Redirect to new form if there is no conference
                          if Conference.count == 0
                            redirect_to new_admin_conference_path
                            return
                    Severity: Minor
                    Found in app/controllers/admin/conferences_controller.rb - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language