openSUSE/open-build-service

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

Summary

Maintainability
C
1 day
Test Coverage
D
63%

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

class Webui::RequestController < Webui::WebuiController
  include Webui::NotificationsHandler
  include Webui::RequestsFilter
  include BuildNewComment

Severity: Minor
Found in src/api/app/controllers/webui/request_controller.rb - About 5 hrs to fix

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

      def changerequest
        changestate = (%w[accepted commented declined revoked new] & params.keys).last
    
        if changestate == 'commented'
    
    
    Severity: Minor
    Found in src/api/app/controllers/webui/request_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 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

        There are no issues that match your filters.

        Category
        Status