app/controllers/media_resources_controller.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Method parents has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def parents()

    parent_media_set_ids = params[:parent_media_set_ids]
    parent_media_sets = MediaSet.accessible_by_user(current_user, :edit).find(parent_media_set_ids)
    child_resources = Array(@media_resource)
Severity: Minor
Found in app/controllers/media_resources_controller.rb - About 2 hrs 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 parents has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def parents()

    parent_media_set_ids = params[:parent_media_set_ids]
    parent_media_sets = MediaSet.accessible_by_user(current_user, :edit).find(parent_media_set_ids)
    child_resources = Array(@media_resource)
Severity: Minor
Found in app/controllers/media_resources_controller.rb - About 1 hr to fix

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

      def image(size = (params[:size] || :large).to_sym)
    
        if size == :maximum and not current_user.authorized? :download, @media_resource
          size = :x_large
        end
    Severity: Minor
    Found in app/controllers/media_resources_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 browse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def browse
        @browsable_meta_terms = []
        @media_resource.meta_data.for_meta_terms.each do |meta_datum|
          meta_datum.value.each do |meta_term|
            count = MediaResource.filter(current_user, {:meta_data => {meta_datum.meta_key.label.to_sym => {:ids => [meta_term.id]}}}).where("media_resources.id != ?", @media_resource.id).count
    Severity: Minor
    Found in app/controllers/media_resources_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 destroy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def destroy
        begin
          ActiveRecord::Base.transaction do
            if MediaResource.where(id: params[:id]).empty?
              render json: {}, status: 204
    Severity: Minor
    Found in app/controllers/media_resources_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

    There are no issues that match your filters.

    Category
    Status