fernandokosh/redmine_time_tracker

View on GitHub
app/controllers/time_trackers_controller.rb

Summary

Maintainability
C
1 day
Test Coverage

Method start has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

  def start(args = {})
    default_args= {:issue_id => nil, :comments => nil, :activity_id => nil, :project_id => nil}
    args = default_args.merge(args)

    @time_tracker = get_current
Severity: Minor
Found in app/controllers/time_trackers_controller.rb - About 4 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 stop has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def stop
    @time_tracker = get_current
    if @time_tracker.new_record?
      flash[:error] = l(:no_time_tracker_running)
      unless request.xhr?
Severity: Minor
Found in app/controllers/time_trackers_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 start has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def start(args = {})
    default_args= {:issue_id => nil, :comments => nil, :activity_id => nil, :project_id => nil}
    args = default_args.merge(args)

    @time_tracker = get_current
Severity: Minor
Found in app/controllers/time_trackers_controller.rb - About 1 hr to fix

    Method stop has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def stop
        @time_tracker = get_current
        if @time_tracker.new_record?
          flash[:error] = l(:no_time_tracker_running)
          unless request.xhr?
    Severity: Minor
    Found in app/controllers/time_trackers_controller.rb - About 1 hr to fix

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

        def delete
          time_tracker = TimeTracker.where(:id => params[:id]).first
          if User.current.id == time_tracker.user_id && User.current.allowed_to?([:tt_edit_own_time_logs], {}) || User.current.allowed_to_globally?([:tt_edit_time_logs], {}) # user could only delete his own entries, except he's admin
            time_tracker.destroy
          else
      Severity: Minor
      Found in app/controllers/time_trackers_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 update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def update
          @time_tracker = get_current
          @time_tracker.update_attributes!(params[:time_tracker])
          flash[:notice] = l(:update_time_tracker_success)
          unless request.xhr?
      Severity: Minor
      Found in app/controllers/time_trackers_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 error_handling has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def error_handling
          yield
        rescue StandardError => e
          flash[:error] = e.message
          unless request.xhr?
      Severity: Minor
      Found in app/controllers/time_trackers_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