openSUSE/open-build-service

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

Summary

Maintainability
C
1 day
Test Coverage
C
72%

Method execute_accept has a Cognitive Complexity of 27 (exceeds 8 allowed). Consider refactoring.
Open

  def execute_accept(opts)
    # create package unless it exists already
    target_project = Project.get_by_name(self.target_project)

    # FIXME: when this code is moved to conditional assigment, it causes ambiguity between target_package and self.target_package.
Severity: Minor
Found in src/api/app/models/bs_request_action_submit.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 execute_accept has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def execute_accept(opts)
    # create package unless it exists already
    target_project = Project.get_by_name(self.target_project)

    # FIXME: when this code is moved to conditional assigment, it causes ambiguity between target_package and self.target_package.
Severity: Major
Found in src/api/app/models/bs_request_action_submit.rb - About 2 hrs to fix

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

      def forward
        forward_object = nil
        target_package_object = Package.find_by_project_and_name(target_project, target_package)
    
        if target_package_object
    Severity: Minor
    Found in src/api/app/models/bs_request_action_submit.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 forward has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def forward
        forward_object = nil
        target_package_object = Package.find_by_project_and_name(target_project, target_package)
    
        if target_package_object
    Severity: Minor
    Found in src/api/app/models/bs_request_action_submit.rb - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                  if forward[:project] == lprj && forward[:package] == lpkg
                    link_is_already_devel = true
                    break
                  end
      Severity: Minor
      Found in src/api/app/models/bs_request_action_submit.rb - About 45 mins to fix

        There are no issues that match your filters.

        Category
        Status