openSUSE/open-build-service

View on GitHub

Showing 394 of 429 total issues

Method validate_target_for_package_command_exists! has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
Open

  def validate_target_for_package_command_exists!
    @project = nil
    @package = nil

    follow_project_links = SOURCE_UNTOUCHED_COMMANDS.include?(@command)
Severity: Minor
Found in src/api/app/controllers/source_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 find has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
Open

  def find(xpath)
    # logger.debug "---------------------- parsing xpath: #{xpath} -----------------------"

    begin
      @stack = @lexer.parse xpath
Severity: Minor
Found in src/api/lib/xpath_engine.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 destroy has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
Open

  def destroy
    @comment = Comment.find(params[:id])
    authorize @comment, :destroy?
    @commentable = @comment.commentable

Severity: Minor
Found in src/api/app/controllers/webui/comments_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 create_events has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def create_events
    Event::Base.transaction do
      data = type = nil
      @last.elements('notification') do |e|
        type = e['type']
Severity: Minor
Found in src/api/app/models/update_notification_events.rb - About 1 hr to fix

    Method update_generic_relationships has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def update_generic_relationships(xmlhash)
        # we remember the current relationships in a hash
        cache = {}
        relationships.each do |purr|
          next if @updater.ignore?(purr)
    Severity: Minor
    Found in src/api/app/models/concerns/has_relationships.rb - About 1 hr to fix

      Method extend_packages_to_link has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def extend_packages_to_link(p)
          return unless p[:package].is_a?(Package) # only for local packages
      
          pkg = p[:package]
          if pkg.is_link?
      Severity: Minor
      Found in src/api/app/models/branch_package.rb - About 1 hr to fix

        Method statistic has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def statistic
              result = backend_statistics
              return if result.blank?
        
              disk = result.dig('disk', 'usage')
        Severity: Minor
        Found in src/api/app/models/local_build_statistic/for_package.rb - About 1 hr to fix

          Method has_local_permission? has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def has_local_permission?(perm_string, object)
              roles = Role.ids_with_permission(perm_string)
              return false unless roles
          
              parent = nil
          Severity: Minor
          Found in src/api/app/models/user.rb - About 1 hr to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              class RelationshipCreate < Relationship
                self.message_bus_routing_key = 'relationship.create'
                self.description = 'Relationship created'
            
                receiver_roles :any_role
            Severity: Major
            Found in src/api/app/models/event/relationship_create.rb and 1 other location - About 1 hr to fix
            src/api/app/models/event/relationship_delete.rb on lines 2..13

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 49.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              class RelationshipDelete < Relationship
                self.message_bus_routing_key = 'relationship.delete'
                self.description = 'Relationship deleted'
            
                receiver_roles :any_role
            Severity: Major
            Found in src/api/app/models/event/relationship_delete.rb and 1 other location - About 1 hr to fix
            src/api/app/models/event/relationship_create.rb on lines 2..13

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 49.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Method run has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def run(xmlhash, force = nil)
                  project.check_write_access!
            
                  # check for raising read access permissions, which can't get ensured atm
                  raise ForbiddenError if !(project.new_record? || project.disabled_for?('access', nil, nil)) && (FlagHelper.xml_disabled_for?(xmlhash, 'access') && !User.admin_session?)
            Severity: Minor
            Found in src/api/app/models/project/update_from_xml_command.rb - About 1 hr to fix

              Method branch_remote_repositories has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def branch_remote_repositories(project)
                  remote_project = Project.new(name: project)
                  remote_project_meta = Nokogiri::XML(remote_project.meta.content, &:strict)
                  local_project_meta = Nokogiri::XML(render_xml, &:strict)
              
              
              Severity: Minor
              Found in src/api/app/models/project.rb - About 1 hr to fix

                Method release_package_create_main_package has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def release_package_create_main_package(request, source_package, target_package_name, target_project)
                    base_package_name = target_package_name.gsub(/\.[^.]*$/, '')
                
                    # only if package does not contain a _patchinfo file
                    lpkg = nil
                Severity: Minor
                Found in src/api/app/helpers/maintenance_helper.rb - About 1 hr to fix

                  Method resample has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def self.resample(values, samples = 400)
                      values.sort_by! { |a| a[0] }
                  
                      result = []
                      return result if values.empty?
                  Severity: Minor
                  Found in src/api/app/helpers/status_helper.rb - About 1 hr to fix

                    Method index has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def index
                        if request.post? && !params[:project].nil? && Project.valid_name?(params[:project])
                          redirect_to project: params[:project]
                        else
                          begin
                    Severity: Minor
                    Found in src/api/app/controllers/webui/monitor_controller.rb - About 1 hr to fix

                      Method create has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def create
                              authorize @package, :update?
                      
                              files = params[:files] || []
                              filename = params[:filename]
                      Severity: Minor
                      Found in src/api/app/controllers/webui/packages/files_controller.rb - About 1 hr to fix

                        Identical blocks of code found in 2 locations. Consider refactoring.
                        Confirmed

                          def payload
                            default_payload.merge(
                              event: 'pull_request',
                              commit_sha: webhook_payload.dig(:pull_request, :head, :sha),
                              pr_number: webhook_payload[:number],
                        Severity: Minor
                        Found in src/api/app/models/gitea_payload/pull_request.rb and 1 other location - About 1 hr to fix
                        src/api/app/models/github_payload/pull_request.rb on lines 3..13

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 47.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Identical blocks of code found in 2 locations. Consider refactoring.
                        Confirmed

                          def payload
                            default_payload.merge(
                              event: 'pull_request',
                              commit_sha: webhook_payload.dig(:pull_request, :head, :sha),
                              pr_number: webhook_payload[:number],
                        Severity: Minor
                        Found in src/api/app/models/github_payload/pull_request.rb and 1 other location - About 1 hr to fix
                        src/api/app/models/gitea_payload/pull_request.rb on lines 3..13

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 47.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                          def update
                            authorize @project, :update?
                            respond_to do |format|
                              if @project.update(project_params)
                                format.html do
                        Severity: Minor
                        Found in src/api/app/controllers/webui/project_controller.rb and 1 other location - About 55 mins to fix
                        src/api/app/controllers/webui/package_controller.rb on lines 115..129

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 46.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                          def update
                            authorize @package, :update?
                            respond_to do |format|
                              if @package.update(package_details_params)
                                format.html do
                        Severity: Minor
                        Found in src/api/app/controllers/webui/package_controller.rb and 1 other location - About 55 mins to fix
                        src/api/app/controllers/webui/project_controller.rb on lines 105..119

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 46.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Severity
                        Category
                        Status
                        Source
                        Language