Katello/katello

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

Summary

Maintainability
B
6 hrs
Test Coverage

Method available_repositories has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def available_repositories
      scan_cdn = sync_task(::Actions::Katello::RepositorySet::ScanCdn, @product, @product_content.content.cp_content_id)
      repos = scan_cdn.output[:results]

      repos = repos.select do |repo|
Severity: Minor
Found in app/controllers/katello/api/v2/repository_sets_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 RepositorySetsController has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Api::V2::RepositorySetsController < Api::V2::ApiController
    respond_to :json

    include Katello::Concerns::FilteredAutoCompleteSearch

Severity: Minor
Found in app/controllers/katello/api/v2/repository_sets_controller.rb - About 2 hrs to fix

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

        def index_relation
          if @product.nil?
            authorized_product_contents = Katello::ProductContent.joins(:product).merge(@product_scope)
            relation = @organization.product_contents.merge(authorized_product_contents).displayable
          else
    Severity: Minor
    Found in app/controllers/katello/api/v2/repository_sets_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 custom_sort_results has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def custom_sort_results(unsorted_relation)
          return unsorted_relation unless params[:sort_by] == 'enabled_by_default'
          product_content_finder = ProductContentFinder.wrap_with_overrides(
            product_contents: unsorted_relation,
            overrides: @consumable&.content_overrides,
    Severity: Minor
    Found in app/controllers/katello/api/v2/repository_sets_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

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

        def sort_score(pc) # sort order for enabled
          score = if pc.enabled_content_override&.value == "1"
                    4 # overridden to enabled
                  elsif pc.enabled_content_override.nil? && pc.enabled
                    3 # enabled
    Severity: Minor
    Found in app/controllers/katello/api/v2/repository_sets_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

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

        def setup_params
          return unless params[:id]
          params[:content_access_mode_all] = true
          if params[:entity] == :activation_key
            params[:activation_key_id] ||= params[:id]
    Severity: Minor
    Found in app/controllers/katello/api/v2/repository_sets_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

    There are no issues that match your filters.

    Category
    Status