theforeman/foreman_remote_execution

View on GitHub

Showing 90 of 230 total issues

Class RemoteExecutionProvider has 32 methods (exceeds 20 allowed). Consider refactoring.
Open

class RemoteExecutionProvider

  EFFECTIVE_USER_METHODS = %w[sudo dzdo su].freeze

  class << self
Severity: Minor
Found in app/models/remote_execution_provider.rb - About 4 hrs to fix

    File fixtures.js has 322 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* eslint-disable max-lines */
    import configureMockStore from 'redux-mock-store';
    import hostsQuery from '../steps/HostsAndInputs/hosts.gql';
    import hostgroupsQuery from '../steps/HostsAndInputs/hostgroups.gql';
    
    
    Severity: Minor
    Found in webpack/JobWizard/__tests__/fixtures.js - About 3 hrs to fix

      File engine.rb has 317 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module ForemanRemoteExecution
        DYNFLOW_QUEUE = :remote_execution
      
        class Engine < ::Rails::Engine
          engine_name 'foreman_remote_execution'
      Severity: Minor
      Found in lib/foreman_remote_execution/engine.rb - About 3 hrs to fix

        Class JobInvocation has 29 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class JobInvocation < ApplicationRecord
          CACHE_PREFIX = "job_invocation".freeze
        
          audited :except => [:task_id, :targeting_id, :task_group_id, :triggering_id]
        
        
        Severity: Minor
        Found in app/models/job_invocation.rb - About 3 hrs to fix

          Class RunHostsJob has 26 methods (exceeds 20 allowed). Consider refactoring.
          Open

              class RunHostsJob < Actions::ActionWithSubPlans
                include Actions::RecurringAction
                include Actions::ObservableAction
                include Actions::RemoteExecution::EventHelpers
          
          
          Severity: Minor
          Found in app/lib/actions/remote_execution/run_hosts_job.rb - About 3 hrs to fix

            Function getJobInvocations has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

            const getJobInvocations = url => async (dispatch, getState) => {
              function onGetJobInvocationsSuccess({ data }) {
                // If the job has finished, stop polling
                if (data.finished) {
                  dispatch({
            Severity: Minor
            Found in webpack/react_app/redux/actions/jobInvocations/index.js - 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

            File ScheduleRecurring.js has 287 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import React, { useEffect, useState, useCallback } from 'react';
            import PropTypes from 'prop-types';
            import {
              Form,
              FormGroup,
            Severity: Minor
            Found in webpack/JobWizard/steps/Schedule/ScheduleRecurring.js - About 2 hrs to fix

              Class RunHostJob has 25 methods (exceeds 20 allowed). Consider refactoring.
              Open

                  class RunHostJob < Actions::EntryAction
                    include ::Actions::Helpers::WithContinuousOutput
                    include ::Actions::Helpers::WithDelegatedAction
                    include ::Actions::ObservableAction
                    include ::Actions::RemoteExecution::TemplateInvocationProgressLogging
              Severity: Minor
              Found in app/lib/actions/remote_execution/run_host_job.rb - About 2 hrs to fix

                Function WrappedTargetingHosts has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const WrappedTargetingHosts = () => {
                  const dispatch = useDispatch();
                  const { perPage, perPageOptions } = useForemanSettings();
                
                  const autoRefresh = useSelector(selectAutoRefresh);
                Severity: Major
                Found in webpack/react_app/components/TargetingHosts/index.js - About 2 hrs to fix

                  File index.js has 277 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import React, { useEffect, useState } from 'react';
                  import { isEmpty, debounce } from 'lodash';
                  import {
                    Alert,
                    Button,
                  Severity: Minor
                  Found in webpack/JobWizard/steps/HostsAndInputs/index.js - About 2 hrs to fix

                    File Fields.js has 263 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import React from 'react';
                    import PropTypes from 'prop-types';
                    import { FormGroup, TextInput, Radio } from '@patternfly/react-core';
                    import { translate as __ } from 'foremanReact/common/I18n';
                    import { helpLabel, ResetDefault } from '../form/FormHelpers';
                    Severity: Minor
                    Found in webpack/JobWizard/steps/AdvancedFields/Fields.js - About 2 hrs to fix

                      Function submit has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export const submit = ({
                        jobTemplateID,
                        templateValues,
                        advancedValues,
                        scheduleValue,
                      Severity: Minor
                      Found in webpack/JobWizard/submit.js - 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

                      Function testSetup has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export const testSetup = (selectors, api) => {
                        jest.spyOn(api, 'get');
                        jest.spyOn(selectors, 'selectJobTemplate');
                        jest.spyOn(selectors, 'selectJobTemplates');
                        jest.spyOn(selectors, 'selectJobCategories');
                      Severity: Major
                      Found in webpack/JobWizard/__tests__/fixtures.js - About 2 hrs to fix

                        Function getJobInvocations has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        const getJobInvocations = url => async (dispatch, getState) => {
                          function onGetJobInvocationsSuccess({ data }) {
                            // If the job has finished, stop polling
                            if (data.finished) {
                              dispatch({
                        Severity: Minor
                        Found in webpack/react_app/redux/actions/jobInvocations/index.js - About 1 hr to fix

                          Function mockApi has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                          Open

                          export const mockApi = api => {
                            api.get.mockImplementation(({ handleSuccess, ...action }) => {
                              if (action.key === 'JOB_CATEGORIES') {
                                handleSuccess &&
                                  handleSuccess({
                          Severity: Minor
                          Found in webpack/JobWizard/__tests__/fixtures.js - 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 job_invocation_task_buttons has 43 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

                            Function mockApi has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export const mockApi = api => {
                              api.get.mockImplementation(({ handleSuccess, ...action }) => {
                                if (action.key === 'JOB_CATEGORIES') {
                                  handleSuccess &&
                                    handleSuccess({
                            Severity: Minor
                            Found in webpack/JobWizard/__tests__/fixtures.js - About 1 hr to fix

                              Function getRepeatComponent has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                const getRepeatComponent = () => {
                                  switch (repeatType) {
                                    case repeatTypes.cronline:
                                      return (
                                        <RepeatCron
                              Severity: Minor
                              Found in webpack/JobWizard/steps/Schedule/RepeatOn.js - About 1 hr to fix

                                Function SearchSelect has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                                Open

                                export const SearchSelect = ({
                                  name,
                                  selected,
                                  setSelected,
                                  placeholderText,
                                Severity: Minor
                                Found in webpack/JobWizard/steps/form/SearchSelect.js - 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 prepended has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    def self.prepended(base)
                                      base.instance_eval do
                                        has_many :targeting_hosts, :dependent => :destroy, :foreign_key => 'host_id'
                                        has_many :template_invocations, :dependent => :destroy, :foreign_key => 'host_id'
                                        has_one :execution_status_object, :class_name => 'HostStatus::ExecutionStatus', :foreign_key => 'host_id', :dependent => :destroy
                                Severity: Minor
                                Found in app/models/concerns/foreman_remote_execution/host_extensions.rb - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language