openSUSE/open-build-service

View on GitHub
src/api/app/controllers/build_controller.rb

Summary

Maintainability
C
1 day
Test Coverage
B
83%

Method project_index has a Cognitive Complexity of 44 (exceeds 8 allowed). Consider refactoring.
Open

  def project_index
    prj = nil
    prj = Project.get_by_name(params[:project]) unless params[:project] == '_dispatchprios'

    if request.get?
Severity: Minor
Found in src/api/app/controllers/build_controller.rb - About 6 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 project_index has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def project_index
    prj = nil
    prj = Project.get_by_name(params[:project]) unless params[:project] == '_dispatchprios'

    if request.get?
Severity: Major
Found in src/api/app/controllers/build_controller.rb - About 2 hrs to fix

    Avoid deeply nested control flow statements.
    Confirmed

                unless allowed
                  render_error status: 403, errorcode: 'execute_cmd_no_permission',
                               message: "No permission to execute command on package #{pack_name} in project #{prj.name}"
                  return
                end
    Severity: Minor
    Found in src/api/app/controllers/build_controller.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Confirmed

                  unless allowed
                    render_error status: 403, errorcode: 'execute_cmd_no_permission',
                                 message: "No permission to execute command on package #{pack_name}"
                    return
                  end
      Severity: Minor
      Found in src/api/app/controllers/build_controller.rb - About 45 mins to fix

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

          def buildinfo
            required_parameters :project, :repository, :arch, :package
            # just for permission checking
            if request.post? && Package.striping_multibuild_suffix(params[:package]) == '_repository'
              # for osc local package build in this repository
        Severity: Minor
        Found in src/api/app/controllers/build_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