openSUSE/open-build-service

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

Summary

Maintainability
F
1 wk
Test Coverage

File package_controller.rb has 949 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'project'

class Webui::PackageController < Webui::WebuiController
  require_dependency 'opensuse/validator'
  include ParsePackageDiff
Severity: Major
Found in src/api/app/controllers/webui/package_controller.rb - About 2 days to fix

    Class PackageController has 56 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Webui::PackageController < Webui::WebuiController
      require_dependency 'opensuse/validator'
      include ParsePackageDiff
      include Webui::PackageHelper
      include Webui::ManageRelationships
    Severity: Major
    Found in src/api/app/controllers/webui/package_controller.rb - About 1 day to fix

      Method branch has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

        def branch
          params.fetch(:linked_project) { raise ArgumentError, 'Linked Project parameter missing' }
          params.fetch(:linked_package) { raise ArgumentError, 'Linked Package parameter missing' }
      
          # Full permission check happens in BranchPackage.new(branch_params).branch command
      Severity: Minor
      Found in src/api/app/controllers/webui/package_controller.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 submit_request has 78 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def submit_request
          target_project_name = params[:targetproject].try(:strip)
          package_name = params[:package].strip
          project_name = params[:project].strip
      
      
      Severity: Major
      Found in src/api/app/controllers/webui/package_controller.rb - About 3 hrs to fix

        Method save_file has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

          def save_file
            authorize @package, :update?
        
            file = params[:file]
            file_url = params[:file_url]
        Severity: Minor
        Found in src/api/app/controllers/webui/package_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 submit_request has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

          def submit_request
            target_project_name = params[:targetproject].try(:strip)
            package_name = params[:package].strip
            project_name = params[:project].strip
        
        
        Severity: Minor
        Found in src/api/app/controllers/webui/package_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 branch has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def branch
            params.fetch(:linked_project) { raise ArgumentError, 'Linked Project parameter missing' }
            params.fetch(:linked_package) { raise ArgumentError, 'Linked Package parameter missing' }
        
            # Full permission check happens in BranchPackage.new(branch_params).branch command
        Severity: Major
        Found in src/api/app/controllers/webui/package_controller.rb - About 2 hrs to fix

          Method save_file has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def save_file
              authorize @package, :update?
          
              file = params[:file]
              file_url = params[:file_url]
          Severity: Minor
          Found in src/api/app/controllers/webui/package_controller.rb - About 1 hr to fix

            Method rdiff has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              def rdiff
                @last_rev = @package.dir_hash['rev']
                @linkinfo = @package.linkinfo
                if params[:oproject]
                  @oproject = ::Project.find_by_name(params[:oproject])
            Severity: Minor
            Found in src/api/app/controllers/webui/package_controller.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_file_details has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              def set_file_details
                @forced_unexpand ||= ''
            
                # check source access
                @files = []
            Severity: Minor
            Found in src/api/app/controllers/webui/package_controller.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 update_build_log has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def update_build_log
                # Make sure objects don't contain invalid chars (eg. '../')
                @repo = @project.repositories.find_by(name: params[:repository]).try(:name)
                unless @repo
                  @errors = "Couldn't find repository '#{params[:repository]}'. We don't have build log for this repository"
            Severity: Minor
            Found in src/api/app/controllers/webui/package_controller.rb - About 1 hr to fix

              Method view_file has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                def view_file
                  @filename = params[:filename] || params[:file] || ''
                  if Package.is_binary_file?(@filename) # We don't want to display binary files
                    flash[:error] = "Unable to display binary file #{@filename}"
                    redirect_back(fallback_location: { action: :show, project: @project, package: @package })
              Severity: Minor
              Found in src/api/app/controllers/webui/package_controller.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 update_build_log has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                def update_build_log
                  # Make sure objects don't contain invalid chars (eg. '../')
                  @repo = @project.repositories.find_by(name: params[:repository]).try(:name)
                  unless @repo
                    @errors = "Couldn't find repository '#{params[:repository]}'. We don't have build log for this repository"
              Severity: Minor
              Found in src/api/app/controllers/webui/package_controller.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 view_file has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def view_file
                  @filename = params[:filename] || params[:file] || ''
                  if Package.is_binary_file?(@filename) # We don't want to display binary files
                    flash[:error] = "Unable to display binary file #{@filename}"
                    redirect_back(fallback_location: { action: :show, project: @project, package: @package })
              Severity: Minor
              Found in src/api/app/controllers/webui/package_controller.rb - About 1 hr to fix

                Method show has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def show
                    if request.bot?
                      params.delete(:rev)
                      params.delete(:srcmd5)
                      @expand = 0
                Severity: Minor
                Found in src/api/app/controllers/webui/package_controller.rb - About 1 hr to fix

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

                    def dependency
                      switch_to_webui2
                      dependant_project = Project.find_by_name(params[:dependant_project]) || Project.find_remote_project(params[:dependant_project]).try(:first)
                      unless dependant_project
                        flash[:error] = "Project '#{params[:dependant_project]}' is invalid."
                  Severity: Minor
                  Found in src/api/app/controllers/webui/package_controller.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 rdiff has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def rdiff
                      @last_rev = @package.dir_hash['rev']
                      @linkinfo = @package.linkinfo
                      if params[:oproject]
                        @oproject = ::Project.find_by_name(params[:oproject])
                  Severity: Minor
                  Found in src/api/app/controllers/webui/package_controller.rb - About 1 hr to fix

                    Method dependency has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def dependency
                        switch_to_webui2
                        dependant_project = Project.find_by_name(params[:dependant_project]) || Project.find_remote_project(params[:dependant_project]).try(:first)
                        unless dependant_project
                          flash[:error] = "Project '#{params[:dependant_project]}' is invalid."
                    Severity: Minor
                    Found in src/api/app/controllers/webui/package_controller.rb - About 1 hr to fix

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

                        def show
                          if request.bot?
                            params.delete(:rev)
                            params.delete(:srcmd5)
                            @expand = 0
                      Severity: Minor
                      Found in src/api/app/controllers/webui/package_controller.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 save_meta has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Wontfix

                        def save_meta
                          errors = []
                      
                          authorize @package, :save_meta_update?
                      
                      
                      Severity: Minor
                      Found in src/api/app/controllers/webui/package_controller.rb - About 1 hr to fix

                        Method rpmlint_result has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def rpmlint_result
                            @repo_arch_hash = {}
                            @buildresult = Buildresult.find_hashed(project: @project.to_param, package: @package.to_param, view: 'status')
                            repos = [] # Temp var
                            if @buildresult
                        Severity: Minor
                        Found in src/api/app/controllers/webui/package_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

                        Method save_meta has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def save_meta
                            errors = []
                        
                            authorize @package, :save_meta_update?
                        
                        
                        Severity: Minor
                        Found in src/api/app/controllers/webui/package_controller.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

                        Method binaries has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Wontfix

                          def binaries
                            @repository = params[:repository]
                            @package_name = params[:package]
                        
                            results_from_backend = Buildresult.find_hashed(project: @project, package: @package_name, repository: @repository, view: ['binarylist', 'status'])
                        Severity: Minor
                        Found in src/api/app/controllers/webui/package_controller.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

                        Method links_for_binaries_action has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Invalid

                          def links_for_binaries_action(project, package_name, repository, architecture, filename)
                        Severity: Minor
                        Found in src/api/app/controllers/webui/package_controller.rb - About 35 mins to fix

                          Method find_last_req has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def find_last_req
                              if @oproject && @opackage
                                last_req = BsRequestAction.where(target_project: @oproject,
                                                                 target_package: @opackage,
                                                                 source_project: @package.project,
                          Severity: Minor
                          Found in src/api/app/controllers/webui/package_controller.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_build_log_access has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def check_build_log_access
                              if ::Project.exists_by_name(params[:project])
                                @project = ::Project.get_by_name(params[:project])
                              else
                                redirect_to root_path, error: "Couldn't find project '#{params[:project]}'. Are you sure it still exists?"
                          Severity: Minor
                          Found in src/api/app/controllers/webui/package_controller.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

                          There are no issues that match your filters.

                          Category
                          Status