Katello/katello

View on GitHub
app/controllers/katello/api/v2/content_view_versions_controller.rb

Summary

Maintainability
C
1 day
Test Coverage

Method find_version_environments has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def find_version_environments
      #Generates a data structure for incremental update:
      # [{:content_view_version => ContentViewVersion, :environments => [KTEnvironment]}]

      list = params[:content_view_version_environments]
Severity: Minor
Found in app/controllers/katello/api/v2/content_view_versions_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

Class ContentViewVersionsController has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Api::V2::ContentViewVersionsController < Api::V2::ApiController
    include ::Api::V2::BulkHostsExtension
    include Katello::Concerns::FilteredAutoCompleteSearch

    before_action :find_authorized_katello_resource, :only => [:show, :update, :promote, :destroy, :republish_repositories, :verify_checksum]
Severity: Minor
Found in app/controllers/katello/api/v2/content_view_versions_controller.rb - About 2 hrs to fix

    File content_view_versions_controller.rb has 256 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Katello
      class Api::V2::ContentViewVersionsController < Api::V2::ApiController
        include ::Api::V2::BulkHostsExtension
        include Katello::Concerns::FilteredAutoCompleteSearch
    
    
    Severity: Minor
    Found in app/controllers/katello/api/v2/content_view_versions_controller.rb - About 2 hrs to fix

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

          def validate_content(content)
            if content[:errata_ids]
              errata = Erratum.with_identifiers(content[:errata_ids])
              not_found_count = content[:errata_ids].length - errata.length
              if not_found_count > 0
      Severity: Minor
      Found in app/controllers/katello/api/v2/content_view_versions_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_version_environments has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def find_version_environments
            #Generates a data structure for incremental update:
            # [{:content_view_version => ContentViewVersion, :environments => [KTEnvironment]}]
      
            list = params[:content_view_version_environments]
      Severity: Minor
      Found in app/controllers/katello/api/v2/content_view_versions_controller.rb - About 1 hr to fix

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

            def index_relation
              version_number = params.permit(:version)[:version]
              versions = ContentViewVersion.readable
              versions = versions.triggered_by(params[:triggered_by_id]) if params[:triggered_by_id]
              versions = versions.with_organization_id(params[:organization_id]) if params[:organization_id]
        Severity: Minor
        Found in app/controllers/katello/api/v2/content_view_versions_controller.rb - About 45 mins to fix

        Cognitive Complexity

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

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

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

        Further reading

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

            def calculate_hosts_for_incremental(bulk_params, use_composites)
              if bulk_params[:included].try(:[], :search)
                version_environments = find_version_environments_for_hosts(use_composites)
                restrict_hosts = lambda do |relation|
                  if version_environments.any?
        Severity: Minor
        Found in app/controllers/katello/api/v2/content_view_versions_controller.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

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

              param :included, Hash, :required => true, :action_aware => true do
                param :search, String, :required => false, :desc => N_("Search string for host to perform an action on")
                param :ids, Array, :required => false, :desc => N_("List of host ids to perform an action on")
              end
        app/controllers/katello/api/v2/hosts_bulk_actions_controller.rb on lines 31..34

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

        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