Katello/katello

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

Summary

Maintainability
F
4 days
Test Coverage

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

const CVDebFilterContent = ({
  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/CVDebFilterContent.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/CVDebFilterContent.js - About 30 mins to fix

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

                    <Split hasGutter>
                      <SplitItem>
                        <Button
                          ouiaId="create-deb-rule-button"
                          onClick={() => setModalOpen(true)}
    webpack/scenes/ContentViews/Details/Filters/CVRpmFilterContent.js on lines 209..233

    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/CVRpmFilterContent.js on lines 64..74

    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/CVRpmFilterContent.js on lines 76..95

    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

    CVDebFilterContent.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/CVRpmFilterContent.js on lines 259..269

    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-deb-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/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
    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

    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/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
    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

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

                    {showMatchContent &&
                      <CVDebMatchContentModal
                        key={`${filterId}-${filterRuleId}`}
                        filterRuleId={filterRuleId}
                        filterId={filterId}
    webpack/scenes/ContentViews/Details/Filters/CVRpmFilterContent.js on lines 200..206

    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/CVRpmFilterContent.js on lines 97..102

    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