RedHatInsights/insights-rbac-ui

View on GitHub

Showing 381 of 381 total issues

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

      <WarningModal
        title={intl.formatMessage(messages.exitItemAdding, { item: intl.formatMessage(messages.permissions).toLocaleLowerCase() })}
        isOpen={cancelWarningVisible}
        onClose={() => setCancelWarningVisible(false)}
        confirmButtonLabel={intl.formatMessage(messages.discard)}
src/smart-components/user/add-user-to-group/add-user-to-group.js on lines 95..103

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

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

    dispatch(updateUsers(newUserList))
      .then(() => {
        setFilters(newFilters);
        if (setSelectedUsers) {
          setSelectedUsers([]);
Severity: Major
Found in src/smart-components/group/add-group/users-list-itless.js and 1 other location - About 4 hrs to fix
src/smart-components/group/add-group/users-list-itless.js on lines 154..166

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

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(updateUserIsOrgAdminStatus(newUserObj))
      .then(() => {
        setFilters(newFilters);
        if (setSelectedUsers) {
          setSelectedUsers([]);
Severity: Major
Found in src/smart-components/group/add-group/users-list-itless.js and 1 other location - About 4 hrs to fix
src/smart-components/group/add-group/users-list-itless.js on lines 229..241

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

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

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

      useEffect(() => {
        if (usesMetaInURL) {
          isPaginationPresentInUrl(location) || applyPaginationToUrl(location, navigate, pagination.limit, pagination.offset);
          Object.values(filters).some((filter) => filter?.length > 0) &&
            !areFiltersPresentInUrl(location, Object.keys(filters)) &&
    Severity: Major
    Found in src/smart-components/group/add-group/users-list.js and 1 other location - About 3 hrs to fix
    src/smart-components/group/add-group/users-list-itless.js on lines 364..371

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

    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

      useEffect(() => {
        if (usesMetaInURL) {
          isPaginationPresentInUrl(location) || applyPaginationToUrl(location, navigate, pagination.limit, pagination.offset);
          Object.values(filters).some((filter) => filter?.length > 0) &&
            !areFiltersPresentInUrl(location, Object.keys(filters)) &&
    Severity: Major
    Found in src/smart-components/group/add-group/users-list-itless.js and 1 other location - About 3 hrs to fix
    src/smart-components/group/add-group/users-list.js on lines 88..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 114.

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

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

            setFilterValue={({ username, email, status }) => {
              updateFilters({
                username: typeof username === 'undefined' ? filters.username : username,
                email: typeof email === 'undefined' ? filters.email : email,
                status: typeof status === 'undefined' || status === filters.status ? filters.status : status,
      Severity: Major
      Found in src/smart-components/group/add-group/users-list.js and 1 other location - About 3 hrs to fix
      src/smart-components/group/add-group/users-list-itless.js on lines 476..482

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

      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

              setFilterValue={({ username, email, status }) => {
                updateFilters({
                  username: typeof username === 'undefined' ? filters.username : username,
                  email: typeof email === 'undefined' ? filters.email : email,
                  status: typeof status === 'undefined' || status === filters.status ? filters.status : status,
      Severity: Major
      Found in src/smart-components/group/add-group/users-list-itless.js and 1 other location - About 3 hrs to fix
      src/smart-components/group/add-group/users-list.js on lines 132..138

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

      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 processRoleName = (value) => {
          const trimmedValue = trimAll(value);
          input.onChange(undefined);
          debouncedAsyncValidator(trimmedValue)
            .then(() => {
      Severity: Major
      Found in src/smart-components/role/add-role/set-name.js and 1 other location - About 3 hrs to fix
      src/smart-components/group/add-group/set-name.js on lines 27..40

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

      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 processGroupName = (value) => {
          const trimmedValue = trimAll(value);
          input.onChange(undefined);
          debouncedAsyncValidator(trimmedValue)
            .then(() => {
      Severity: Major
      Found in src/smart-components/group/add-group/set-name.js and 1 other location - About 3 hrs to fix
      src/smart-components/role/add-role/set-name.js on lines 24..37

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

      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

                  [pathnames['group-members-remove-group'].path]: {
                    postMethod: () => dispatch(fetchGroups({ ...groupsPagination, offset: 0, filters: groupsFilters, usesMetaInURL: true, chrome })),
                    cancelRoute: pathnames['group-detail-members'].link.replace(':groupId', groupId),
                    submitRoute: getBackRoute(pathnames.groups.link, { ...groupsPagination, offset: 0 }, groupsFilters),
                    groupsUuid: [group],
      Severity: Major
      Found in src/smart-components/group/member/group-members.js and 1 other location - About 3 hrs to fix
      src/smart-components/group/role/group-roles.js on lines 323..328

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

      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

                  [pathnames['group-roles-remove-group'].path]: {
                    postMethod: () => dispatch(fetchGroups({ ...groupsPagination, offset: 0, filters: groupsFilters, usesMetaInURL: true, chrome })),
                    cancelRoute: pathnames['group-detail-roles'].link.replace(':groupId', groupId),
                    submitRoute: getBackRoute(pathnames.groups.link, { ...groupsPagination, offset: 0 }, groupsFilters),
                    groupsUuid: [group],
      Severity: Major
      Found in src/smart-components/group/role/group-roles.js and 1 other location - About 3 hrs to fix
      src/smart-components/group/member/group-members.js on lines 219..224

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

      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 InsightsRbac = () => (
        <IntlProvider locale={locale} messages={messages[locale]}>
          <RegistryContext.Provider
            value={{
              getRegistry: () => registry,
      Severity: Major
      Found in src/AppEntry.js and 1 other location - About 3 hrs to fix
      src/entries/IamUserAccess.js on lines 10..22

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

      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 IamUserAccess = () => (
        <IntlProvider locale={locale} messages={messages[locale]}>
          <RegistryContext.Provider
            value={{
              getRegistry: () => registry,
      Severity: Major
      Found in src/entries/IamUserAccess.js and 1 other location - About 3 hrs to fix
      src/AppEntry.js on lines 10..22

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

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

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

                        <Tr>
                          <Td>Understanding Workspace hierarchy and inheritance</Td>
                          <Td>
                            <Label color="orange">Documentation</Label>
                          </Td>
            src/smart-components/workspaces/overview/about-access-tab.tsx on lines 241..252
            src/smart-components/workspaces/overview/about-access-tab.tsx on lines 265..276

            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

            Severity
            Category
            Status
            Source
            Language