openSUSE/open-build-service

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

Summary

Maintainability
F
1 wk
Test Coverage

Method create_expand_package has a Cognitive Complexity of 181 (exceeds 5 allowed). Consider refactoring.
Open

  def create_expand_package(packages, opts = {})
    newactions = []
    incident_suffix = ''
    if is_maintenance_release?
      # The maintenance ID is always the sub project name of the maintenance project
Severity: Minor
Found in src/api/app/models/bs_request_action.rb - About 3 days 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

File bs_request_action.rb has 686 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class BsRequestAction < ApplicationRecord
  #### Includes and extends
  include ParsePackageDiff
  include BsRequestAction::Errors
  #### Constants
Severity: Major
Found in src/api/app/models/bs_request_action.rb - About 1 day to fix

    Method create_expand_package has 190 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def create_expand_package(packages, opts = {})
        newactions = []
        incident_suffix = ''
        if is_maintenance_release?
          # The maintenance ID is always the sub project name of the maintenance project
    Severity: Major
    Found in src/api/app/models/bs_request_action.rb - About 7 hrs to fix

      Method check_action_permission! has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
      Open

        def check_action_permission!(skip_source = nil)
          # find objects if specified or report error
          role = nil
          sprj = nil
          if person_name
      Severity: Minor
      Found in src/api/app/models/bs_request_action.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

      Class BsRequestAction has 44 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class BsRequestAction < ApplicationRecord
        #### Includes and extends
        include ParsePackageDiff
        include BsRequestAction::Errors
        #### Constants
      Severity: Minor
      Found in src/api/app/models/bs_request_action.rb - About 6 hrs to fix

        Method default_reviewers has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
        Open

          def default_reviewers
            reviews = []
            return reviews unless target_project
        
            tprj = Project.get_by_name(target_project)
        Severity: Minor
        Found in src/api/app/models/bs_request_action.rb - About 5 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 store_from_xml has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

          def store_from_xml(hash)
            source = hash.delete('source')
            if source
              self.source_package = source.delete('package')
              self.source_project = source.delete('project')
        Severity: Minor
        Found in src/api/app/models/bs_request_action.rb - About 3 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_action_permission_target! has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

          def check_action_permission_target!
            return unless target_project
        
            tprj = Project.get_by_name(target_project)
            if tprj.is_a?(Project)
        Severity: Minor
        Found in src/api/app/models/bs_request_action.rb - About 3 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 expand_targets has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

          def expand_targets(ignore_build_state)
            # expand target_package
        
            if action_type.in?([:submit, :maintenance_incident])
              if target_package &&
        Severity: Minor
        Found in src/api/app/models/bs_request_action.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_sanity has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

          def check_sanity
            if action_type.in?([:submit, :maintenance_incident, :maintenance_release, :change_devel])
              errors.add(:source_project, "should not be empty for #{action_type} requests") if source_project.blank?
              unless is_maintenance_incident?
                errors.add(:source_package, "should not be empty for #{action_type} requests") if source_package.blank?
        Severity: Minor
        Found in src/api/app/models/bs_request_action.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_for_expand_errors! has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

          def check_for_expand_errors!(add_revision)
            return unless action_type.in?([:submit, :maintenance_incident, :maintenance_release])
        
            # validate that the sources are not broken
            begin
        Severity: Minor
        Found in src/api/app/models/bs_request_action.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 render_xml has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

          def render_xml(builder)
            builder.action(type: action_type) do |action|
              render_xml_attributes(action)
              if sourceupdate || updatelink || makeoriginolder
                action.options do
        Severity: Minor
        Found in src/api/app/models/bs_request_action.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 store_from_xml has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def store_from_xml(hash)
            source = hash.delete('source')
            if source
              self.source_package = source.delete('package')
              self.source_project = source.delete('project')
        Severity: Minor
        Found in src/api/app/models/bs_request_action.rb - About 1 hr to fix

          Method default_reviewers has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def default_reviewers
              reviews = []
              return reviews unless target_project
          
              tprj = Project.get_by_name(target_project)
          Severity: Minor
          Found in src/api/app/models/bs_request_action.rb - About 1 hr to fix

            Method check_action_permission! has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def check_action_permission!(skip_source = nil)
                # find objects if specified or report error
                role = nil
                sprj = nil
                if person_name
            Severity: Minor
            Found in src/api/app/models/bs_request_action.rb - About 1 hr to fix

              Method check_action_permission_source! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                def check_action_permission_source!
                  return unless source_project
              
                  sprj = Project.get_by_name(source_project)
                  raise UnknownProject, "Unknown source project #{source_project}" unless sprj
              Severity: Minor
              Found in src/api/app/models/bs_request_action.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 expand_targets has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def expand_targets(ignore_build_state)
                  # expand target_package
              
                  if action_type.in?([:submit, :maintenance_incident])
                    if target_package &&
              Severity: Minor
              Found in src/api/app/models/bs_request_action.rb - About 1 hr to fix

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

                  def check_action_permission_target!
                    return unless target_project
                
                    tprj = Project.get_by_name(target_project)
                    if tprj.is_a?(Project)
                Severity: Minor
                Found in src/api/app/models/bs_request_action.rb - About 1 hr to fix

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

                    def source_access_check!
                      sp = Package.find_by_project_and_name(source_project, source_package)
                      if sp.nil?
                        # either not there or read permission problem
                        if Package.exists_on_backend?(source_package, source_project)
                  Severity: Minor
                  Found in src/api/app/models/bs_request_action.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 source_cleanup has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def source_cleanup
                      source_project = Project.find_by_name(self.source_project)
                      return unless source_project
                      if (source_project.packages.count == 1 && ::Configuration.cleanup_empty_projects) || !source_package
                  
                  
                  Severity: Minor
                  Found in src/api/app/models/bs_request_action.rb - About 45 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 too many return statements within this method.
                  Open

                      return
                  Severity: Major
                  Found in src/api/app/models/bs_request_action.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                          return create_expand_package(packages, ignore_build_state: ignore_build_state),
                                 per_package_locking
                    Severity: Major
                    Found in src/api/app/models/bs_request_action.rb - About 30 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status