RedHatInsights/insights-rbac-ui

View on GitHub

Showing 109 of 381 total issues

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

      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

          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

          Function EnableWorkspacesAlert has 101 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const EnableWorkspacesAlert: React.FunctionComponent = () => {
            const [checked, setChecked] = React.useState<boolean>(false);
            const [isModalOpen, setIsModalOpen] = React.useState<boolean>(false);
            const [isConfirmed, setIsConfirmed] = React.useState<boolean>(false);
            const intl = useIntl();
          Severity: Major
          Found in src/smart-components/overview/enable-workspaces-alert.tsx - About 4 hrs to fix

            File inventory-groups-role.js has 328 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import React, { useEffect, useReducer } from 'react';
            import {
              Button,
              Grid,
              GridItem,
            Severity: Minor
            Found in src/smart-components/role/add-role/inventory-groups-role.js - About 3 hrs to fix

              Function schemaBuilder has 94 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const schemaBuilder = (container, enableServiceAccounts) => {
                const cache = createIntlCache();
                const intl = createIntl({ locale, messages: providerMessages }, cache);
                return {
                  fields: [
              Severity: Major
              Found in src/smart-components/group/add-group/schema.js - About 3 hrs to fix

                Function ReviewStep has 92 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const ReviewStep = () => {
                  const intl = useIntl();
                  const enableWorkspacesNameChange = useFlag('platform.rbac.groups-to-workspaces-rename');
                  const formOptions = useFormApi();
                  const {
                Severity: Major
                Found in src/smart-components/role/add-role/review.js - About 3 hrs to fix

                  File user.js has 318 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import React, { useEffect, useState, useContext, Fragment, Suspense } from 'react';
                  import { useDispatch, useSelector } from 'react-redux';
                  import { Outlet, useNavigationType, useParams } from 'react-router-dom';
                  import { useIntl } from 'react-intl';
                  import { Button, Label, Stack, StackItem, Text, TextContent, TextVariants } from '@patternfly/react-core';
                  Severity: Minor
                  Found in src/smart-components/user/user.js - About 3 hrs to fix

                    Function TableToolbarView has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export const TableToolbarView = ({
                      className,
                      isCompact,
                      borders,
                      columns,
                    Severity: Minor
                    Found in src/presentational-components/shared/table-toolbar-view.js - About 3 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 role-permissions.js has 314 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import React, { useEffect, useReducer, useState } from 'react';
                    import PropTypes from 'prop-types';
                    import { cellWidth, info } from '@patternfly/react-table';
                    import { Button, ButtonVariant } from '@patternfly/react-core';
                    import { FormattedMessage, useIntl } from 'react-intl';
                    Severity: Minor
                    Found in src/smart-components/role/role-permissions.js - About 3 hrs to fix

                      Function SummaryContent has 88 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const SummaryContent = () => {
                        const intl = useIntl();
                        const formOptions = useFormApi();
                        const { isBeta } = useChrome();
                        const {
                      Severity: Major
                      Found in src/smart-components/group/add-group/summary-content.js - About 3 hrs to fix

                        Function schemaBuilder has 86 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export const schemaBuilder = (container, featureFlag) => {
                          const cache = createIntlCache();
                          const intl = createIntl({ locale, messages: providerMessages }, cache);
                        
                          return {
                        Severity: Major
                        Found in src/smart-components/role/add-role-permissions/schema.js - About 3 hrs to fix

                          Function BaseRoleTable has 85 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const BaseRoleTable = (props) => {
                            const intl = useIntl();
                            const dispatch = useDispatch();
                            const fetchData = (options) => dispatch(fetchRolesForWizard(options));
                            const [filterValue, setFilterValue] = useState('');
                          Severity: Major
                          Found in src/smart-components/role/add-role/base-role-table.js - About 3 hrs to fix

                            Function reducer has 81 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            const reducer = (state, action) => {
                              const prevState = state[action.key];
                              switch (action.type) {
                                case 'toggle':
                                  return {
                            Severity: Major
                            Found in src/smart-components/role/add-role/inventory-groups-role.js - About 3 hrs to fix

                              File table-composable-toolbar-view.tsx has 300 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              import React, { Fragment } from 'react';
                              import { useIntl } from 'react-intl';
                              import messages from '../../Messages';
                              import { TableVariant, Table, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
                              import TableToolbar from '@redhat-cloud-services/frontend-components/TableToolbar';

                                Function makeRow has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  const makeRow = (permissionID, index) => {
                                    const options = Object.values(resourceTypes?.[permissionID] ?? {});
                                
                                    return (
                                      <React.Fragment key={permissionID}>
                                Severity: Major
                                Found in src/smart-components/role/add-role/inventory-groups-role.js - About 3 hrs to fix

                                  Function activeFiltersConfigBuilder has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  export const activeFiltersConfigBuilder = (
                                    filterValue = '',
                                    filters,
                                    pagination = {},
                                    setFilterValue = () => undefined,
                                  Severity: Minor
                                  Found in src/presentational-components/shared/toolbar.js - About 3 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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language