hicknhack-software/redmine_time_tracker

View on GitHub
app/models/time_booking.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Class TimeBooking has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

class TimeBooking < ActiveRecord::Base
  include Redmine::I18n

  attr_accessible :started_on, :stopped_at, :time_entry_id, :time_log_id, :project, :project_id, :comments, :issue, :activity_id
  belongs_to :project
Severity: Minor
Found in app/models/time_booking.rb - About 2 hrs to fix

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

      def project=(project)
        return if project == self.project # no validation or permission checks necessary if there are no changes!
        raise StandardError, l(:tt_error_not_allowed_to_book_without_project) if project.nil?
    
        # workaround to get dirty-flag working even for associated fields!
    Severity: Minor
    Found in app/models/time_booking.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

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

      def issue=(issue)
        return if issue == self.issue # no validation or permission checks necessary if there are no changes!
    
        # check if project has to be updated also!
        unless issue.nil?
    Severity: Minor
    Found in app/models/time_booking.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