theforeman/foreman_remote_execution

View on GitHub

Showing 250 of 250 total issues

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

RepeatCron.propTypes = {
  repeatData: PropTypes.object.isRequired,
  setRepeatData: PropTypes.func.isRequired,
  setValid: PropTypes.func.isRequired,
};
Severity: Major
Found in webpack/JobWizard/steps/Schedule/RepeatCron.js and 5 other locations - About 50 mins to fix
webpack/JobWizard/steps/AdvancedFields/AdvancedFields.js on lines 143..147
webpack/JobWizard/steps/HostsAndInputs/HostPreviewModal.js on lines 66..70
webpack/JobWizard/steps/Schedule/RepeatDaily.js on lines 33..37
webpack/JobWizard/steps/Schedule/RepeatMonth.js on lines 43..47
webpack/JobWizard/steps/Schedule/RepeatWeek.js on lines 68..72

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

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 7 locations. Consider refactoring.
Open

    act(() => {
      fireEvent.click(screen.getByRole('button', { name: 'Future execution' }));
      jest.advanceTimersByTime(1000); // to handle pf4 date picker popover useTimer
    });
Severity: Major
Found in webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js and 6 other locations - About 50 mins to fix
webpack/JobWizard/steps/ReviewDetails/ReviewDetails.test.js on lines 51..54
webpack/JobWizard/steps/ReviewDetails/ReviewDetails.test.js on lines 88..95
webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js on lines 144..147
webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js on lines 201..206
webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js on lines 251..256
webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js on lines 285..290

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

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 6 locations. Consider refactoring.
Open

