gitlabhq/gitlabhq

View on GitHub
app/controllers/projects/merge_requests_controller.rb

Summary

Maintainability
D
1 day
Test Coverage

Class MergeRequestsController has 39 methods (exceeds 20 allowed). Consider refactoring.
Open

class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationController
  include ToggleSubscriptionAction
  include IssuableActions
  include RendersNotes
  include RendersCommits
Severity: Minor
Found in app/controllers/projects/merge_requests_controller.rb - About 5 hrs to fix

    File merge_requests_controller.rb has 328 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationController
      include ToggleSubscriptionAction
      include IssuableActions
      include RendersNotes
      include RendersCommits
    Severity: Minor
    Found in app/controllers/projects/merge_requests_controller.rb - About 3 hrs to fix

      Method show has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        def show
          close_merge_request_if_no_source_project
          @merge_request.check_mergeability(async: true)
      
          respond_to do |format|
      Severity: Minor
      Found in app/controllers/projects/merge_requests_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

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

        def update
          @merge_request = ::MergeRequests::UpdateService.new(project, current_user, merge_request_update_params).execute(@merge_request)
      
          respond_to do |format|
            format.html do
      Severity: Minor
      Found in app/controllers/projects/merge_requests_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 merge! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def merge!
          # Disable the CI check if auto_merge_strategy is specified since we have
          # to wait until CI completes to know
          unless @merge_request.mergeable?(skip_ci_check: auto_merge_requested?)
            return :failed
      Severity: Minor
      Found in app/controllers/projects/merge_requests_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 show has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def show
          close_merge_request_if_no_source_project
          @merge_request.check_mergeability(async: true)
      
          respond_to do |format|
      Severity: Minor
      Found in app/controllers/projects/merge_requests_controller.rb - About 1 hr to fix

        There are no issues that match your filters.

        Category
        Status