RedHatInsights/insights-rbac-ui

View on GitHub

Showing 381 of 381 total issues

File Messages.js has 2210 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { defineMessages } from 'react-intl';

export default defineMessages({
  inviteUsers: {
    id: 'inviteUsers',
Severity: Major
Found in src/Messages.js - About 6 days to fix

    Function User has 285 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const User = () => {
      const intl = useIntl();
      const navigate = useAppNavigate();
      const navigationType = useNavigationType();
      const dispatch = useDispatch();
    Severity: Major
    Found in src/smart-components/user/user.js - About 1 day to fix

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

          mockRoles.data.forEach((role, index) => {
            cy.get(`[data-ouia-component-id^="RolesTable-table-tr-${index}"]`).within(() => {
              cy.get('td').eq(1).should('contain', role.display_name);
              cy.get('td').eq(2).should('contain', role.description);
              cy.get('td').eq(3).should('contain', role.accessCount);
      Severity: Major
      Found in cypress/e2e/roles.cy.ts and 1 other location - About 1 day to fix
      cypress/e2e/roles.cy.ts on lines 72..81

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

      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

          mockRoles.data.forEach((role, index) => {
            cy.get(`[data-ouia-component-id^="RolesTable-table-tr-${index}"]`).within(() => {
              cy.get('td').eq(1).should('contain', role.display_name);
              cy.get('td').eq(2).should('contain', role.description);
              cy.get('td').eq(3).should('contain', role.accessCount);
      Severity: Major
      Found in cypress/e2e/roles.cy.ts and 1 other location - About 1 day to fix
      cypress/e2e/roles.cy.ts on lines 59..68

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

      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 Permissions has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
      Open

      const Permissions = ({ cantAddPermissions, isLoading }) => {
        const intl = useIntl();
        const { role, isRecordLoading } = useSelector(
          (state) => ({
            role: state.roleReducer.selectedRole,
      Severity: Minor
      Found in src/smart-components/role/role-permissions.js - About 1 day 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

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

            filters={[
              {
                key: 'username',
                value: filters.username,
                placeholder: intl.formatMessage(messages.filterByKey, { key: intl.formatMessage(messages.username).toLowerCase() }),
      Severity: Major
      Found in src/smart-components/group/add-group/users-list.js and 1 other location - About 1 day to fix
      src/smart-components/group/add-group/users-list-itless.js on lines 490..513

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

      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

              filters={[
                {
                  key: 'username',
                  value: filters.username,
                  placeholder: intl.formatMessage(messages.filterByKey, { key: intl.formatMessage(messages.username).toLowerCase() }),
      Severity: Major
      Found in src/smart-components/group/add-group/users-list-itless.js and 1 other location - About 1 day to fix
      src/smart-components/group/add-group/users-list.js on lines 146..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 228.

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

      const Group = () => {
        const intl = useIntl();
        const dispatch = useDispatch();
        const navigate = useAppNavigate();
        const location = useLocation();
      Severity: Major
      Found in src/smart-components/group/group.js - About 1 day to fix

        Function Groups has 234 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const Groups = () => {
          const intl = useIntl();
          const dispatch = useDispatch();
          const navigate = useNavigate();
          const location = useLocation();
        Severity: Major
        Found in src/smart-components/group/groups.js - About 1 day to fix

          Function WorkspacesOverview has 233 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const WorkspacesOverview = () => {
            const [isExpanded, setIsExpanded] = React.useState(false);
            const intl = useIntl();
            const navigate = useNavigate();
          
          
          Severity: Major
          Found in src/smart-components/workspaces/overview/about-access-tab.tsx - About 1 day to fix

            Function Roles has 232 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const Roles = () => {
              const { orgAdmin, userAccessAdministrator } = useContext(PermissionsContext);
              const [selectedRows, setSelectedRows] = useState([]);
              const intl = useIntl();
              const dispatch = useDispatch();
            Severity: Major
            Found in src/smart-components/role/roles.js - About 1 day to fix

              Function Overview has 225 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const Overview = () => {
                const intl = useIntl();
                const [expanded, setExpanded] = useState(true);
                const isWorkspacesFlag = useFlag('platform.rbac.workspaces');
                const isWorkspacesEligible = useFlag('platform.rbac.workspaces-eligible');
              Severity: Major
              Found in src/smart-components/overview/overview.js - About 1 day to fix

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

                        fetchData={(config) => {
                          const status = Object.prototype.hasOwnProperty.call(config, 'status') ? config.status : filters.status;
                          const { username, email, count, limit, offset, orderBy } = config;
                
                          fetchData({ ...mappedProps({ count, limit, offset, orderBy, filters: { username, email, status } }), usesMetaInURL }).then(() => {
                Severity: Major
                Found in src/smart-components/group/add-group/users-list-itless.js and 1 other location - About 1 day to fix
                src/smart-components/group/add-group/users-list.js on lines 122..130

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

                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

                      fetchData={(config) => {
                        const status = Object.prototype.hasOwnProperty.call(config, 'status') ? config.status : filters.status;
                        const { username, email, count, limit, offset, orderBy } = config;
                
                        fetchData({ ...mappedProps({ count, limit, offset, orderBy, filters: { username, email, status } }), usesMetaInURL }).then(() => {
                Severity: Major
                Found in src/smart-components/group/add-group/users-list.js and 1 other location - About 1 day to fix
                src/smart-components/group/add-group/users-list-itless.js on lines 466..474

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

                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 users-list-itless.js has 515 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import React, { useEffect, Fragment, useState, useContext, useRef, useCallback, Suspense } from 'react';
                import { useSelector, useDispatch } from 'react-redux';
                import truncate from 'lodash/truncate';
                import { useIntl } from 'react-intl';
                import PropTypes from 'prop-types';
                Severity: Major
                Found in src/smart-components/group/add-group/users-list-itless.js - About 1 day to fix

                  Function Role has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const Role = ({ onDelete }) => {
                    const intl = useIntl();
                    const chrome = useChrome();
                    const navigate = useAppNavigate();
                    const navigationType = useNavigationType();
                  Severity: Minor
                  Found in src/smart-components/role/role.js - About 1 day 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 schemaBuilder has 206 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/schema.js - About 1 day to fix

                    Function InventoryGroupsRole has 205 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const InventoryGroupsRole = (props) => {
                      const intl = useIntl();
                      const dispatch = useDispatch();
                      const { input } = useFieldApi(props);
                      const formOptions = useFormApi();
                    Severity: Major
                    Found in src/smart-components/role/add-role/inventory-groups-role.js - About 1 day to fix

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

                      export const updateUsers = (userList) => {
                        const cache = createIntlCache();
                        const intl = createIntl({ locale, messages: providerMessages }, cache);
                        return {
                          type: ActionTypes.UPDATE_USERS,
                      Severity: Major
                      Found in src/redux/actions/user-actions.js and 2 other locations - About 1 day to fix
                      src/redux/actions/group-actions.js on lines 73..98
                      src/redux/actions/user-actions.js on lines 39..64

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

                      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

                      export const updateUserIsOrgAdminStatus = (user) => {
                        const cache = createIntlCache();
                        const intl = createIntl({ locale, messages: providerMessages }, cache);
                        return {
                          type: ActionTypes.UPDATE_USER_IS_ORG_ADMIN_STATUS,
                      Severity: Major
                      Found in src/redux/actions/user-actions.js and 2 other locations - About 1 day to fix
                      src/redux/actions/group-actions.js on lines 73..98
                      src/redux/actions/user-actions.js on lines 66..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 197.

                      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