openSUSE/open-build-service

View on GitHub
src/api/app/controllers/webui/request_controller.rb

Summary

Maintainability
C
1 day
Test Coverage
D
65%

Class RequestController has 43 methods (exceeds 20 allowed). Consider refactoring.
Open

class Webui::RequestController < Webui::WebuiController
  helper 'webui/package'

  before_action :require_login,
                except: %i[show sourcediff diff request_action request_action_changes inline_comment build_results rpm_lint changes mentioned_issues]
Severity: Minor
Found in src/api/app/controllers/webui/request_controller.rb - About 5 hrs to fix

    Method changerequest has a Cognitive Complexity of 18 (exceeds 8 allowed). Consider refactoring.
    Open

      def changerequest
        changestate = (%w[accepted declined revoked new] & params.keys).last
    
        if change_state(changestate, params)
          # TODO: Make this work for each submit action individually
    Severity: Minor
    Found in src/api/app/controllers/webui/request_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

    Consider simplifying this complex logical expression.
    Open

        if Flipper.enabled?(:request_show_redesign, User.session)
          @history_elements = @bs_request.history_elements.includes(:user)
          @active_tab = 'conversation'
          render :beta_show
        else
    Severity: Critical
    Found in src/api/app/controllers/webui/request_controller.rb - About 1 hr to fix

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

        def show
          # TODO: Remove this `if` condition, and the `else` clause once request_show_redesign is rolled out
          if Flipper.enabled?(:request_show_redesign, User.session)
            @history_elements = @bs_request.history_elements.includes(:user)
            @active_tab = 'conversation'
      Severity: Minor
      Found in src/api/app/controllers/webui/request_controller.rb - About 1 hr to fix

        Method prepare_request_data has a Cognitive Complexity of 12 (exceeds 8 allowed). Consider refactoring.
        Wontfix

          def prepare_request_data
            @is_target_maintainer = @bs_request.is_target_maintainer?(User.session)
            @my_open_reviews = ReviewsFinder.new(@bs_request.reviews).open_reviews_for_user(User.session).reject(&:staging_project?)
        
            # Handling request actions
        Severity: Minor
        Found in src/api/app/controllers/webui/request_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

        Avoid deeply nested control flow statements.
        Confirmed

                  target.add_maintainer(@bs_request.creator) if target.can_be_modified_by?(User.possibly_nobody)
        Severity: Minor
        Found in src/api/app/controllers/webui/request_controller.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Confirmed

                    target = if tpkg
                               Package.find_by_project_and_name(tprj, tpkg)
                             else
                               Project.find_by_name(tprj)
                             end
          Severity: Minor
          Found in src/api/app/controllers/webui/request_controller.rb - About 45 mins to fix

            Method show has a Cognitive Complexity of 9 (exceeds 8 allowed). Consider refactoring.
            Open

              def show
                # TODO: Remove this `if` condition, and the `else` clause once request_show_redesign is rolled out
                if Flipper.enabled?(:request_show_redesign, User.session)
                  @history_elements = @bs_request.history_elements.includes(:user)
                  @active_tab = 'conversation'
            Severity: Minor
            Found in src/api/app/controllers/webui/request_controller.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