RedHatInsights/insights-rbac-ui

View on GitHub

Showing 109 of 381 total issues

Function Roles has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

const Roles = () => {
  const { orgAdmin, userAccessAdministrator } = useContext(PermissionsContext);
  const [selectedRows, setSelectedRows] = useState([]);
  const intl = useIntl();
  const dispatch = useDispatch();
Severity: Minor
Found in src/smart-components/role/roles.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

Function reducer has 56 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/cost-resources.js - About 2 hrs to fix

    Function GroupMembers has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    const GroupMembers = () => {
      const intl = useIntl();
      const chrome = useChrome();
      const [filterValue, setFilterValue] = useState('');
      const [selectedMembers, setSelectedMembers] = useState([]);
    Severity: Minor
    Found in src/smart-components/group/member/group-members.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

    Function GroupServiceAccounts has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    const GroupServiceAccounts = () => {
      const intl = useIntl();
      const dispatch = useDispatch();
      const navigate = useAppNavigate();
      const { groupId } = useParams();
    Severity: Minor
    Found in src/smart-components/group/service-account/group-service-accounts.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

    Function UsersListNotSelectable has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    const UsersListNotSelectable = ({ userLinks, usesMetaInURL, props }: UsersListNotSelectableI) => {
      const intl = useIntl();
      const navigate = useNavigate();
      const location = useLocation();
      const dispatch = useDispatch();
    Severity: Minor
    Found in src/smart-components/user/users-list-not-selectable.tsx - 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

    Function onSubmit has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const onSubmit = (formData) => {
        const {
          'role-name': name,
          'role-description': description,
          'role-copy-name': copyName,
    Severity: Major
    Found in src/smart-components/role/add-role/add-role-wizard.js - About 2 hrs to fix

      Function onSubmit has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        const onSubmit = async (formData) => {
          const {
            'add-permissions-table': selectedPermissions,
            'cost-resources': costResources = [],
            'inventory-groups-role': invResources = [],

        Function filterConfigBuilder has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        export const filterConfigBuilder = (
          isLoading,
          setFilterValue = () => undefined,
          fetchData = () => undefined,
          filterValue = '',
        Severity: Minor
        Found in src/presentational-components/shared/toolbar.js - About 1 hr to fix

        Cognitive Complexity

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

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

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

        Further reading

        Function ResourceDefinitions has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        const ResourceDefinitions = () => {
          const intl = useIntl();
          const [config, setConfig] = useState({
            pagination: {
              ...defaultSettings,
        Severity: Minor
        Found in src/smart-components/role/role-resource-definitions.js - About 1 hr 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 AddGroupMembers has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        const AddGroupMembers = ({ cancelRoute }) => {
          const chrome = useChrome();
          const intl = useIntl();
          const navigate = useAppNavigate();
          const { groupId } = useParams();
        Severity: Minor
        Found in src/smart-components/group/member/add-group-members.js - About 1 hr 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 UserGroupsTable has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        const UserGroupsTable: React.FunctionComponent<UserGroupsTableProps> = ({
          defaultPerPage = 20,
          useUrlParams = true,
          enableActions = true,
          ouiaId = 'iam-user-groups-table',
        Severity: Minor
        Found in src/smart-components/access-management/UserGroupsTable.tsx - About 1 hr 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 QuickstartsTestButtons has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const QuickstartsTestButtons = () => {
          const intl = useIntl();
          const [openQuickstart, setOpenQuickstart] = useState(false);
          const chromeHook = useChrome();
          const navigate = useNavigate();
        Severity: Minor
        Found in src/utilities/quickstarts-test-buttons.js - About 1 hr to fix

          Function SetUsers has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const SetUsers = (props) => {
            const [selectedUsers, setSelectedUsers] = useState([]);
            const { input } = useFieldApi(props);
            const intl = useIntl();
            const formOptions = useFormApi();
          Severity: Minor
          Found in src/smart-components/group/add-group/set-users.js - About 1 hr to fix

            Function UsersTable has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

            const UsersTable: React.FunctionComponent<UsersTableProps> = ({ onAddUserClick }) => {
              const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
              const [currentUser, setCurrentUser] = useState<User | undefined>();
              const dispatch = useDispatch();
              const intl = useIntl();
            Severity: Minor
            Found in src/smart-components/access-management/UsersTable.tsx - About 1 hr 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 EditGroupModal has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

            const EditGroupModal = ({ postMethod, pagination, cancelRoute, submitRoute = cancelRoute, group, onClose }) => {
              const intl = useIntl();
              const [selectedGroup, setSelectedGroup] = useState(undefined);
            
              const navigate = useAppNavigate();
            Severity: Minor
            Found in src/smart-components/group/edit-group-modal.js - About 1 hr 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 listPermissions has 11 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              limit,
              offset,
              orderBy,
              application,
              resourceType,
            Severity: Major
            Found in src/helpers/permission/permission-helper.js - About 1 hr to fix

              Function syncDefaultFiltersWithUrl has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const syncDefaultFiltersWithUrl = (location, navigate, keys, defaults = {}) => {
                const searchParams = new URLSearchParams(location.search);
              
                let filters = keys.reduce((acc, key) => {
                  const values = searchParams.getAll(key);
              Severity: Minor
              Found in src/helpers/shared/filters.js - About 1 hr to fix

                Function toolbarDropdowns has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  const toolbarDropdowns = () => {
                    const onToggle = (isOpen) => {
                      setIsToolbarDropdownOpen(isOpen);
                    };
                    const onToolbarDropdownSelect = async (_event) => {
                Severity: Minor
                Found in src/smart-components/group/add-group/users-list-itless.js - About 1 hr to fix

                  Function Routing has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const Routing = () => {
                    const location = useLocation();
                    const { updateDocumentTitle, isBeta } = useChrome();
                    const isITLess = useFlag('platform.rbac.itless');
                    const enableServiceAccounts =
                  Severity: Minor
                  Found in src/Routing.tsx - About 1 hr to fix

                    Function TypeSelector has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const TypeSelector = (props) => {
                      const intl = useIntl();
                      const { input } = useFieldApi(props);
                      const formOptions = useFormApi();
                      const [checked, setChecked] = useState(formOptions.getState().values['role-type']);
                    Severity: Minor
                    Found in src/smart-components/role/add-role/type-selector.js - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language