RepeatMonth.propTypes = {
  repeatData: PropTypes.object.isRequired,
  setRepeatData: PropTypes.func.isRequired,
  setValid: PropTypes.func.isRequired,
};
Severity: Major
Found in webpack/JobWizard/steps/Schedule/RepeatMonth.js and 5 other locations - About 50 mins to fix
webpack/JobWizard/steps/AdvancedFields/AdvancedFields.js on lines 143..147
webpack/JobWizard/steps/HostsAndInputs/HostPreviewModal.js on lines 66..70
webpack/JobWizard/steps/Schedule/RepeatCron.js on lines 82..86
webpack/JobWizard/steps/Schedule/RepeatDaily.js on lines 33..37
webpack/JobWizard/steps/Schedule/RepeatWeek.js on lines 68..72

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

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 7 locations. Consider refactoring.
Open

    act(() => {
      fireEvent.click(
        screen.getByRole('button', { name: 'Recurring execution' })
      );
      jest.advanceTimersByTime(1000); // to handle pf4 date picker popover useTimer
Severity: Major
Found in webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js and 6 other locations - About 50 mins to fix
webpack/JobWizard/steps/ReviewDetails/ReviewDetails.test.js on lines 51..54
webpack/JobWizard/steps/ReviewDetails/ReviewDetails.test.js on lines 88..95
webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js on lines 106..109
webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js on lines 144..147
webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js on lines 201..206
webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js on lines 251..256

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

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 7 locations. Consider refactoring.
Open

    act(() => {
      fireEvent.click(
        screen.getByText('Target hosts', {
          selector: '.pf-c-button',
        })
Severity: Major
Found in webpack/JobWizard/steps/ReviewDetails/ReviewDetails.test.js and 6 other locations - About 50 mins to fix
webpack/JobWizard/steps/ReviewDetails/ReviewDetails.test.js on lines 51..54
webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js on lines 106..109
webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js on lines 144..147
webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js on lines 201..206
webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js on lines 251..256
webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js on lines 285..290

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

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 6 locations. Consider refactoring.
Open

RepeatWeek.propTypes = {
  repeatData: PropTypes.object.isRequired,
  setRepeatData: PropTypes.func.isRequired,
  setValid: PropTypes.func.isRequired,
};
Severity: Major
Found in webpack/JobWizard/steps/Schedule/RepeatWeek.js and 5 other locations - About 50 mins to fix
webpack/JobWizard/steps/AdvancedFields/AdvancedFields.js on lines 143..147
webpack/JobWizard/steps/HostsAndInputs/HostPreviewModal.js on lines 66..70
webpack/JobWizard/steps/Schedule/RepeatCron.js on lines 82..86
webpack/JobWizard/steps/Schedule/RepeatDaily.js on lines 33..37
webpack/JobWizard/steps/Schedule/RepeatMonth.js on lines 43..47

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

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

  beforeEach(() => {
    jest.spyOn(selectors, 'selectRouterSearch');
    selectors.selectRouterSearch.mockImplementation(() => ({
      'host_ids[]': ['105', '37'],
    }));
Severity: Major
Found in webpack/JobWizard/__tests__/integration.test.js and 2 other locations - About 50 mins to fix
webpack/JobWizard/steps/AdvancedFields/__tests__/AdvancedFields.test.js on lines 29..34
webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js on lines 62..67

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

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

APIHooks.useAPI.mockImplementation((action, url) => {
  if (url === '/ui_job_wizard/job_invocation?id=57') {
    return { response: jobInvocation, status: 'RESOLVED' };
  }
  return {};
Severity: Minor
Found in webpack/JobWizard/steps/ReviewDetails/ReviewDetails.test.js and 1 other location - About 50 mins to fix
webpack/JobWizard/__tests__/JobWizardPageRerun.test.js on lines 15..20

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

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

APIHooks.useAPI.mockImplementation((action, url) => {
  if (url === '/ui_job_wizard/job_invocation?id=57') {
    return { response: jobInvocation, status: 'RESOLVED' };
  }
  return {};
Severity: Minor
Found in webpack/JobWizard/__tests__/JobWizardPageRerun.test.js and 1 other location - About 50 mins to fix
webpack/JobWizard/steps/ReviewDetails/ReviewDetails.test.js on lines 22..27

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

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

  beforeEach(() => {
    jest.spyOn(selectors, 'selectRouterSearch');
    selectors.selectRouterSearch.mockImplementation(() => ({
      'host_ids[]': ['105', '37'],
    }));
webpack/JobWizard/__tests__/integration.test.js on lines 21..26
webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js on lines 62..67

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

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

  useEffect(() => {
    if (at) {
      setValid(true);
    } else {
      setValid(false);
Severity: Minor
Found in webpack/JobWizard/steps/Schedule/RepeatDaily.js and 1 other location - About 50 mins to fix
webpack/JobWizard/steps/Schedule/RepeatCron.js on lines 33..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 51.

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

  beforeEach(() => {
    jest.spyOn(selectors, 'selectRouterSearch');
    selectors.selectRouterSearch.mockImplementation(() => ({
      'host_ids[]': ['105', '37'],
    }));
Severity: Major
Found in webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js and 2 other locations - About 50 mins to fix
webpack/JobWizard/__tests__/integration.test.js on lines 21..26
webpack/JobWizard/steps/AdvancedFields/__tests__/AdvancedFields.test.js on lines 29..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 51.

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

  useEffect(() => {
    if (cronline) {
      setValid(true);
    } else {
      setValid(false);
Severity: Minor
Found in webpack/JobWizard/steps/Schedule/RepeatCron.js and 1 other location - About 50 mins to fix
webpack/JobWizard/steps/Schedule/RepeatDaily.js on lines 8..15

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

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

Avoid deeply nested control flow statements.
Open

              if (advanced) {
                setAdvancedValues(prev => ({
                  ...prev,
                  templateValues: { ...prev.templateValues, [input]: value },
                }));
Severity: Major
Found in webpack/JobWizard/autofill.js - About 45 mins 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 status has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def status
          if task.nil? || task.state == 'scheduled'
            QUEUED
          elsif task.state == 'stopped' && task.result == 'success'
            OK
    Severity: Minor
    Found in app/models/host_status/execution_status.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 cancel has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def cancel
        @job_invocation = resource_base.find(params[:id])
        result = @job_invocation.cancel(params[:force])
    
        if result
    Severity: Minor
    Found in app/controllers/job_invocations_controller.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

    Function JobInvocationSystemStatusChart has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const JobInvocationSystemStatusChart = ({
      data,
      isAlreadyStarted,
      formattedStartDate,
    }) => {
    Severity: Minor
    Found in webpack/JobInvocationDetail/JobInvocationSystemStatusChart.js - 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

    Function buildHostQuery has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    export const buildHostQuery = (selected, search) => {
      const { hosts, hostCollections, hostGroups } = selected;
      const hostsSearch = `id ^ (${hosts.map(({ id }) => id).join(',')})`;
      const hostCollectionsSearch = `host_collection_id ^ (${hostCollections
        .map(({ id }) => id)
    Severity: Minor
    Found in webpack/JobWizard/steps/HostsAndInputs/buildHostQuery.js - 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 permitted_actions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def permitted_actions(template)
          original = super(template)
    
          if template.is_a?(JobTemplate)
            original.unshift(authorized_for(controller: :job_invocations, action: :create) ? link_to(_('Run'), hash_for_new_job_invocation_path(:template_id => template.id).merge(:authorizer => authorizer)) : nil) unless template.snippet

    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

    Severity
    Category
    Status
    Source
    Language