Katello/katello

View on GitHub
app/services/katello/pulp3/repository/yum.rb

Summary

Maintainability
F
3 days
Test Coverage

File yum.rb has 382 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'pulp_rpm_client'

module Katello
  module Pulp3
    class Repository
Severity: Minor
Found in app/services/katello/pulp3/repository/yum.rb - About 5 hrs to fix

    Method multi_copy_units has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

            def multi_copy_units(repo_id_map, dependency_solving)
              tasks = []
    
              if repo_id_map.values.pluck(:content_unit_hrefs).flatten.any?
                data = PulpRpmClient::Copy.new
    Severity: Minor
    Found in app/services/katello/pulp3/repository/yum.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

    Class Yum has 28 methods (exceeds 20 allowed). Consider refactoring.
    Open

          class Yum < ::Katello::Pulp3::Repository
            include Katello::Util::Errata
            include Katello::Util::PulpcoreContentFilters
    
            UNIT_LIMIT = 10_000
    Severity: Minor
    Found in app/services/katello/pulp3/repository/yum.rb - About 3 hrs to fix

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

              def copy_content_for_source(source_repository, options = {})
                package_filters = [ContentViewPackageGroupFilter, ContentViewPackageFilter].collect do |filter_class|
                  filter_class.where(:id => options[:filter_ids])
                end
                package_filters.flatten!.compact!
      Severity: Minor
      Found in app/services/katello/pulp3/repository/yum.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 copy_content_chunked has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

              def copy_content_chunked(data)
                tasks = []
                # Don't chunk if there aren't enough content units
                if data.config.sum { |repo_config| repo_config[:content].size } <= UNIT_LIMIT
                  return api.copy_api.copy_content(data)
      Severity: Minor
      Found in app/services/katello/pulp3/repository/yum.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 copy_content_for_source has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def copy_content_for_source(source_repository, options = {})
                package_filters = [ContentViewPackageGroupFilter, ContentViewPackageFilter].collect do |filter_class|
                  filter_class.where(:id => options[:filter_ids])
                end
                package_filters.flatten!.compact!
      Severity: Minor
      Found in app/services/katello/pulp3/repository/yum.rb - About 1 hr to fix

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

                def multi_copy_units(repo_id_map, dependency_solving)
                  tasks = []
        
                  if repo_id_map.values.pluck(:content_unit_hrefs).flatten.any?
                    data = PulpRpmClient::Copy.new
        Severity: Minor
        Found in app/services/katello/pulp3/repository/yum.rb - About 1 hr to fix

          Method copy_content_from_mapping has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def copy_content_from_mapping(repo_id_map, options = {})
                    repo_id_map.each do |source_repo_ids, dest_repo_map|
                      filters = [ContentViewErratumFilter, ContentViewPackageGroupFilter, ContentViewPackageFilter].collect do |filter_class|
                        filter_class.where(:id => dest_repo_map[:filter_ids])
                      end
          Severity: Minor
          Found in app/services/katello/pulp3/repository/yum.rb - About 1 hr to fix

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

                    def copy_content_chunked(data)
                      tasks = []
                      # Don't chunk if there aren't enough content units
                      if data.config.sum { |repo_config| repo_config[:content].size } <= UNIT_LIMIT
                        return api.copy_api.copy_content(data)
            Severity: Minor
            Found in app/services/katello/pulp3/repository/yum.rb - About 1 hr to fix

              Method add_modular_content has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                      def add_modular_content(source_repo_ids, filters, modular_filters, filter_list_map)
                        inclusion_modular_filters = modular_filters.select { |filter| filter.inclusion }
                        exclusion_modular_filters = modular_filters - inclusion_modular_filters
                        if inclusion_modular_filters.empty? &&
                            !(filters.any? { |filter| filter.class == ContentViewErratumFilter && filter.inclusion })
              Severity: Minor
              Found in app/services/katello/pulp3/repository/yum.rb - About 25 mins to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Method copy_content_from_mapping has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                      def copy_content_from_mapping(repo_id_map, options = {})
                        repo_id_map.each do |source_repo_ids, dest_repo_map|
                          filters = [ContentViewErratumFilter, ContentViewPackageGroupFilter, ContentViewPackageFilter].collect do |filter_class|
                            filter_class.where(:id => dest_repo_map[:filter_ids])
                          end
              Severity: Minor
              Found in app/services/katello/pulp3/repository/yum.rb - About 25 mins to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

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

                      def copy_content_chunked(data)
                        tasks = []
                        # Don't chunk if there aren't enough content units
                        if data.config.sum { |repo_config| repo_config[:content].size } <= UNIT_LIMIT
                          return api.copy_api.copy_content(data)
              Severity: Major
              Found in app/services/katello/pulp3/repository/yum.rb and 1 other location - About 3 hrs to fix
              app/services/katello/pulp3/repository/apt.rb on lines 127..165

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

              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 copy_api_data_dup(data)
                        data_dup = PulpRpmClient::Copy.new
                        data_dup.dependency_solving = data.dependency_solving
                        data_dup.config = []
                        data.config.each do |repo_config|
              Severity: Minor
              Found in app/services/katello/pulp3/repository/yum.rb and 1 other location - About 55 mins to fix
              app/services/katello/pulp3/repository/apt.rb on lines 111..124

              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

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

                            source_repo_ids.each do |source_repo_id|
                              source_repo_version = ::Katello::Repository.find(source_repo_id).version_href
                              config = { source_repo_version: source_repo_version, dest_repo: dest_repo_href, content: content_unit_hrefs }
                              config[:dest_base_version] = dest_repo_id_map[:base_version] if dest_repo_id_map[:base_version]
                              data.config << config
              Severity: Minor
              Found in app/services/katello/pulp3/repository/yum.rb and 1 other location - About 30 mins to fix
              app/services/katello/pulp3/repository/apt.rb on lines 97..101

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

              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 remove_all_content_from_mapping(repo_id_map)
                        tasks = []
                        repo_id_map.each do |_source_repo_ids, dest_repo_id_map|
                          dest_repo = ::Katello::Repository.find(dest_repo_id_map[:dest_repo])
                          dest_repo_href = ::Katello::Pulp3::Repository::Yum.new(dest_repo, SmartProxy.pulp_primary).repository_reference.repository_href
              Severity: Minor
              Found in app/services/katello/pulp3/repository/yum.rb and 1 other location - About 30 mins to fix
              app/services/katello/pulp3/repository/apt.rb on lines 168..175

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

              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