openSUSE/open-build-service

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

Summary

Maintainability
F
1 wk
Test Coverage

File project.rb has 1202 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require_dependency 'has_relationships'

# rubocop:disable Metrics/ClassLength
class Project < ApplicationRecord
  include FlagHelper
Severity: Major
Found in src/api/app/models/project.rb - About 3 days to fix

    Class Project has 128 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Project < ApplicationRecord
      include FlagHelper
      include Flag::Validations
      include CanRenderModel
      include HasRelationships
    Severity: Major
    Found in src/api/app/models/project.rb - About 2 days to fix

      Method branch_local_repositories has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
      Open

        def branch_local_repositories(project, pkg_to_enable, opts = {})
          # shall we use the repositories from a different project?
          project = project.update_instance('OBS', 'BranchRepositoriesFromProject')
          skip_repos = []
          a = project.find_attribute('OBS', 'BranchSkipRepositories')
      Severity: Minor
      Found in src/api/app/models/project.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 sync_repository_pathes has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

        def sync_repository_pathes
          # check all my repositories and ..
          repositories.each do |repo|
            cycle_detection = {}
            repo.path_elements.each do |path|
      Severity: Minor
      Found in src/api/app/models/project.rb - About 4 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 do_project_release has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

        def do_project_release(params)
          User.session ||= User.find_by!(login: params[:user])
      
          # uniq timestring for all targets
          time_now = Time.now.utc
      Severity: Minor
      Found in src/api/app/models/project.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 revoke_requests has a Cognitive Complexity of 23 (exceeds 5 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 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 remove_repositories has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.remove_repositories(repositories, opts = {})
          deleted_repository = Repository.deleted_instance
      
          repositories.each do |repo|
            linking_repositories = repo.linking_repositories
      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 branch_copy_flags has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        def branch_copy_flags(project)
          # Copy the flags from the other project, adjusting them appropriately
          # for this one being a branch of it:
          #
          # - enable building
      Severity: Minor
      Found in src/api/app/models/project.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 write_to_backend has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        def write_to_backend
          # expire cache
          reset_cache
      
          unless @commit_opts[:no_backend_write] || @commit_opts[:login] || @commit_user
      Severity: Minor
      Found in src/api/app/models/project.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 branch_local_repositories has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def branch_local_repositories(project, pkg_to_enable, opts = {})
          # shall we use the repositories from a different project?
          project = project.update_instance('OBS', 'BranchRepositoriesFromProject')
          skip_repos = []
          a = project.find_attribute('OBS', 'BranchSkipRepositories')
      Severity: Minor
      Found in src/api/app/models/project.rb - About 1 hr to fix

        Method find_package has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def find_package(package_name, check_update_project = nil, processed = {})
            # cycle check in linked projects
            if processed[self]
              str = name
              processed.keys.each do |key|
        Severity: Minor
        Found in src/api/app/models/project.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 validate_repository_xml_attribute has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.validate_repository_xml_attribute(request_data, project_name)
            # Check used repo pathes for existens and read access permissions
            request_data.elements('repository') do |repository|
              repository.elements('path') do |element|
                # permissions check
        Severity: Minor
        Found in src/api/app/models/project.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 can_be_unlocked? has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def can_be_unlocked?(with_exception = true)
            if is_maintenance_incident?
              requests = BsRequest.where(state: [:new, :review, :declined]).joins(:bs_request_actions)
              maintenance_release_requests = requests.where(bs_request_actions: { type: 'maintenance_release', source_project: name })
              if maintenance_release_requests.exists?
        Severity: Minor
        Found in src/api/app/models/project.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 cleanup_linking_repos has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          def cleanup_linking_repos
            # replace links to this project repositories with links to the "deleted" repository
            find_repos(:linking_repositories) do |linking_repository|
              linking_repository.path_elements.includes(:link).each do |path_element|
                next unless path_element.link.db_project_id == id && !(path_element.repository.db_project_id == id)
        Severity: Minor
        Found in src/api/app/models/project.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 get_by_name has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.get_by_name(name, opts = {})
            dbp = find_by_name(name, skip_check_access: true)
            if dbp.nil?
              dbp, remote_name = find_remote_project(name)
              return dbp.name + ':' + remote_name if dbp
        Severity: Minor
        Found in src/api/app/models/project.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_package has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def find_package(package_name, check_update_project = nil, processed = {})
            # cycle check in linked projects
            if processed[self]
              str = name
              processed.keys.each do |key|
        Severity: Minor
        Found in src/api/app/models/project.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 find_remote_project has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.find_remote_project(name, skip_access = false)
                return unless name
            
                fragments = name.split(/:/)
            
            
            Severity: Minor
            Found in src/api/app/models/project.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 delete_on_backend has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def delete_on_backend
                if CONFIG['global_write_through'] && !@commit_opts[:no_backend_write]
                  begin
                    options = { user: User.session!.login, comment: @commit_opts[:comment] }
                    options[:requestid] = @commit_opts[:request].number if @commit_opts[:request]
            Severity: Minor
            Found in src/api/app/models/project.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 add_repository_targets has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def add_repository_targets(trepo, source_repo, add_target_repos = [], opts = {})
                trepo.clone_repository_from(source_repo)
                trepo.rebuild = opts[:rebuild] if opts[:rebuild]
                trepo.rebuild = source_repo.rebuild if opts[:rebuild] == 'copy'
                trepo.block   = opts[:block] if opts[:block]
            Severity: Minor
            Found in src/api/app/models/project.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 expand_all_products has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def expand_all_products
                p_map = {}
                products = Product.all_products(self).to_a
                products.each { |p| p_map[p.cpe] = 1 } # existing packages map
                # second path, all packages from indirect linked projects
            Severity: Minor
            Found in src/api/app/models/project.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 expand_all_projects has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def expand_all_projects(project_map: {}, allow_remote_projects: true)
                # cycle check
                return [] if project_map[self]
                project_map[self] = 1
            
            
            Severity: Minor
            Found in src/api/app/models/project.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 branch_remote_repositories has a Cognitive Complexity of 7 (exceeds 5 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 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 valid_name? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.valid_name?(name)
                return false unless name.is_a?(String)
                return false if name == '0'
                return false if name =~ /:[:\._]/
                return false if name =~ /\A[:\._]/
            Severity: Minor
            Found in src/api/app/models/project.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 expand_all_packages has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def expand_all_packages(packages = [], project_map = {}, package_map = {})
                # check for project link cycle
                return [] if project_map[self]
                project_map[self] = 1
            
            
            Severity: Minor
            Found in src/api/app/models/project.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

            Avoid too many return statements within this method.
            Open

                return false if name.end_with?(':')
            Severity: Major
            Found in src/api/app/models/project.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                  return true  if name =~ /\A[-+\w\.:]{1,200}\z/
              Severity: Major
              Found in src/api/app/models/project.rb - About 30 mins to fix

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

                  def check_write_access!(ignore_lock = nil)
                    return if Rails.env.test? && !User.session # for unit tests
                
                    # the can_create_check is inconsistent with package class check_write_access! check
                    return if can_be_modified_by?(User.possibly_nobody, ignore_lock)
                Severity: Minor
                Found in src/api/app/models/project.rb and 1 other location - About 25 mins to fix
                src/api/app/models/package.rb on lines 381..385

                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 30.

                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

                        begin
                          request.change_state(newstate: 'declined', comment: "The target project '#{name}' has been removed")
                        rescue PostRequestNoPermission
                          logger.debug "#{User.session!.login} tried to decline request #{request.number} but had no permissions"
                Severity: Minor
                Found in src/api/app/models/project.rb and 1 other location - About 15 mins to fix
                src/api/app/models/project.rb on lines 288..291

                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 26.

                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

                          begin
                            request.change_state(newstate: 'revoked', comment: "The source project '#{name}' has been removed")
                          rescue PostRequestNoPermission
                            logger.debug "#{User.session!.login} tried to revoke request #{request.number} but had no permissions"
                Severity: Minor
                Found in src/api/app/models/project.rb and 1 other location - About 15 mins to fix
                src/api/app/models/project.rb on lines 296..299

                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 26.

                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

                    unless linking_repositories.empty?
                      str = linking_repositories.map! { |l| l.project.name + '/' + l.name }.join("\n")
                      return { error: "Unable to delete repository; following repositories depend on this project:\n#{str}" }
                Severity: Minor
                Found in src/api/app/models/project.rb and 1 other location - About 15 mins to fix
                src/api/app/models/project.rb on lines 1492..1494

                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 25.

                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

                    unless linking_target_repositories.empty?
                      str = linking_target_repositories.map { |l| l.project.name + '/' + l.name }.join("\n")
                      return { error: "Unable to delete repository; following target repositories depend on this project:\n#{str}" }
                Severity: Minor
                Found in src/api/app/models/project.rb and 1 other location - About 15 mins to fix
                src/api/app/models/project.rb on lines 1487..1489

                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 25.

                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

                There are no issues that match your filters.

                Category
                Status