theforeman/foreman_remote_execution

View on GitHub
app/helpers/remote_execution_helper.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Method job_invocation_task_buttons has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def job_invocation_task_buttons(task)
    job_invocation = task.task_groups.find { |group| group.class == JobInvocationTaskGroup }.job_invocation
    task_authorizer = Authorizer.new(User.current, :collection => [task])
    buttons = []
    if (template = job_report_template) && authorized_for(controller: :report_templates, action: :generate)
Severity: Minor
Found in app/helpers/remote_execution_helper.rb - About 1 hr to fix

    Method template_invocation_status has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def template_invocation_status(task, parent_task)
        return(parent_task.result == 'cancelled' ? _('cancelled') : _('Awaiting start')) if task.nil?
        return task.state if task.state == 'running' || task.state == 'planned'
        return _('error') if task.result == 'warning'
    
    
    Severity: Minor
    Found in app/helpers/remote_execution_helper.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 template_invocation_actions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def template_invocation_actions(task, host, job_invocation, template_invocation)
        links = []
        host_task = template_invocation.try(:run_host_job_task)
    
        if authorized_for(hash_for_host_path(host).merge(auth_object: host, permission: :view_hosts, authorizer: job_hosts_authorizer))
    Severity: Minor
    Found in app/helpers/remote_execution_helper.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 normalize_line_sets has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def normalize_line_sets(line_sets)
        previous_line_break = true
        line_sets.each_with_index do |line_set, index|
          # if previous line_set was missing break, add the first line from next set
          unless previous_line_break
    Severity: Minor
    Found in app/helpers/remote_execution_helper.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 job_invocation_task_buttons has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def job_invocation_task_buttons(task)
        job_invocation = task.task_groups.find { |group| group.class == JobInvocationTaskGroup }.job_invocation
        task_authorizer = Authorizer.new(User.current, :collection => [task])
        buttons = []
        if (template = job_report_template) && authorized_for(controller: :report_templates, action: :generate)
    Severity: Minor
    Found in app/helpers/remote_execution_helper.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