theforeman/foreman_remote_execution

View on GitHub
app/models/job_invocation_composer.rb

Summary

Maintainability
D
2 days
Test Coverage

File job_invocation_composer.rb has 535 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class JobInvocationComposer
  class JobTemplateNotFound < StandardError; end

  class FeatureNotFound < StandardError; end

Severity: Major
Found in app/models/job_invocation_composer.rb - About 1 day to fix

    Class JobInvocationComposer has 41 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class JobInvocationComposer
      class JobTemplateNotFound < StandardError; end
    
      class FeatureNotFound < StandardError; end
    
    
    Severity: Minor
    Found in app/models/job_invocation_composer.rb - About 5 hrs to fix

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

          def triggering_params
            if api_params[:recurrence].present? && api_params[:scheduling].present?
              recurring_mode_params.merge :start_at_raw => format_datetime(api_params[:scheduling][:start_at])
            elsif api_params[:recurrence].present? && api_params[:scheduling].empty?
              recurring_mode_params
      Severity: Minor
      Found in app/models/job_invocation_composer.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 displayed_search_query has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def displayed_search_query
          if @search_query.present?
            @search_query
          elsif host_ids.present?
            Targeting.build_query_from_hosts(host_ids)
      Severity: Minor
      Found in app/models/job_invocation_composer.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 compose has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def compose
          job_invocation.job_category = validate_job_category(params[:job_category])
          job_invocation.job_category ||= resolve_job_category(available_job_categories.first) { |template| template.job_category } if @set_defaults
          job_invocation.remote_execution_feature_id = params[:remote_execution_feature_id]
          job_invocation.targeting = build_targeting
      Severity: Minor
      Found in app/models/job_invocation_composer.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 build_targeting has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def build_targeting
          # if bookmark was used we compare it to search query,
          # when it's the same, we delete the query since it is used from bookmark
          # when no bookmark is set we store the query
          bookmark_id = params[:targeting][:bookmark_id]
      Severity: Minor
      Found in app/models/job_invocation_composer.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 resolve_for_composer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def resolve_for_composer(default_value, &block)
          setting_value = Setting['remote_execution_form_job_template']
          return default_value unless setting_value
      
          form_template = JobTemplate.authorized(:view_job_templates).find_by :name => setting_value
      Severity: Minor
      Found in app/models/job_invocation_composer.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 build_input_values_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def build_input_values_for(template_invocation, job_template_base)
          template_invocation.input_values = template_invocation.template.template_inputs_with_foreign.map do |input|
            attributes = job_template_base.fetch('input_values', {}).find { |i| i[:template_input_id].to_s == input.id.to_s }
            attributes = { "template_input_id" => input.id, "value" => input.default } if attributes.nil? && input.default
            attributes ? input.template_invocation_input_values.build(attributes) : nil
      Severity: Minor
      Found in app/models/job_invocation_composer.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