MiraitSystems/enju_trunk

View on GitHub
app/controllers/loss_items_controller.rb

Summary

Maintainability
D
2 days
Test Coverage

Method create has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    LossItem.transaction do 
      flash[:notice] = ""
      @loss_item = LossItem.new(params[:loss_item])
      if params[:user_number]
Severity: Minor
Found in app/controllers/loss_items_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 set_list has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def set_list(obj, status)
    unless obj.blank?
      obj.each do |i|
        @same_items =  LossItem.where(:item_id => i.id) if obj == @items and status.blank?
        @same_items =  LossItem.where(:item_id => i.id, :status => status) if obj == @items and !status.blank?
Severity: Minor
Found in app/controllers/loss_items_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 create has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def create
    LossItem.transaction do 
      flash[:notice] = ""
      @loss_item = LossItem.new(params[:loss_item])
      if params[:user_number]
Severity: Major
Found in app/controllers/loss_items_controller.rb - About 2 hrs to fix

    Avoid deeply nested control flow statements.
    Open

                    messages << message if message
    Severity: Major
    Found in app/controllers/loss_items_controller.rb - About 45 mins to fix

      Method update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def update
          @loss_item = LossItem.find(params[:id])
          LossItem.transaction do 
            @loss_item.status = params[:loss_item][:status]
            @loss_item.note = params[:loss_item][:note]
      Severity: Minor
      Found in app/controllers/loss_items_controller.rb - About 35 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 index has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def index
          @count = {}
      
          search = Sunspot.new_search(Item)
          set_role_query(current_user, search)
      Severity: Minor
      Found in app/controllers/loss_items_controller.rb - About 35 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