Noosfero/noosfero

View on GitHub
plugins/orders_cycle/controllers/profile/orders_cycle_plugin_order_controller.rb

Summary

Maintainability
C
1 day
Test Coverage

Method edit has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

  def edit
    return show_more if params[:page].present?

    if request.xhr? && params[:order].present?
      status = params[:order][:status]

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 edit has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def edit
    return show_more if params[:page].present?

    if request.xhr? && params[:order].present?
      status = params[:order][:status]

    Method repeat has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def repeat
        @consumer = user
        @order = profile.orders_cycles_sales.where(id: params[:order_id], consumer_id: @consumer.id).first
        @cycle = profile.orders_cycles.find params[:cycle_id]
        if @order

    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

    Avoid too many return statements within this method.
    Open

          return render_access_denied unless @user_is_admin || @admin_edit || (user == @consumer)

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

        def filter
          if id = params[:id]
            @order = OrdersCyclePlugin::Sale.find id rescue nil
            @cycle = @order.cycle
          else

      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