RedHatInsights/insights-rbac-ui

View on GitHub

Showing 381 of 381 total issues

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

export const fetchRole = (apiProps) => ({
  type: ActionTypes.FETCH_ROLE,
  payload: RoleHelper.fetchRole(apiProps).catch((err) => {
    const error = err?.errors?.[0] || {};
    if (error.status === '400' && error.source === 'role uuid validation') {
Severity: Major
Found in src/redux/actions/role-actions.js and 1 other location - About 3 hrs to fix
src/redux/actions/role-actions.js on lines 40..50

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

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

Function createITLessRows has 76 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const createITLessRows = (userLinks, data, checkedRows = []) => {
    const maxLength = 25;
    return data
      ? data.reduce(
          (
Severity: Major
Found in src/smart-components/group/add-group/users-list-itless.js - About 3 hrs to fix

    Function renderTable has 73 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const renderTable = () => {
        const orderBy = `${sortBy?.direction === 'desc' ? '-' : ''}${columns[sortBy?.index]?.key}`;
        return (
          <Fragment>
            <Toolbar
    Severity: Major
    Found in src/presentational-components/shared/table-toolbar-view.js - About 2 hrs to fix

      Function ReviewTemplate has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

      const ReviewTemplate = ({ formFields }) => {
        const intl = useIntl();
        const navigate = useAppNavigate();
        const { submittingGroup, submittingServiceAccounts, error, setWizardError } = useContext(AddGroupWizardContext);
        const { getState } = useFormApi();
      Severity: Minor
      Found in src/smart-components/group/add-group/review-template.js - About 2 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 group-actions.js has 287 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import * as ActionTypes from '../action-types';
      import * as GroupHelper from '../../helpers/group/group-helper';
      import { createIntl, createIntlCache } from 'react-intl';
      import { BAD_UUID } from '../../helpers/shared/helpers';
      import messages from '../../Messages';
      Severity: Minor
      Found in src/redux/actions/group-actions.js - About 2 hrs to fix

        Function SetName has 72 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const SetName = (props) => {
          const intl = useIntl();
          const { input } = useFieldApi(props);
          const formOptions = useFormApi();
          const { 'role-name': name, 'role-description': description } = formOptions.getState().values;
        Severity: Major
        Found in src/smart-components/role/add-role/set-name.js - About 2 hrs to fix

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

                dispatch(
                  addNotification({
                    variant: 'info',
                    title: intl.formatMessage(userList.length > 1 ? messages.addingGroupMembersTitle : messages.addingGroupMemberTitle),
                    dismissDelay: 8000,
          Severity: Major
          Found in src/smart-components/group/member/add-group-members.js and 1 other location - About 2 hrs to fix
          src/smart-components/group/member/add-group-members.js on lines 48..55

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

          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

              dispatch(
                addNotification({
                  variant: 'warning',
                  title: intl.formatMessage(selectedUsers.length > 1 ? messages.addingGroupMembersTitle : messages.addingGroupMemberTitle),
                  dismissDelay: 8000,
          Severity: Major
          Found in src/smart-components/group/member/add-group-members.js and 1 other location - About 2 hrs to fix
          src/smart-components/group/member/add-group-members.js on lines 31..38

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

          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 SetName has 70 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const SetName = (props) => {
            const intl = useIntl();
            const { input } = useFieldApi(props);
            const formOptions = useFormApi();
            const { 'group-name': name, 'group-description': description } = formOptions.getState().values;
          Severity: Major
          Found in src/smart-components/group/add-group/set-name.js - About 2 hrs to fix

            File Routing.tsx has 282 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import { Navigate, Route as RouterRoute, Routes as RouterRoutes, matchPath, useLocation } from 'react-router-dom';
            import React, { lazy, Suspense, useEffect, useMemo } from 'react';
            import { useChrome } from '@redhat-cloud-services/frontend-components/useChrome';
            import { AppPlaceholder } from './presentational-components/shared/loader-placeholders';
            import pathnames from './utilities/pathnames';
            Severity: Minor
            Found in src/Routing.tsx - About 2 hrs to fix

              Function UsersAndUserGroups has 69 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const UsersAndUserGroups: React.FunctionComponent = () => {
                const intl = useIntl();
                const [activeTabKey, setActiveTabKey] = React.useState<number>(0);
                const [isAddUserGroupModalOpen, setIsAddUserGroupModalOpen] = React.useState<boolean>(false);
                const [selectedUsers, setSelectedUsers] = React.useState<any[]>([]);
              Severity: Major
              Found in src/smart-components/access-management/users-and-user-groups.tsx - About 2 hrs to fix

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

                  const debouncedGetOperationOptions = useCallback(
                    debouncePromise(
                      ({ applications, resources, operations }) =>
                        fetchOptions({ field: 'verb', limit: 50, application: applications.join(), resourceType: resources.join(), verb: operations.join() }),
                      2000
                Severity: Major
                Found in src/smart-components/role/add-role/add-permissions.js and 2 other locations - About 2 hrs to fix
                src/smart-components/role/add-role/add-permissions.js on lines 134..147
                src/smart-components/role/add-role/add-permissions.js on lines 148..161

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

                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

                                  <ActionListItem>
                                    <AppLink to={pathnames.roles.link}>
                                      <Button variant="secondary" aria-label="View roles" size="lg" ouiaId="getstarted-view-roles-button">
                                        {intl.formatMessage(messages.viewRolesBtn)}
                                      </Button>
                Severity: Major
                Found in src/smart-components/overview/overview.js and 1 other location - About 2 hrs to fix
                src/smart-components/overview/overview.js on lines 78..84

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

                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 debouncedGetResourceOptions = useCallback(
                    debouncePromise(
                      ({ applications, resources, operations }) =>
                        fetchOptions({
                          field: 'resource_type',
                Severity: Major
                Found in src/smart-components/role/add-role/add-permissions.js and 2 other locations - About 2 hrs to fix
                src/smart-components/role/add-role/add-permissions.js on lines 134..147
                src/smart-components/role/add-role/add-permissions.js on lines 162..169

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

                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 debouncedGetApplicationOptions = useCallback(
                    debouncePromise(
                      ({ applications, resources, operations }) =>
                        fetchOptions({
                          field: 'application',
                Severity: Major
                Found in src/smart-components/role/add-role/add-permissions.js and 2 other locations - About 2 hrs to fix
                src/smart-components/role/add-role/add-permissions.js on lines 148..161
                src/smart-components/role/add-role/add-permissions.js on lines 162..169

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

                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

                                  <ActionListItem>
                                    <AppLink to={pathnames.groups.link}>
                                      <Button variant="primary" size="lg" aria-label="View groups" ouiaId="getstarted-view-groups-button">
                                        {intl.formatMessage(messages.viewGroupsBtn)}
                                      </Button>
                Severity: Major
                Found in src/smart-components/overview/overview.js and 1 other location - About 2 hrs to fix
                src/smart-components/overview/overview.js on lines 85..91

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

                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 handleBulkSelect = (value: BulkSelectValue) => {
                    if (value === BulkSelectValue.none) {
                      onSelect(false);
                    } else if (value === BulkSelectValue.page) {
                      onSelect(true, rows);
                Severity: Major
                Found in src/smart-components/access-management/UsersTable.tsx and 1 other location - About 2 hrs to fix
                src/smart-components/access-management/UserGroupsTable.tsx on lines 101..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 89.

                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 handleBulkSelect = (value: BulkSelectValue) => {
                    if (value === BulkSelectValue.none) {
                      onSelect(false);
                    } else if (value === BulkSelectValue.page) {
                      onSelect(true, rows);
                Severity: Major
                Found in src/smart-components/access-management/UserGroupsTable.tsx and 1 other location - About 2 hrs to fix
                src/smart-components/access-management/UsersTable.tsx on lines 76..84

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

                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 MyUserAccess has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const MyUserAccess = () => {
                  const intl = useIntl();
                  const chrome = useChrome();
                  const [user, setUser] = useState({});
                  const [{ bundle }, setSearchParams] = useSearchParams();
                Severity: Major
                Found in src/smart-components/myUserAccess/MUAHome.js - About 2 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language