redmine/redmine

View on GitHub
app/controllers/timelog_controller.rb

Summary

Maintainability
C
1 day
Test Coverage

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

  def create
    @time_entry ||=
      TimeEntry.new(:project => @project, :issue => @issue,
                    :author => User.current, :user => User.current,
                    :spent_on => User.current.today)
Severity: Minor
Found in app/controllers/timelog_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

File timelog_controller.rb has 254 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class TimelogController < ApplicationController
  menu_item :time_entries

  before_action :find_time_entry, :only => [:show, :edit, :update]
  before_action :check_editability, :only => [:edit, :update]
Severity: Minor
Found in app/controllers/timelog_controller.rb - About 2 hrs to fix

    Method create has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def create
        @time_entry ||=
          TimeEntry.new(:project => @project, :issue => @issue,
                        :author => User.current, :user => User.current,
                        :spent_on => User.current.today)
    Severity: Minor
    Found in app/controllers/timelog_controller.rb - About 1 hr to fix

      Method destroy has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def destroy
          destroyed = TimeEntry.transaction do
            @time_entries.each do |t|
              unless t.destroy && t.destroyed?
                raise ActiveRecord::Rollback
      Severity: Minor
      Found in app/controllers/timelog_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 bulk_update has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def bulk_update
          attributes = parse_params_for_bulk_update(params[:time_entry])
      
          unsaved_time_entries = []
          saved_time_entries = []
      Severity: Minor
      Found in app/controllers/timelog_controller.rb - About 1 hr to fix

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

          def find_time_entries
            @time_entries = TimeEntry.where(:id => params[:id] || params[:ids]).
              preload(:project => :time_entry_activities).
              preload(:user).to_a
        
        
        Severity: Minor
        Found in app/controllers/timelog_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 bulk_update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def bulk_update
            attributes = parse_params_for_bulk_update(params[:time_entry])
        
            unsaved_time_entries = []
            saved_time_entries = []
        Severity: Minor
        Found in app/controllers/timelog_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