openSUSE/osem

View on GitHub

Showing 151 of 151 total issues

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

  def update_state(transition, mail = false, subject = false, send_mail = false, send_mail_param)
    alert = ''
    if mail && send_mail_param && subject && send_mail
      alert = 'Update Email Subject before Sending Mails'
    end
Severity: Minor
Found in app/models/event.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 carousel_item_class has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def carousel_item_class(number, carousel_number, num_cols, col)
    item_class = 'item'
    item_class += ' first' if number == 0
    item_class += ' last' if number == (carousel_number - 1)
    if (col && ((col / num_cols) == number)) || (!col && number == 0)
Severity: Minor
Found in app/helpers/format_helper.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

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

    def update
      if @track.update(track_params)
        redirect_to admin_conference_program_tracks_path(conference_id: @conference.short_title),
                    notice: 'Track successfully updated.'
      else
Severity: Major
Found in app/controllers/admin/tracks_controller.rb and 10 other locations - About 25 mins to fix
app/controllers/admin/difficulty_levels_controller.rb on lines 30..37
app/controllers/admin/event_types_controller.rb on lines 28..35
app/controllers/admin/lodgings_controller.rb on lines 28..35
app/controllers/admin/resources_controller.rb on lines 27..34
app/controllers/admin/rooms_controller.rb on lines 28..35
app/controllers/admin/sponsors_controller.rb on lines 30..38
app/controllers/admin/sponsorship_levels_controller.rb on lines 29..37
app/controllers/admin/tickets_controller.rb on lines 31..38
app/controllers/admin/venues_controller.rb on lines 27..34
app/controllers/tracks_controller.rb on lines 33..40

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

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

    def destroy
      if @event_type.destroy
        redirect_to admin_conference_program_event_types_path(conference_id: @conference.short_title),
                    notice: 'Event type successfully deleted.'
      else
Severity: Major
Found in app/controllers/admin/event_types_controller.rb and 9 other locations - About 25 mins to fix
app/controllers/admin/difficulty_levels_controller.rb on lines 40..48
app/controllers/admin/lodgings_controller.rb on lines 38..46
app/controllers/admin/resources_controller.rb on lines 37..45
app/controllers/admin/rooms_controller.rb on lines 38..45
app/controllers/admin/schedules_controller.rb on lines 60..67
app/controllers/admin/sponsors_controller.rb on lines 41..49
app/controllers/admin/sponsorship_levels_controller.rb on lines 40..48
app/controllers/admin/tickets_controller.rb on lines 41..49
app/controllers/admin/tracks_controller.rb on lines 68..75

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

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

    def destroy
      if @sponsorship_level.destroy
        redirect_to admin_conference_sponsorship_levels_path(conference_id: @conference.short_title),
                    notice: 'Sponsorship level successfully deleted.'
      else
Severity: Major
Found in app/controllers/admin/sponsorship_levels_controller.rb and 9 other locations - About 25 mins to fix
app/controllers/admin/difficulty_levels_controller.rb on lines 40..48
app/controllers/admin/event_types_controller.rb on lines 38..46
app/controllers/admin/lodgings_controller.rb on lines 38..46
app/controllers/admin/resources_controller.rb on lines 37..45
app/controllers/admin/rooms_controller.rb on lines 38..45
app/controllers/admin/schedules_controller.rb on lines 60..67
app/controllers/admin/sponsors_controller.rb on lines 41..49
app/controllers/admin/tickets_controller.rb on lines 41..49
app/controllers/admin/tracks_controller.rb on lines 68..75

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

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

    def destroy
      if @ticket.destroy
        redirect_to admin_conference_tickets_path(conference_id: @conference.short_title),
                    notice: 'Ticket successfully destroyed.'
      else
