openSUSE/open-build-service

View on GitHub
src/api/app/models/bs_request_permission_check.rb

Summary

Maintainability
D
2 days
Test Coverage
A
95%

Method cmd_changestate_permissions has a Cognitive Complexity of 51 (exceeds 8 allowed). Consider refactoring.
Open

  def cmd_changestate_permissions
    # We do not support to revert changes from accepted requests (yet)
    raise PostRequestNoPermission, 'change state from an accepted state is not allowed.' if req.state == :accepted

    # need to check for accept permissions
Severity: Minor
Found in src/api/app/models/bs_request_permission_check.rb - About 7 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 set_permissions_for_action has a Cognitive Complexity of 21 (exceeds 8 allowed). Consider refactoring.
Open

  def set_permissions_for_action(action, new_state = nil)
    # general write permission check on the target on accept
    @write_permission_in_this_action = false

    # all action types need a target project in any case for accept
Severity: Minor
Found in src/api/app/models/bs_request_permission_check.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 check_accepted_action has a Cognitive Complexity of 18 (exceeds 8 allowed). Consider refactoring.
Open

  def check_accepted_action(action)
    raise NotExistingTarget, "Unable to process project #{action.target_project}; it does not exist." unless @target_project

    check_action_target(action)

Severity: Minor
Found in src/api/app/models/bs_request_permission_check.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 cmd_changestate_permissions has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def cmd_changestate_permissions
    # We do not support to revert changes from accepted requests (yet)
    raise PostRequestNoPermission, 'change state from an accepted state is not allowed.' if req.state == :accepted

    # need to check for accept permissions
Severity: Minor
Found in src/api/app/models/bs_request_permission_check.rb - About 1 hr to fix

    Method extra_permissions_check_changestate has a Cognitive Complexity of 17 (exceeds 8 allowed). Consider refactoring.
    Open

      def extra_permissions_check_changestate
        err =
          case opts[:newstate]
          when 'superseded'
            # Is the user involved in any project or package ?
    Severity: Minor
    Found in src/api/app/models/bs_request_permission_check.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 cmd_changereviewstate_permissions has a Cognitive Complexity of 17 (exceeds 8 allowed). Consider refactoring.
    Open

      def cmd_changereviewstate_permissions
        # Basic validations of given parameters
        by_user = User.find_by_login!(opts[:by_user]) if opts[:by_user]
        by_group = Group.find_by_title!(opts[:by_group]) if opts[:by_group]
        if opts[:by_project] && opts[:by_package]
    Severity: Minor
    Found in src/api/app/models/bs_request_permission_check.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 check_maintenance_release_accept has a Cognitive Complexity of 16 (exceeds 8 allowed). Consider refactoring.
    Open

      def check_maintenance_release_accept(action)
        if action.source_rev
          # FIXME2.4 we have a directory model
          c = Backend::Api::Sources::Package.files(action.source_project, action.source_package, expand: 1)
          data = REXML::Document.new(c)
    Severity: Minor
    Found in src/api/app/models/bs_request_permission_check.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 set_permissions_for_action has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def set_permissions_for_action(action, new_state = nil)
        # general write permission check on the target on accept
        @write_permission_in_this_action = false
    
        # all action types need a target project in any case for accept
    Severity: Minor
    Found in src/api/app/models/bs_request_permission_check.rb - About 1 hr to fix

      Method check_action_target has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
      Open

        def check_action_target(action)
          return unless action.action_type.in?(%i[submit change_devel maintenance_release maintenance_incident])
      
          raise PostRequestNoPermission, "Target package is missing in request #{action.bs_request.number} (type #{action.action_type})" if action.action_type == :change_devel && !action.target_package
      
      
      Severity: Minor
      Found in src/api/app/models/bs_request_permission_check.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 cmd_setincident_permissions has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
      Open

        def cmd_setincident_permissions
          raise ReviewChangeStateNoPermission, 'The request is not in state new or review' unless req.state.in?(%i[review new])
      
          req.bs_request_actions.each do |action|
            set_permissions_for_action(action)
      Severity: Minor
      Found in src/api/app/models/bs_request_permission_check.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

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

        def check_delete_accept(action)
          if @target_package
            return if opts.include?(:force) && opts[:force].in?([nil, '1'])
      
            @target_package.check_weak_dependencies!
      Severity: Minor
      Found in src/api/app/models/bs_request_permission_check.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