Katello/katello

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

Summary

Maintainability
F
5 days
Test Coverage

File CVRpmFilterContent.js has 256 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';
Severity: Minor
Found in webpack/scenes/ContentViews/Details/Filters/CVRpmFilterContent.js - About 2 hrs to fix

    Function CVRpmFilterContent has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    const CVRpmFilterContent = ({
      cvId, filterId, inclusion, showAffectedRepos, setShowAffectedRepos, details,
    }) => {
      const response = useSelector(state => selectCVFilterRules(state, filterId), shallowEqual);
      const { results, ...metadata } = response;
    Severity: Minor
    Found in webpack/scenes/ContentViews/Details/Filters/CVRpmFilterContent.js - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Avoid too many return statements within this function.
    Open

        return 'All versions';
    Severity: Major
    Found in webpack/scenes/ContentViews/Details/Filters/CVRpmFilterContent.js - About 30 mins to fix

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

                        <Split hasGutter>
                          <SplitItem>
                            <Button
                              ouiaId="add-rpm-rule-button"
                              onClick={() => setModalOpen(true)}
      webpack/scenes/ContentViews/Details/Filters/CVDebFilterContent.js on lines 189..220

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

      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

        const versionText = (rule) => {
          const { version, min_version: minVersion, max_version: maxVersion } = rule;
      
          if (rule.version) return `Version ${version}`;
          if (rule.min_version && !rule.max_version) return `Greater than version ${minVersion}`;
      webpack/scenes/ContentViews/Details/Filters/CVDebFilterContent.js on lines 63..73

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

      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

        const buildRows = useCallback(() => {
          const newRows = [];
          results.forEach((rule) => {
            const {
              name, architecture, id, ...rest
      webpack/scenes/ContentViews/Details/Filters/CVDebFilterContent.js on lines 75..94

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

      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

      CVRpmFilterContent.propTypes = {
        cvId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
        filterId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
        inclusion: PropTypes.bool,
        showAffectedRepos: PropTypes.bool.isRequired,
      webpack/scenes/ContentViews/Details/Filters/CVDebFilterContent.js on lines 245..255

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

      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="cv-rpm-filter-content-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/CVPackageGroupFilterContent.js on lines 281..291

      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 rpmFilterIds =
            rows.filter(row => row.selected).map(selected => selected.id);
          dispatch(deleteContentViewFilterRules(filterId, rpmFilterIds, () => {
      webpack/scenes/ContentViews/Details/Filters/CVContainerImageFilterContent.js on lines 79..88

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

      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

          {
            title: __('Remove'),
            onClick: (_event, _rowId, { id }) => {
              dispatch(removeCVFilterRule(filterId, id, () => {
                dispatch(getCVFilterRules(filterId));
      webpack/scenes/ContentViews/Details/Filters/CVContainerImageFilterContent.js on lines 113..121

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

      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/CVPackageGroupFilterContent.js on lines 207..219
      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/CVPackageGroupFilterContent.js on lines 153..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 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

        const primaryActionButton =
          (
            <Button
              ouiaId="add-rpm-rule-button"
              onClick={() => setModalOpen(true)}
      webpack/scenes/ContentViews/Details/Filters/CVContainerImageFilterContent.js on lines 59..67
      webpack/scenes/ContentViews/Details/Versions/ContentViewVersions.js on lines 81..89

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

                      {showMatchContent &&
                        <CVRpmMatchContentModal
                          key={`${filterId}-${filterRuleId}`}
                          filterRuleId={filterRuleId}
                          filterId={filterId}
      webpack/scenes/ContentViews/Details/Filters/CVDebFilterContent.js on lines 182..188

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

      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

        useDeepCompareEffect(() => {
          if (!loading && results) {
            const newRows = buildRows(results);
            setRows(newRows);
          }
      webpack/scenes/ContentViews/Details/ComponentContentViews/ContentViewComponents.js on lines 235..240
      webpack/scenes/ContentViews/Details/Filters/CVDebFilterContent.js on lines 96..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 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

      There are no issues that match your filters.

      Category
      Status