redmine/redmine

View on GitHub
app/models/time_entry_query.rb

Summary

Maintainability
C
1 day
Test Coverage

Method initialize_available_filters has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def initialize_available_filters
    add_available_filter "spent_on", :type => :date_past
    add_available_filter(
      "project_id",
      :type => :list, :values => lambda {project_values}
Severity: Major
Found in app/models/time_entry_query.rb - About 2 hrs to fix

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

    class TimeEntryQuery < Query
      self.queried_class = TimeEntry
      self.view_permission = :view_time_entries
    
      self.available_columns = [
    Severity: Minor
    Found in app/models/time_entry_query.rb - About 2 hrs to fix

      Method joins_for_order_statement has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def joins_for_order_statement(order_options)
          joins = [super]
      
          if order_options
            if order_options.include?('issue_statuses')
      Severity: Minor
      Found in app/models/time_entry_query.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 sql_for_issue_parent_id_field has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def sql_for_issue_parent_id_field(field, operator, value)
          case operator
          when "="
            # accepts a comma separated list of ids
            parent_ids = value.first.to_s.scan(/\d+/).map(&:to_i).uniq
      Severity: Minor
      Found in app/models/time_entry_query.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 initialize_available_filters has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def initialize_available_filters
          add_available_filter "spent_on", :type => :date_past
          add_available_filter(
            "project_id",
            :type => :list, :values => lambda {project_values}
      Severity: Minor
      Found in app/models/time_entry_query.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 sql_for_issue_fixed_version_id_field has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def sql_for_issue_fixed_version_id_field(field, operator, value)
          issue_ids = Issue.where(:fixed_version_id => value.map(&:to_i)).pluck(:id)
          case operator
          when "="
            if issue_ids.any?
      Severity: Minor
      Found in app/models/time_entry_query.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