openSUSE/open-build-service

View on GitHub

Showing 397 of 433 total issues

Method revoke_requests has a Cognitive Complexity of 23 (exceeds 8 allowed). Consider refactoring.
Open

  def revoke_requests
    # Find open requests involving self and:
    # - revoke them if self is source
    # - decline if self is target
    # Note: As requests are a backend matter, it's pointless to include them into the transaction below
Severity: Minor
Found in src/api/app/models/project.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 find_with_ldap has a Cognitive Complexity of 23 (exceeds 8 allowed). Consider refactoring.
Open

    def find_with_ldap(login, password)
      Rails.logger.debug { "Looking for #{login} using ldap" }

      # When the server closes the connection, @@ldap_search_con.nil? doesn't catch it
      # @@ldap_search_con.bound? doesn't catch it as well. So when an error occurs, we
Severity: Minor
Found in src/api/app/models/user_ldap_strategy.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 package_command has a Cognitive Complexity of 23 (exceeds 8 allowed). Consider refactoring.
Open

  def package_command
    params[:user] = User.session!.login

    raise MissingParameterError, 'POST request without given cmd parameter' unless params[:cmd]

Severity: Minor
Found in src/api/app/controllers/source_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 call has a Cognitive Complexity of 23 (exceeds 8 allowed). Consider refactoring.
Open

  def call(env)
    logger = Rails.logger
    GC.start
    before = `ps -orss= -p#{$PROCESS_ID}`.to_i
    file = File.new("/tmp/memprof-#{$PROCESS_ID}.log", 'w')
Severity: Minor
Found in src/api/lib/memory_debugger.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 find_with_ldap has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def find_with_ldap(login, password)
      Rails.logger.debug { "Looking for #{login} using ldap" }

      # When the server closes the connection, @@ldap_search_con.nil? doesn't catch it
      # @@ldap_search_con.bound? doesn't catch it as well. So when an error occurs, we
Severity: Major
Found in src/api/app/models/user_ldap_strategy.rb - About 2 hrs to fix

    Method create_branch_packages has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def create_branch_packages(tprj)
        # collect also the needed repositories here
        response = nil
        @packages.each do |p|
          raise CanNotBranchPackage, "project is developed at #{p[:link_target_project].scmsync}. Fork it instead." if p[:link_target_project].try(:scmsync).present?
    Severity: Major
    Found in src/api/app/models/branch_package.rb - About 2 hrs to fix

      Class StagedRequests has 24 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class Staging::StagedRequests
        include ActiveModel::Model
        attr_accessor :request_numbers, :staging_project, :staging_workflow, :user_login
      
        def create
      Severity: Minor
      Found in src/api/app/models/staging/staged_requests.rb - About 2 hrs to fix

        Class Request has 24 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Request < Base
            self.description = 'Request was updated'
            self.abstract_class = true
            payload_keys :author, :comment, :description, :id, :number, :actions, :state, :when, :who, :namespace
            shortenable_key :description
        Severity: Minor
        Found in src/api/app/models/event/request.rb - About 2 hrs to fix

          Method project_command_copy has 65 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def project_command_copy
              project_name = params[:project]
          
              @project = Project.find_by_name(project_name)
              raise CmdExecutionNoPermission, "no permission to execute command 'copy'" unless (@project && User.session!.can_modify?(@project)) ||
          Severity: Major
          Found in src/api/app/controllers/source_controller.rb - About 2 hrs to fix

            Method get_by_project_and_name has a Cognitive Complexity of 22 (exceeds 8 allowed). Consider refactoring.
            Open

              def self.get_by_project_and_name(project_name_or_object, package_name, opts = {})
                get_by_project_and_name_defaults = { use_source: true, follow_project_links: true, follow_multibuild: false, check_update_project: false }
                opts = get_by_project_and_name_defaults.merge(opts)
            
                package_name = striping_multibuild_suffix(package_name) if opts[:follow_multibuild]
            Severity: Minor
            Found in src/api/app/models/package.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 owner_packages_or_projects has a Cognitive Complexity of 22 (exceeds 8 allowed). Consider refactoring.
            Open

              def owner_packages_or_projects
                return if params[:project].blank? && params[:package].blank?
            
                if params[:package].present?
                  if params[:project].blank?
            Severity: Minor
            Found in src/api/app/controllers/search_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 search has a Cognitive Complexity of 22 (exceeds 8 allowed). Consider refactoring.
            Open

              def search(what, render_all)
                if render_all && params[:match].blank?
                  render_error status: 400, errorcode: 'empty_match',
                               message: 'No predicate found in match argument'
                  return
            Severity: Minor
            Found in src/api/app/controllers/search_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 call has 64 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def call(env)
                logger = Rails.logger
                GC.start
                before = `ps -orss= -p#{$PROCESS_ID}`.to_i
                file = File.new("/tmp/memprof-#{$PROCESS_ID}.log", 'w')
            Severity: Major
            Found in src/api/lib/memory_debugger.rb - About 2 hrs to fix

              Method update_binary_releases_via_json has 63 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def self.update_binary_releases_via_json(repository, json, time = Time.now)
                  # building a hash to avoid single SQL select calls slowing us down too much
                  oldhash = {}
                  BinaryRelease.transaction do
                    where(repository: repository, obsolete_time: nil).find_each do |binary|
              Severity: Major
              Found in src/api/app/models/binary_release.rb - About 2 hrs to fix

                Class ApplicationController has 23 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class ApplicationController < ActionController::Base
                  include Pundit::Authorization
                  protect_from_forgery
                
                  include ActionController::ImplicitRender
                Severity: Minor
                Found in src/api/app/controllers/application_controller.rb - About 2 hrs to fix

                  Method find_packages_to_branch has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def find_packages_to_branch
                      @packages = []
                      if params[:request]
                        # find packages from request
                        req = BsRequest.find_by_number(params[:request])
                  Severity: Major
                  Found in src/api/app/models/branch_package.rb - About 2 hrs to fix

                    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 to_xml has a Cognitive Complexity of 21 (exceeds 8 allowed). Consider refactoring.
                      Open

                        def to_xml(project, package)
                          self.issues = []
                          issueid.to_a.each_with_index do |new_issue, index|
                            issues << [
                              new_issue,
                      Severity: Minor
                      Found in src/api/app/models/patchinfo.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 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 instantiate_container has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def instantiate_container(project, opackage, opts = {})
                          opkg = opackage.origin_container
                          pkg_name = opkg_name = opkg.name
                          if opkg.is_a?(Package) && opkg.project.is_maintenance_release?
                            # strip incident suffix
                      Severity: Major
                      Found in src/api/app/helpers/maintenance_helper.rb - About 2 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language