app/controllers/media_entries_controller.rb

Summary

Maintainability
C
1 day
Test Coverage

Method the_messy_before_filter has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
Open

  def the_messy_before_filter 
    if [:edit_multiple, :update_multiple, :remove_multiple].include? request[:action].to_sym
      begin
        if !params[:media_set_id].blank?
          action = case request[:action].to_sym
Severity: Minor
Found in app/controllers/media_entries_controller.rb - About 1 day 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 the_messy_before_filter has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def the_messy_before_filter 
    if [:edit_multiple, :update_multiple, :remove_multiple].include? request[:action].to_sym
      begin
        if !params[:media_set_id].blank?
          action = case request[:action].to_sym
Severity: Major
Found in app/controllers/media_entries_controller.rb - About 2 hrs to fix

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

      def update_multiple
        ActiveRecord::Base.transaction do
          @media_entries.each do |media_entry|
            meta_data_attributes= params[:resource].try(:[],'meta_data_attributes')
            to_be_updated_meta_data_attributes=
    Severity: Minor
    Found in app/controllers/media_entries_controller.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 check_and_initialize_for_view has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def check_and_initialize_for_view
        @media_entry = find_media_resource
        raise "Wrong type" unless @media_entry.is_a? MediaEntry
        raise UserUnauthorizedError if (logged_in? && current_user.login.nil?) && @media_entry.view == false
        raise UserForbiddenError unless current_user.try(:authorized?, :view, @media_entry) || @media_entry.view == true
    Severity: Minor
    Found in app/controllers/media_entries_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

    There are no issues that match your filters.

    Category
    Status