openSUSE/osem

View on GitHub

Showing 151 of 151 total issues

Method read_file has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def self.read_file(file)
    errors = {}
    errors[:no_event] = []
    errors[:validation_errors] = []

Severity: Minor
Found in app/models/commercial.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

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

    def update
      @cfp.assign_attributes(cfp_params)

      send_mail_on_cfp_dates_updates = @cfp.notify_on_cfp_date_update?

Severity: Minor
Found in app/controllers/admin/cfps_controller.rb and 1 other location - About 45 mins to fix
app/controllers/admin/registration_periods_controller.rb on lines 26..38

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

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 omniauth_configured has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def omniauth_configured
    return Devise.omniauth_providers if OmniAuth.config.test_mode

    providers = []
    Devise.omniauth_providers.each do |provider|
Severity: Minor
Found in app/helpers/users_helper.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 valid_times_range? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def valid_times_range?
    if start_hour && end_hour
      errors.add(:start_hour, 'is lower than 0') if start_hour < 0
      errors.add(:end_hour, 'is lower or equal than start hour') if end_hour <= start_hour
      errors.add(:end_hour, 'is greater than 24') if end_hour > 24
Severity: Minor
Found in app/models/conference.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 notify_on_registration_dates_changed? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def notify_on_registration_dates_changed?
    return false unless email_settings.send_on_conference_registration_dates_updated
    # do not notify unless we allow a registration
    return false unless registration_period
    # do not notify unless one of the dates changed
Severity: Minor
Found in app/models/conference.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

Consider simplifying this complex logical expression.
Open

      if start_date >= existing_track.start_date && start_date <= existing_track.end_date ||
         end_date >= existing_track.start_date && end_date <= existing_track.end_date ||
         start_date <= existing_track.start_date && end_date >= existing_track.end_date
        errors.add(:track, 'has overlapping dates with a confirmed or accepted track in the same room')
        break
Severity: Major
Found in app/models/track.rb - About 40 mins to fix

    Consider simplifying this complex logical expression.
    Open

        return true if facebook.present? || twitter.present? || googleplus.present? || instagram.present? || mastodon.present? || email.present?
    Severity: Major
    Found in app/models/contact.rb - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

            unless (current_user.has_cached_role? :organizer, :any) || (current_user.has_cached_role? :cfp, :any) ||
                   (current_user.has_cached_role? :info_desk, :any) || (current_user.has_cached_role? :volunteers_coordinator, :any) ||
                   (current_user.has_cached_role? :track_organizer, :any) || current_user.is_admin
              raise CanCan::AccessDenied.new('You are not authorized to access this page.')
            end
      Severity: Major
      Found in app/controllers/admin/base_controller.rb - About 40 mins to fix

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

          def start_before_start_hour
            return unless event && start_time && event.program && event.program.conference && event.program.conference.start_hour
        
            errors.add(:start_time, "can't be before the conference start hour (#{event.program.conference.start_hour})") if start_time.hour < event.program.conference.start_hour
        Severity: Minor
        Found in app/models/event_schedule.rb and 1 other location - About 40 mins to fix
        app/models/event_schedule.rb on lines 84..87

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

        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

          def start_after_end_hour
            return unless event && start_time && event.program && event.program.conference && event.program.conference.end_hour
        
            errors.add(:start_time, "can't be after the conference end hour (#{event.program.conference.end_hour})") if start_time.hour >= event.program.conference.end_hour
        Severity: Minor
        Found in app/models/event_schedule.rb and 1 other location - About 40 mins to fix
        app/models/event_schedule.rb on lines 90..93

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

        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 update_state has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def update_state(transition, mail = false, subject = false, send_mail = false, send_mail_param)
        Severity: Minor
        Found in app/models/event.rb - About 35 mins to fix

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

              def update_state(transition, notice, mail = false, subject = false, send_mail = false)
          Severity: Minor
          Found in app/controllers/admin/events_controller.rb - About 35 mins to fix

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

              def initialize(conference, user, physical_ticket, ticket_layout, file_name)
            Severity: Minor
            Found in app/pdfs/ticket_pdf.rb - About 35 mins to fix

              Method dates_within_conference_dates has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def dates_within_conference_dates
                  return unless start_date && end_date && program.try(:conference).try(:start_date) && program.try(:conference).try(:end_date)
              
                  errors.add(:start_date, "can't be outside of the conference's dates (#{program.conference.start_date}-#{program.conference.end_date})") unless (program.conference.start_date..program.conference.end_date).cover?(start_date)
                  errors.add(:end_date, "can't be outside of the conference's dates (#{program.conference.start_date}-#{program.conference.end_date})") unless (program.conference.start_date..program.conference.end_date).cover?(end_date)
              Severity: Minor
              Found in app/models/track.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

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

                  def show
                    @event_schedules = @schedule.event_schedules.eager_load(
                      room:  :tracks,
                      event: [
                        :difficulty_level,
              Severity: Minor
              Found in app/controllers/admin/schedules_controller.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

              Method revert_object has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def revert_object
                    if @version.event != 'create'
                      if @version.reify.save
                        flash[:notice] = 'The selected change was successfully reverted'
                      else
              Severity: Minor
              Found in app/controllers/admin/versions_controller.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

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

                  def create
                    @event_type = @conference.program.event_types.new(event_type_params)
                    if @event_type.save
                      redirect_to admin_conference_program_event_types_path(conference_id: @conference.short_title),
                                  notice: 'Event type successfully created.'
              Severity: Minor
              Found in app/controllers/admin/event_types_controller.rb and 1 other location - About 35 mins to fix
              app/controllers/admin/difficulty_levels_controller.rb on lines 19..27

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

              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

                  def create
                    @difficulty_level = @conference.program.difficulty_levels.new(difficulty_level_params)
                    if @difficulty_level.save
                      redirect_to admin_conference_program_difficulty_levels_path(conference_id: @conference.short_title),
                                  notice: 'Difficulty level successfully created.'
              Severity: Minor
              Found in app/controllers/admin/difficulty_levels_controller.rb and 1 other location - About 35 mins to fix
              app/controllers/admin/event_types_controller.rb on lines 17..25

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

              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 current_or_last_object_state has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def current_or_last_object_state(model_name, id)
                  return nil unless id.present? && model_name.present?
              
                  begin
                    object = model_name.constantize.find_by(id: id)
              Severity: Minor
              Found in app/helpers/versions_helper.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

              Method create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def create
                  current_user.ticket_purchases.by_conference(@conference).unpaid.destroy_all
                  message = TicketPurchase.purchase(@conference, current_user, params[:tickets].try(:first))
                  if message.blank?
                    if current_user.ticket_purchases.by_conference(@conference).unpaid.any?
              Severity: Minor
              Found in app/controllers/ticket_purchases_controller.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

              Severity
              Category
              Status
              Source
              Language