theforeman/foreman_remote_execution

View on GitHub

Showing 230 of 230 total issues

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

      } else if (action.key === 'JOB_TEMPLATE') {
        handleSuccess &&
          handleSuccess({
            data: {
              ...jobTemplateResponse,
webpack/JobWizard/steps/AdvancedFields/__tests__/AdvancedFields.test.js on lines 326..361

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

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

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

      } else if (action.key === 'JOB_TEMPLATE') {
        handleSuccess &&
          handleSuccess({
            data: {
              ...jobTemplateResponse,
webpack/JobWizard/steps/AdvancedFields/__tests__/AdvancedFields.test.js on lines 268..287

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

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

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

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

                  {!isEmpty(missingPermissions) && (
                    <Alert
                      ouiaId="host-access-denied"
                      variant="warning"
                      title={__('Access denied')}
          Severity: Major
          Found in webpack/JobWizard/steps/HostsAndInputs/index.js and 1 other location - About 2 hrs to fix
          webpack/JobWizard/steps/CategoryAndTemplate/CategoryAndTemplate.js on lines 102..116

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

          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

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

                  {!isEmpty(missingPermissions) && (
                    <Alert
                      ouiaId="category-and-template-access-denied"
                      variant="warning"
                      title={__('Access denied')}
          webpack/JobWizard/steps/HostsAndInputs/index.js on lines 250..264

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

          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

          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

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

                await act(async () => {
                  await fireEvent.change(startsAtDateField(), {
                    target: { value: newStartAtDate },
                  });
                  fireEvent.change(startsAtTimeField(), {
            Severity: Major
            Found in webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js and 2 other locations - About 2 hrs to fix
            webpack/JobWizard/steps/ReviewDetails/ReviewDetails.test.js on lines 62..70
            webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js on lines 238..246

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

            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

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

                await act(async () => {
                  await fireEvent.change(endsAtDateField(), {
                    target: { value: newStartAtDate },
                  });
                  fireEvent.change(endsAtTimeField(), {
            Severity: Major
            Found in webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js and 2 other locations - About 2 hrs to fix
            webpack/JobWizard/steps/ReviewDetails/ReviewDetails.test.js on lines 62..70
            webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js on lines 223..231

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

            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

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

                await act(async () => {
                  await fireEvent.change(startsAtDateField(), {
                    target: { value: newStartAtDate },
                  });
                  fireEvent.change(startsAtTimeField(), {
            Severity: Major
            Found in webpack/JobWizard/steps/ReviewDetails/ReviewDetails.test.js and 2 other locations - About 2 hrs to fix
            webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js on lines 223..231
            webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js on lines 238..246

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

            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

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

                    {detailsSecondHalf.map(({ label, value }, index) => (
                      <DescriptionListGroup key={index}>
                        <DescriptionListTerm>{label}</DescriptionListTerm>
                        <DescriptionListDescription>
                          {value || ''}
            Severity: Major
            Found in webpack/JobWizard/steps/ReviewDetails/index.js and 1 other location - About 2 hrs to fix
            webpack/JobWizard/steps/ReviewDetails/index.js on lines 300..307

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

            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

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

                    {detailsFirstHalf.map(({ label, value }, index) => (
                      <DescriptionListGroup key={index}>
                        <DescriptionListTerm>{label}</DescriptionListTerm>
                        <DescriptionListDescription>
                          {value || ''}
            Severity: Major
            Found in webpack/JobWizard/steps/ReviewDetails/index.js and 1 other location - About 2 hrs to fix
            webpack/JobWizard/steps/ReviewDetails/index.js on lines 317..324

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

            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

            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

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

                render(
                  <MockedProvider mocks={gqlMock} addTypename={false}>
                    <Provider store={store}>
                      <JobWizardPageRerun
                        match={{
            Severity: Major
            Found in webpack/JobWizard/steps/ReviewDetails/ReviewDetails.test.js and 1 other location - About 2 hrs to fix
            webpack/JobWizard/__tests__/JobWizardPageRerun.test.js on lines 24..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 79.

            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

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

                render(
                  <MockedProvider mocks={gqlMock} addTypename={false}>
                    <Provider store={store}>
                      <JobWizardPageRerun
                        match={{
            Severity: Major
            Found in webpack/JobWizard/__tests__/JobWizardPageRerun.test.js and 1 other location - About 2 hrs to fix
            webpack/JobWizard/steps/ReviewDetails/ReviewDetails.test.js on lines 30..40

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

            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

            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

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

                if (response.subtotal > maxResults) {
                  selectOptions = [
                    <SelectOption
                      isDisabled
                      key={0}
              Severity: Major
              Found in webpack/JobWizard/steps/form/SearchSelect.js and 1 other location - About 1 hr to fix
              webpack/JobWizard/steps/form/ResourceSelect.js on lines 45..59

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

              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

              Severity
              Category
              Status
              Source
              Language