openSUSE/osem

View on GitHub

Showing 83 of 151 total issues

Method update has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def update
      authorize! :update, @conference.program
      @program = @conference.program
      params['program']['languages'] = params['program']['languages'].join(',') if params['program']['languages'].present?
      @program.assign_attributes(program_params)
Severity: Minor
Found in app/controllers/admin/programs_controller.rb - About 55 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 parse_template has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_template(text, values)
    values.each do |key, value|
      if value.kind_of?(Date)
        text = text.gsub "{#{key}}", value.strftime('%Y-%m-%d') unless text.blank?
      else
Severity: Minor
Found in app/models/email_settings.rb - About 55 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 active? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def active?
    return true unless start_date || end_date

    # Find timezone of conference (survyeable is Conference or Event)
    timezone = surveyable.is_a?(Conference) ? surveyable.timezone : surveyable.conference.timezone
Severity: Minor
Found in app/models/survey.rb - About 55 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 variant_from_delta has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def variant_from_delta(delta, reverse: false)
    if delta.to_i.positive?
      reverse ? 'warning' : 'success'
    elsif delta.to_i.negative?
      reverse ? 'success' : 'warning'
Severity: Minor
Found in app/helpers/format_helper.rb - About 55 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 state_dropdown has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def state_dropdown(event, conference_id, email_settings)
    selection = event.state.humanize
    options = []
    if event.transition_possible? :accept
      options << [
Severity: Minor
Found in app/helpers/events_helper.rb - About 55 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 mass_upload has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def mass_upload
      errors = Commercial.read_file(params[:file]) if params[:file]

      if !params[:file]
        flash[:error] = 'Empty file detected while adding commercials to Event'
Severity: Minor
Found in app/controllers/admin/commercials_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 handle has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def handle(provider)
      auth_hash = request.env['omniauth.auth']
      unless auth_hash.info.email.present?
        flash[:error] = "Email field is missing in your #{provider} account"
        redirect_to new_user_registration_path
Severity: Minor
Found in app/controllers/users/omniauth_callbacks_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 date_string has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def date_string(start_date, end_date)
    startstr = 'Unknown - '
    endstr = 'Unknown'
    # When the conference is in the same month
    if start_date.month == end_date.month && start_date.year == end_date.year
Severity: Minor
Found in app/helpers/application_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 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 destroy has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def destroy
      if can? :destroy, @question
        # Do not delete global questions
        if @question.global
          flash[:error] = 'You cannot delete global questions.'
Severity: Minor
Found in app/controllers/admin/questions_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 draw_second_square has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def draw_second_square
    move_up 150
    if @conference.picture?
      conference_image = case @conference.picture.ticket.url[0, 4]
                         when 'http', 'ftp:' # CDNs
Severity: Minor
Found in app/pdfs/ticket_pdf.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 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

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

        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
            Severity
            Category
            Status
            Source
            Language