openSUSE/osem

View on GitHub

Showing 151 of 151 total issues

Method link_to_user has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def link_to_user(user_id)
    return 'Someone (probably via the console)' unless user_id

    user = User.find_by(id: user_id)
    if user
Severity: Minor
Found in app/helpers/versions_helper.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 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def create
    @url = conference_program_proposals_path(@conference.short_title)

    # We allow proposal submission and sign up on same page.
    # If user is not signed in then first create new user and then sign them in
Severity: Minor
Found in app/controllers/proposals_controller.rb - About 1 hr to fix

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

      def registration_change_description(version)
        if version.item_type == 'Registration'
          user_id = current_or_last_object_state(version.item_type, version.item_id).user_id
        elsif version.item_type == 'EventsRegistration'
          registration_id = current_or_last_object_state(version.item_type, version.item_id).registration_id
    Severity: Minor
    Found in app/helpers/versions_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 check_languages_format has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def check_languages_format
        return unless languages.present?
    
        # All white spaces are removed to allow languages to be separated by ',' and ', '. The languages string without spaces is saved
        self.languages = languages.delete(' ').downcase
    Severity: Minor
    Found in app/models/program.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 concurrent_events has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def concurrent_events(event)
        return nil unless event.scheduled? && event.program.selected_event_schedules
    
        event_schedule = event.program.selected_event_schedules.find { |es| es.event == event }
        other_event_schedules = event.program.selected_event_schedules.reject { |other_event_schedule| other_event_schedule == event_schedule }
    Severity: Minor
    Found in app/helpers/application_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 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

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

        $('a:contains("Add track")').click(function () {
            setTimeout(function () {
                    $("div.nested-fields:last div:nth-of-type(2) input").val(get_color());
                },
                5)
    Severity: Major
    Found in app/assets/javascripts/osem.js and 2 other locations - About 50 mins to fix
    app/assets/javascripts/osem.js on lines 108..113
    app/assets/javascripts/osem.js on lines 115..120

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

    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 3 locations. Consider refactoring.
    Open

        $('a:contains("Add event_type")').click(function () {
            setTimeout(function () {
                    $("div.nested-fields:last div:nth-of-type(5) input").val(get_color());
                },
                5)
    Severity: Major
    Found in app/assets/javascripts/osem.js and 2 other locations - About 50 mins to fix
    app/assets/javascripts/osem.js on lines 101..106
    app/assets/javascripts/osem.js on lines 108..113

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

    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 3 locations. Consider refactoring.
    Open

        $('a:contains("Add difficulty_level")').click(function () {
            setTimeout(function () {
                    $("div.nested-fields:last div:nth-of-type(3) input").val(get_color());
                },
                5)
    Severity: Major
    Found in app/assets/javascripts/osem.js and 2 other locations - About 50 mins to fix
    app/assets/javascripts/osem.js on lines 101..106
    app/assets/javascripts/osem.js on lines 115..120

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

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

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

        def update
          @registration_period.assign_attributes(registration_period_params)
          send_mail_on_reg_update = @conference.notify_on_registration_dates_changed?
    
          if @registration_period.update(registration_period_params)
    Severity: Minor
    Found in app/controllers/admin/registration_periods_controller.rb and 1 other location - About 45 mins to fix
    app/controllers/admin/cfps_controller.rb on lines 33..45

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

    Severity
    Category
    Status
    Source
    Language