Severity: Major
Found in app/controllers/admin/tickets_controller.rb and 9 other locations - About 25 mins to fix
app/controllers/admin/difficulty_levels_controller.rb on lines 40..48
app/controllers/admin/event_types_controller.rb on lines 38..46
app/controllers/admin/lodgings_controller.rb on lines 38..46
app/controllers/admin/resources_controller.rb on lines 37..45
app/controllers/admin/rooms_controller.rb on lines 38..45
app/controllers/admin/schedules_controller.rb on lines 60..67
app/controllers/admin/sponsors_controller.rb on lines 41..49
app/controllers/admin/sponsorship_levels_controller.rb on lines 40..48
app/controllers/admin/tracks_controller.rb on lines 68..75

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

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

    def destroy
      if @room.destroy
        redirect_to admin_conference_venue_rooms_path(conference_id: @conference.short_title),
                    notice: 'Room successfully deleted.'
      else
Severity: Major
Found in app/controllers/admin/rooms_controller.rb and 9 other locations - About 25 mins to fix
app/controllers/admin/difficulty_levels_controller.rb on lines 40..48
app/controllers/admin/event_types_controller.rb on lines 38..46
app/controllers/admin/lodgings_controller.rb on lines 38..46
app/controllers/admin/resources_controller.rb on lines 37..45
app/controllers/admin/schedules_controller.rb on lines 60..67
app/controllers/admin/sponsors_controller.rb on lines 41..49
app/controllers/admin/sponsorship_levels_controller.rb on lines 40..48
app/controllers/admin/tickets_controller.rb on lines 41..49
app/controllers/admin/tracks_controller.rb on lines 68..75

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

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

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

  def initialize(user)
    user ||= User.new

    if user.new_record?
      not_signed_in
Severity: Minor
Found in app/models/ability.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

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

    def destroy
      if @difficulty_level.destroy
        redirect_to admin_conference_program_difficulty_levels_path(conference_id: @conference.short_title),
                    notice: 'Difficulty level successfully deleted.'
      else
Severity: Major
Found in app/controllers/admin/difficulty_levels_controller.rb and 9 other locations - About 25 mins to fix
app/controllers/admin/event_types_controller.rb on lines 38..46
app/controllers/admin/lodgings_controller.rb on lines 38..46
app/controllers/admin/resources_controller.rb on lines 37..45
app/controllers/admin/rooms_controller.rb on lines 38..45
app/controllers/admin/schedules_controller.rb on lines 60..67
app/controllers/admin/sponsors_controller.rb on lines 41..49
app/controllers/admin/sponsorship_levels_controller.rb on lines 40..48
app/controllers/admin/tickets_controller.rb on lines 41..49
app/controllers/admin/tracks_controller.rb on lines 68..75

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

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

  def notify_on_venue_changed?
    return false unless conference.try(:email_settings).try(:send_on_venue_updated)
    # do not notify unless the address changed
    return false unless saved_change_to_name? || saved_change_to_street? || saved_change_to_city? || saved_change_to_country?

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

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

    def update
      if @ticket.update(ticket_params)
        redirect_to admin_conference_tickets_path(conference_id: @conference.short_title),
                    notice: 'Ticket successfully updated.'
      else
Severity: Major
Found in app/controllers/admin/tickets_controller.rb and 10 other locations - About 25 mins to fix
app/controllers/admin/difficulty_levels_controller.rb on lines 30..37
app/controllers/admin/event_types_controller.rb on lines 28..35
app/controllers/admin/lodgings_controller.rb on lines 28..35
app/controllers/admin/resources_controller.rb on lines 27..34
app/controllers/admin/rooms_controller.rb on lines 28..35
app/controllers/admin/sponsors_controller.rb on lines 30..38
app/controllers/admin/sponsorship_levels_controller.rb on lines 29..37
app/controllers/admin/tracks_controller.rb on lines 58..65
app/controllers/admin/venues_controller.rb on lines 27..34
app/controllers/tracks_controller.rb on lines 33..40

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

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

    def update
      if @lodging.update(lodging_params)
        redirect_to admin_conference_lodgings_path(conference_id: @conference.short_title),
                    notice: 'Lodging successfully updated.'
      else
