gitlabhq/gitlabhq

View on GitHub
app/services/issuable_base_service.rb

Summary

Maintainability
C
1 day
Test Coverage

Class IssuableBaseService has 36 methods (exceeds 20 allowed). Consider refactoring.
Open

class IssuableBaseService < BaseService
  private

  attr_accessor :params, :skip_milestone_email

Severity: Minor
Found in app/services/issuable_base_service.rb - About 4 hrs to fix

    File issuable_base_service.rb has 293 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class IssuableBaseService < BaseService
      private
    
      attr_accessor :params, :skip_milestone_email
    
    
    Severity: Minor
    Found in app/services/issuable_base_service.rb - About 3 hrs to fix

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

        def update(issuable)
          change_state(issuable)
          change_subscription(issuable)
          change_todo(issuable)
          toggle_award(issuable)
      Severity: Minor
      Found in app/services/issuable_base_service.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 update has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def update(issuable)
          change_state(issuable)
          change_subscription(issuable)
          change_todo(issuable)
          toggle_award(issuable)
      Severity: Minor
      Found in app/services/issuable_base_service.rb - About 1 hr to fix

        Method process_label_ids has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          def process_label_ids(attributes, existing_label_ids: nil, extra_label_ids: [])
            label_ids = attributes.delete(:label_ids)
            add_label_ids = attributes.delete(:add_label_ids)
            remove_label_ids = attributes.delete(:remove_label_ids)
        
        
        Severity: Minor
        Found in app/services/issuable_base_service.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 filter_assignee has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def filter_assignee(issuable)
            return if params[:assignee_ids].blank?
        
            unless issuable.allows_multiple_assignees?
              params[:assignee_ids] = params[:assignee_ids].first(1)
        Severity: Minor
        Found in app/services/issuable_base_service.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