Katello/katello

View on GitHub
webpack/components/extensions/HostDetails/Tabs/ModuleStreamsTab/ModuleStreamsTab.js

Summary

Maintainability
F
1 wk
Test Coverage

Function ModuleStreamsTab has 447 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const ModuleStreamsTab = () => {
  const hostDetails = useSelector(selectHostDetails);
  const { id: hostId, name: hostname } = hostDetails;
  const showActions = can(invokeRexJobs, userPermissionsFromHostDetails({ hostDetails }));
  const [useCustomizedRex, setUseCustomizedRex] = useState('');

    File ModuleStreamsTab.js has 644 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React, { useCallback, useState } from 'react';
    import { useSelector } from 'react-redux';
    import { FormattedMessage } from 'react-intl';
    import { translate as __ } from 'foremanReact/common/I18n';
    import { Skeleton,

      Consider simplifying this complex logical expression.
      Open

                    if (id === useCustomizedRex) {
                      dropdownItems.push(
                        <DropdownItem
                          aria-label={`enable-${id}-href`}
                          ouiaId={`enable-${id}-href`}

        Function ModuleStreamsTab has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        export const ModuleStreamsTab = () => {
          const hostDetails = useSelector(selectHostDetails);
          const { id: hostId, name: hostname } = hostDetails;
          const showActions = can(invokeRexJobs, userPermissionsFromHostDetails({ hostDetails }));
          const [useCustomizedRex, setUseCustomizedRex] = useState('');

        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

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

                          <DropdownItem
                            aria-label={`remove-${id}-button`}
                            ouiaId={`remove-${id}-button`}
                            key={`dropdownItem-remove-${id}`}
                            component="button"
        webpack/components/extensions/HostDetails/Tabs/ModuleStreamsTab/ModuleStreamsTab.js on lines 578..594

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

        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

                          <DropdownItem
                            aria-label={`reset-${id}-button`}
                            ouiaId={`reset-${id}-button`}
                            key={`dropdownItem-reset-${id}`}
                            component="button"
        webpack/components/extensions/HostDetails/Tabs/ModuleStreamsTab/ModuleStreamsTab.js on lines 595..611

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

        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

                          <DropdownItem
                            aria-label={`reset-${id}-href`}
                            ouiaId={`reset-${id}-href`}
                            key={`dropdownItem-reset-${id}`}
                            component="a"
        webpack/components/extensions/HostDetails/Tabs/ModuleStreamsTab/ModuleStreamsTab.js on lines 500..509

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

        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

                          <DropdownItem
                            aria-label={`remove-${id}-href`}
                            ouiaId={`remove-${id}-href`}
                            key={`dropdownItem-remove-${id}`}
                            component="a"
        webpack/components/extensions/HostDetails/Tabs/ModuleStreamsTab/ModuleStreamsTab.js on lines 490..499

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

        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

                          <DropdownItem
                            aria-label={`enable-${id}-href`}
                            ouiaId={`enable-${id}-href`}
                            key={`dropdownItem-enable-url-${id}`}
                            component="a"
        webpack/components/extensions/HostDetails/Tabs/ModuleStreamsTab/ModuleStreamsTab.js on lines 454..465

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

        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

                          <DropdownItem
                            aria-label={`disable-${id}-href`}
                            ouiaId={`disable-${id}-href`}
                            key={`dropdownItem-disable-url-${id}`}
                            component="a"
        webpack/components/extensions/HostDetails/Tabs/ModuleStreamsTab/ModuleStreamsTab.js on lines 443..453

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

        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

          case 'disable':
            confirmText = __('Disable');
            title = __('Disable module stream');
            body = (
              <FormattedMessage
        webpack/components/extensions/HostDetails/Tabs/ModuleStreamsTab/ModuleStreamsTab.js on lines 132..145

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

        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

          case 'reset':
            confirmText = __('Reset');
            title = __('Reset module stream');
            body = (
              <FormattedMessage
        webpack/components/extensions/HostDetails/Tabs/ModuleStreamsTab/ModuleStreamsTab.js on lines 118..131

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

        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

                {actionModalOpen &&
                  <ModuleActionConfirmationModal
                    hostname={hostname}
                    action={hostModuleStreamAction}
                    moduleSpec={actionableModuleSpec}
        webpack/components/extensions/HostDetails/Tabs/DebsTab/DebsTab.js on lines 571..580

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

        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

                            onClick={() => {
                              triggerModuleStreamAction({ hostname, action: 'install', moduleSpec });
                              setUseCustomizedRex('');
                              setDropdownOpen('');
                            }}
        webpack/components/extensions/HostDetails/Tabs/ModuleStreamsTab/ModuleStreamsTab.js on lines 518..522
        webpack/components/extensions/HostDetails/Tabs/ModuleStreamsTab/ModuleStreamsTab.js on lines 569..573

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

        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

                            onClick={() => {
                              triggerModuleStreamAction({ hostname, action: 'enable', moduleSpec });
                              setUseCustomizedRex('');
                              setDropdownOpen('');
                            }}
        webpack/components/extensions/HostDetails/Tabs/ModuleStreamsTab/ModuleStreamsTab.js on lines 551..555
        webpack/components/extensions/HostDetails/Tabs/ModuleStreamsTab/ModuleStreamsTab.js on lines 569..573

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

        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

                            onClick={() => {
                              triggerModuleStreamAction({ hostname, action: 'update', moduleSpec });
                              setUseCustomizedRex('');
                              setDropdownOpen('');
                            }}
        webpack/components/extensions/HostDetails/Tabs/ModuleStreamsTab/ModuleStreamsTab.js on lines 518..522
        webpack/components/extensions/HostDetails/Tabs/ModuleStreamsTab/ModuleStreamsTab.js on lines 551..555

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

        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

          const {
            pfSortParams, apiSortParams,
            activeSortColumn, activeSortDirection,
          } = useTableSort({
            allColumns: columnHeaders,
        webpack/components/extensions/HostDetails/Tabs/DebsTab/DebsTab.js on lines 175..182
        webpack/components/extensions/HostDetails/Tabs/ErrataTab/ErrataTab.js on lines 171..178
        webpack/components/extensions/HostDetails/Tabs/PackagesTab/PackagesTab.js on lines 182..189
        webpack/components/extensions/HostDetails/Tabs/TracesTab/TracesTab.js on lines 66..73
        webpack/scenes/AlternateContentSources/MainTable/ACSTable.js on lines 247..254
        webpack/scenes/ContentViews/Table/ContentViewsTable.js on lines 60..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 48.

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

          const {
            selectOne, isSelected, searchQuery, selectedCount, isSelectable,
            updateSearchQuery, selectNone, fetchBulkParams, ...selectAll
          } = useBulkSelect({
            results,
        webpack/components/extensions/HostDetails/Cards/HostCollectionsCard/HostCollectionsModal.js on lines 56..70
        webpack/components/extensions/HostDetails/Tabs/ErrataTab/ErrataTab.js on lines 219..229
        webpack/components/extensions/HostDetails/Tabs/RepositorySetsTab/RepositorySetsTab.js on lines 294..302
        webpack/scenes/ContentViews/Details/Filters/CVErrataIDFilterContent.js on lines 91..101

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

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

                        <Tr key={`${id} ${index}`} ouiaId={`tr-${id}-${index}`}>
                          <Td>
                            <a
                              href={`/module_streams?search=module_spec%3D${moduleSpec}+and+host%3D${hostname}`}
                            >
        webpack/scenes/ContentViews/Delete/Steps/CVDeleteEnvironmentsSelection.js on lines 81..95
        webpack/scenes/ContentViews/Details/Versions/BulkDelete/Steps/ReviewEnvironments.js on lines 83..96
        webpack/scenes/ContentViews/Details/Versions/Delete/RemoveSteps/CVEnvironmentSelectionForm.js on lines 102..117

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

        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

        There are no issues that match your filters.

        Category
        Status