Severity: Major
Found in app/controllers/admin/lodgings_controller.rb and 10 other locations - About 25 mins to fix
app/controllers/admin/difficulty_levels_controller.rb on lines 30..37
app/controllers/admin/event_types_controller.rb on lines 28..35
app/controllers/admin/resources_controller.rb on lines 27..34
app/controllers/admin/rooms_controller.rb on lines 28..35
app/controllers/admin/sponsors_controller.rb on lines 30..38
app/controllers/admin/sponsorship_levels_controller.rb on lines 29..37
app/controllers/admin/tickets_controller.rb on lines 31..38
app/controllers/admin/tracks_controller.rb on lines 58..65
app/controllers/admin/venues_controller.rb on lines 27..34
app/controllers/tracks_controller.rb on lines 33..40

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

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

    def destroy
      if @lodging.destroy
        redirect_to admin_conference_lodgings_path(conference_id: @conference.short_title),
                    notice: 'Lodging successfully deleted.'
      else
Severity: Major
Found in app/controllers/admin/lodgings_controller.rb and 9 other locations - About 25 mins to fix
app/controllers/admin/difficulty_levels_controller.rb on lines 40..48
app/controllers/admin/event_types_controller.rb on lines 38..46
app/controllers/admin/resources_controller.rb on lines 37..45
app/controllers/admin/rooms_controller.rb on lines 38..45
app/controllers/admin/schedules_controller.rb on lines 60..67
app/controllers/admin/sponsors_controller.rb on lines 41..49
app/controllers/admin/sponsorship_levels_controller.rb on lines 40..48
app/controllers/admin/tickets_controller.rb on lines 41..49
app/controllers/admin/tracks_controller.rb on lines 68..75

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

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

  def after_sign_in_path_for(_resource)
    if (can? :view, Conference) &&
      (!session[:return_to] ||
      session[:return_to] &&
      session[:return_to] == root_path)
Severity: Minor
Found in app/controllers/application_controller.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 confirm has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def confirm
    authorize! :update, @event
    @url = conference_program_proposal_path(@conference.short_title, params[:id])

    begin
Severity: Minor
Found in app/controllers/proposals_controller.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

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

    def update
      if @resource.update(resource_params)
        redirect_to admin_conference_resources_path(conference_id: @conference.short_title),
                    notice: 'Resource successfully updated.'
      else
Severity: Major
Found in app/controllers/admin/resources_controller.rb and 10 other locations - About 25 mins to fix
app/controllers/admin/difficulty_levels_controller.rb on lines 30..37
app/controllers/admin/event_types_controller.rb on lines 28..35
app/controllers/admin/lodgings_controller.rb on lines 28..35
app/controllers/admin/rooms_controller.rb on lines 28..35
app/controllers/admin/sponsors_controller.rb on lines 30..38
app/controllers/admin/sponsorship_levels_controller.rb on lines 29..37
app/controllers/admin/tickets_controller.rb on lines 31..38
app/controllers/admin/tracks_controller.rb on lines 58..65
app/controllers/admin/venues_controller.rb on lines 27..34
app/controllers/tracks_controller.rb on lines 33..40

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

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

    def update
      if @sponsor.update(sponsor_params)
        redirect_to admin_conference_sponsors_path(
                    conference_id: @conference.short_title),
                    notice: 'Sponsor successfully updated.'
Severity: Major
Found in app/controllers/admin/sponsors_controller.rb and 10 other locations - About 25 mins to fix
app/controllers/admin/difficulty_levels_controller.rb on lines 30..37
app/controllers/admin/event_types_controller.rb on lines 28..35
app/controllers/admin/lodgings_controller.rb on lines 28..35
app/controllers/admin/resources_controller.rb on lines 27..34
app/controllers/admin/rooms_controller.rb on lines 28..35
app/controllers/admin/sponsorship_levels_controller.rb on lines 29..37
app/controllers/admin/tickets_controller.rb on lines 31..38
app/controllers/admin/tracks_controller.rb on lines 58..65
app/controllers/admin/venues_controller.rb on lines 27..34
app/controllers/tracks_controller.rb on lines 33..40

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

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

Severity
Category
Status
Source
Language