Katello/katello

View on GitHub
webpack/scenes/ContentViews/Details/Filters/CVPackageGroupFilterContent.js

Summary

Maintainability
F
4 days
Test Coverage

File CVPackageGroupFilterContent.js has 286 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React, { useState, useEffect, useCallback } from 'react';
import useDeepCompareEffect from 'use-deep-compare-effect';
import PropTypes from 'prop-types';
import { shallowEqual, useSelector, useDispatch } from 'react-redux';
import { TableVariant } from '@patternfly/react-table';

    Function buildRows has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const buildRows = useCallback(() => {
        const newRows = [];
        const filterRules = filterResults.find(({ id }) => id === Number(filterId))?.rules || [];
        results.forEach((packageGroups) => {
          const {

      Function CVPackageGroupFilterContent has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      const CVPackageGroupFilterContent = ({
        cvId, filterId, showAffectedRepos, setShowAffectedRepos, details,
      }) => {
        const dispatch = useDispatch();
        const { results: filterResults } =

      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

        const fetchItems = useCallback((params) => {
          const adjustedParams = { ...params };
          switch (selectedIndex) {
          case 0:
            adjustedParams.show_all_for = 'content_view_filter';
      webpack/scenes/ContentViews/Details/Filters/CVModuleStreamFilterContent.js on lines 79..98

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

      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

      CVPackageGroupFilterContent.propTypes = {
        cvId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
        filterId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
        showAffectedRepos: PropTypes.bool.isRequired,
        setShowAffectedRepos: PropTypes.func.isRequired,
      webpack/scenes/ContentViews/Details/Filters/AffectedRepositories/AffectedRepositoryTable.js on lines 266..274
      webpack/scenes/ContentViews/Details/Filters/CVErrataIDFilterContent.js on lines 473..481
      webpack/scenes/ContentViews/Details/Filters/CVModuleStreamFilterContent.js on lines 306..314

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

      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

                        <SplitItem>
                          <Dropdown
                            toggle={<KebabToggle aria-label="bulk_actions" onToggle={toggleBulkAction} />}
                            isOpen={bulkActionOpen}
                            ouiaId="cv-package-group-filter-bulk-actions-dropdown"
      webpack/scenes/ContentViews/Details/Filters/CVContainerImageFilterContent.js on lines 180..192
      webpack/scenes/ContentViews/Details/Filters/CVErrataIDFilterContent.js on lines 339..351
      webpack/scenes/ContentViews/Details/Filters/CVModuleStreamFilterContent.js on lines 273..285
      webpack/scenes/ContentViews/Details/Filters/ContentViewFilters.js on lines 160..172

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

      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

            {(repositories.length || showAffectedRepos) &&
              <Tab
                ouiaId="affected-repos-tab"
                eventKey={1}
                title={<TabTitleText>{__('Affected repositories')}</TabTitleText>}
      webpack/scenes/ContentViews/Details/Filters/CVContainerImageFilterContent.js on lines 206..216
      webpack/scenes/ContentViews/Details/Filters/CVDebFilterContent.js on lines 231..240
      webpack/scenes/ContentViews/Details/Filters/CVErrataDateFilterContent.js on lines 317..326
      webpack/scenes/ContentViews/Details/Filters/CVErrataIDFilterContent.js on lines 458..468
      webpack/scenes/ContentViews/Details/Filters/CVModuleStreamFilterContent.js on lines 291..301
      webpack/scenes/ContentViews/Details/Filters/CVRpmFilterContent.js on lines 245..254

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

      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

        const bulkRemove = () => {
          setBulkActionOpen(false);
          const packageFilterIds =
            rows.filter(({ selected, added }) =>
              selected && added).map(({ packagefilterId }) => packagefilterId);
      webpack/scenes/ContentViews/Details/Filters/CVModuleStreamFilterContent.js on lines 151..159

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

      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

                        <SplitItem>
                          <Button
                            ouiaId="add-package-group-filter-rule-button"
                            isDisabled={!hasNotAddedSelected}
                            onClick={bulkAdd}
      webpack/scenes/ContentViews/Details/Filters/CVErrataIDFilterContent.js on lines 332..336
      webpack/scenes/ContentViews/Details/Filters/CVModuleStreamFilterContent.js on lines 262..272

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

      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

                  {...{
                    rows,
                    metadata,
                    emptyContentTitle,
                    emptyContentBody,
      webpack/scenes/ContentViews/Details/Filters/CVContainerImageFilterContent.js on lines 145..157
      webpack/scenes/ContentViews/Details/Filters/CVModuleStreamFilterContent.js on lines 217..229
      webpack/scenes/ContentViews/Details/Filters/CVRpmFilterContent.js on lines 177..189
      webpack/scenes/SmartProxy/SmartProxyExpandableTable.js on lines 58..70

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

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

        useEffect(() => {
          if (!repositories.length && showAffectedRepos) {
            setActiveTabKey(1);
          } else {
            setActiveTabKey(0);
      webpack/scenes/ContentViews/Details/Filters/CVContainerImageFilterContent.js on lines 90..96
      webpack/scenes/ContentViews/Details/Filters/CVDebFilterContent.js on lines 103..109
      webpack/scenes/ContentViews/Details/Filters/CVErrataDateFilterContent.js on lines 106..112
      webpack/scenes/ContentViews/Details/Filters/CVErrataIDFilterContent.js on lines 150..156
      webpack/scenes/ContentViews/Details/Filters/CVModuleStreamFilterContent.js on lines 161..167
      webpack/scenes/ContentViews/Details/Filters/CVRpmFilterContent.js on lines 104..110

      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

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

          return newRows.sort(({ added: addedA }, { added: addedB }) => {
            if (addedA === addedB) return 0;
            return addedA ? -1 : 1;
          });
      webpack/scenes/ContentViews/Details/Filters/AffectedRepositories/AffectedRepositoryTable.js on lines 99..102
      webpack/scenes/ContentViews/Details/Filters/CVErrataIDFilterContent.js on lines 127..130
      webpack/scenes/ContentViews/Details/Filters/CVModuleStreamFilterContent.js on lines 136..139

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

      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

        useDeepCompareEffect(() => {
          if (!loading && results) {
            const newRows = buildRows();
            setRows(newRows);
          }
      webpack/scenes/ContentViews/Details/Filters/ContentViewFilters.js on lines 95..100

      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

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

                          <Select
                            variant={SelectVariant.single}
                            onToggle={setSelectOpen}
                            ouiaId="allAddedNotAdded"
                            onSelect={(_event, selection) => {
      webpack/scenes/ContentViews/Details/Filters/CVModuleStreamFilterContent.js on lines 246..260

      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