openSUSE/osem

View on GitHub
app/models/conference.rb

Summary

Maintainability
F
3 days
Test Coverage

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

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

        def get_events_per_week_by_state
          result = {
            'Submitted'   => {},
            'Confirmed'   => {},
            'Unconfirmed' => {}
      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 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 get_submissions_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def get_submissions_data
          return [] unless program&.cfp && program&.events
      
          start_week = program.cfp.start_week
          get_events_per_week_by_state.collect do |state, values|
      Severity: Minor
      Found in app/models/conference.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

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

        def affiliation_distribution
          counted_affiliations = registrations.joins(:user).group(:affiliation).count
          result = {}
          i = 1
          others = 0
      Severity: Minor
      Found in app/models/conference.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

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

        def notify_on_dates_changed?
          return false unless email_settings.send_on_conference_dates_updated
          # do not notify unless one of the dates changed
          return false unless saved_change_to_start_date? || saved_change_to_end_date?
      
      
      Severity: Minor
      Found in app/models/conference.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

      There are no issues that match your filters.

      Category
      Status