RedHatInsights/insights-rbac-ui

View on GitHub

Showing 381 of 381 total issues

Function GroupRoles has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

const GroupRoles = ({ onDefaultGroupChanged }) => {
  const intl = useIntl();
  const chrome = useChrome();
  const dispatch = useDispatch();
  const navigate = useAppNavigate();
Severity: Minor
Found in src/smart-components/group/role/group-roles.js - About 5 hrs to fix

Cognitive Complexity

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

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

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

Further reading

Function ResourceDefinitions has 139 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const ResourceDefinitions = () => {
  const intl = useIntl();
  const [config, setConfig] = useState({
    pagination: {
      ...defaultSettings,
Severity: Major
Found in src/smart-components/role/role-resource-definitions.js - About 5 hrs to fix

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

                  <Grid>
                    <GridItem md={3}>
                      <Text component={TextVariants.h4} className="rbac-bold-text">
                        {intl.formatMessage(messages.members)}
                      </Text>
    Severity: Major
    Found in src/smart-components/group/add-group/summary-content.js and 1 other location - About 5 hrs to fix
    src/smart-components/group/add-group/summary-content.js on lines 50..63

    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

                  <Grid>
                    <GridItem md={3}>
                      <Text component={TextVariants.h4} className="rbac-bold-text">
                        {intl.formatMessage(messages.roles)}
                      </Text>
    Severity: Major
    Found in src/smart-components/group/add-group/summary-content.js and 1 other location - About 5 hrs to fix
    src/smart-components/group/add-group/summary-content.js on lines 64..77

    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

    Function AddPermissionsTable has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

    const AddPermissionsTable = ({ selectedPermissions, setSelectedPermissions, ...props }) => {
      const [isOrgAdmin, setIsOrgAdmin] = useState(null);
      const { auth } = useChrome();
      const dispatch = useDispatch();
      const intl = useIntl();
    Severity: Minor
    Found in src/smart-components/role/add-role/add-permissions.js - About 5 hrs 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

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

            actions={[
              <Button
                aria-label="Save"
                className="pf-v5-u-mr-sm"
                ouiaId="primary-save-button"
    Severity: Major
    Found in src/smart-components/user/invite-users/invite-users-modal.js and 1 other location - About 5 hrs to fix
    src/smart-components/user/add-user-to-group/add-user-to-group.js on lines 109..124

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

    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

            actions={[
              <Button
                aria-label="Save"
                className="pf-v5-u-mr-sm"
                ouiaId="primary-save-button"
    src/smart-components/user/invite-users/invite-users-modal.js on lines 83..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 138.

    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

            <StackItem>
              <TextContent>
                {intl.formatMessage(messages.addServiceAccountsToGroupDescription)}
                <Alert
                  className="pf-v5-u-mt-sm rbac-service-accounts-alert"
    src/smart-components/group/add-group/set-service-accounts.tsx on lines 35..53

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

    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

              <StackItem>
                <TextContent>
                  {intl.formatMessage(messages.addServiceAccountsToGroupDescription)}
                  <Alert
                    className="pf-v5-u-mt-sm rbac-service-accounts-alert"
    src/smart-components/group/service-account/add-group-service-accounts.tsx on lines 74..92

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

    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

    File add-permissions.js has 368 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React, { useCallback, useState, useEffect, useMemo } from 'react';
    import PropTypes from 'prop-types';
    import { shallowEqual, useSelector, useDispatch } from 'react-redux';
    import { useChrome } from '@redhat-cloud-services/frontend-components/useChrome';
    import useFieldApi from '@data-driven-forms/react-form-renderer/use-field-api';
    Severity: Minor
    Found in src/smart-components/role/add-role/add-permissions.js - About 4 hrs to fix

      Function InventoryGroupsRole has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

      const InventoryGroupsRole = (props) => {
        const intl = useIntl();
        const dispatch = useDispatch();
        const { input } = useFieldApi(props);
        const formOptions = useFormApi();
      Severity: Minor
      Found in src/smart-components/role/add-role/inventory-groups-role.js - About 4 hrs 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

      File toolbar.js has 363 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import React from 'react';
      import PrimaryToolbar from '@redhat-cloud-services/frontend-components/PrimaryToolbar';
      import { useIntl } from 'react-intl';
      import PropTypes from 'prop-types';
      import messages from '../../Messages';
      Severity: Minor
      Found in src/presentational-components/shared/toolbar.js - About 4 hrs to fix

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

                      <Grid>
                        <GridItem md={3}>
                          <Text component={TextVariants.h4} className="rbac-bold-text">
                            {intl.formatMessage(messages.groupName)}
                          </Text>
        Severity: Major
        Found in src/smart-components/group/add-group/summary-content.js and 1 other location - About 4 hrs to fix
        src/smart-components/group/add-group/summary-content.js on lines 40..49

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

        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

                      <Grid>
                        <GridItem md={3}>
                          <Text component={TextVariants.h4} className="rbac-bold-text">
                            {intl.formatMessage(messages.groupDescription)}
                          </Text>
        Severity: Major
        Found in src/smart-components/group/add-group/summary-content.js and 1 other location - About 4 hrs to fix
        src/smart-components/group/add-group/summary-content.js on lines 30..39

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

        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

        Function CostResources has 109 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const CostResources = (props) => {
          const intl = useIntl();
          const dispatch = useDispatch();
          const fetchData = (apiProps) => dispatch(fetchResourceDefinitions(apiProps));
          const getResource = (apiProps) => dispatch(fetchResource(apiProps));
        Severity: Major
        Found in src/smart-components/role/add-role/cost-resources.js - About 4 hrs to fix

          File group-roles.js has 346 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import React, { useState, useEffect, Fragment, useContext, useRef, Suspense } from 'react';
          import { useDispatch, useSelector } from 'react-redux';
          import { FormattedMessage, useIntl } from 'react-intl';
          import PropTypes from 'prop-types';
          import { Outlet, useParams } from 'react-router-dom';
          Severity: Minor
          Found in src/smart-components/group/role/group-roles.js - About 4 hrs to fix

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

              useEffect(() => {
                if (!location.pathname.includes('detail')) {
                  isPaginationPresentInUrl(location) || applyPaginationToUrl(location, navigate, pagination.limit, pagination.offset);
                  filterValue?.length > 0 &&
                    !areFiltersPresentInUrl(location, ['display_name']) &&
            Severity: Major
            Found in src/smart-components/role/roles.js and 1 other location - About 4 hrs to fix
            src/smart-components/group/groups.js on lines 108..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 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

              useEffect(() => {
                if (!location.pathname.includes('detail')) {
                  isPaginationPresentInUrl(location) || applyPaginationToUrl(location, navigate, pagination.limit, pagination.offset);
                  filterValue?.length > 0 &&
                    !areFiltersPresentInUrl(location, ['name']) &&
            Severity: Major
            Found in src/smart-components/group/groups.js and 1 other location - About 4 hrs to fix
            src/smart-components/role/roles.js on lines 100..109

            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

            Function Group has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

            const Group = () => {
              const intl = useIntl();
              const dispatch = useDispatch();
              const navigate = useAppNavigate();
              const location = useLocation();
            Severity: Minor
            Found in src/smart-components/group/group.js - About 4 hrs 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

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

                  <WarningModal
                    title={intl.formatMessage(messages.exitItemAdding, { item: intl.formatMessage(messages.users).toLocaleLowerCase() })}
                    isOpen={cancelWarningVisible}
                    onClose={() => setCancelWarningVisible(false)}
                    confirmButtonLabel={intl.formatMessage(messages.discard)}
            src/smart-components/role/add-role-permissions/add-role-permission-wizard.js on lines 132..140

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

            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

            Severity
            Category
            Status
            Source
            Language