RedHatInsights/insights-rbac-ui

View on GitHub

Showing 109 of 381 total issues

Function AddRoleWizard has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

const AddRoleWizard = ({ pagination, filters, orderBy }) => {
  const intl = useIntl();
  const dispatch = useDispatch();
  const navigate = useAppNavigate();
  const chrome = useChrome();
Severity: Minor
Found in src/smart-components/role/add-role/add-role-wizard.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 CommonBundleView has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

const CommonBundleView = ({ apps }) => {
  const isOrgAdmin = useContext(OrgAdminContext);
  const [name, setName] = useState('');
  const [permission, setPermission] = useState('');
  const [application, setApplication] = useState([]);
Severity: Minor
Found in src/smart-components/myUserAccess/CommonBundleView.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 rows has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const rows = useMemo(() => {
    return users.map((user: UserProps) => ({
      id: user.username,
      is_active: user.is_active,
      row: [
Severity: Minor
Found in src/smart-components/access-management/UsersTable.tsx - About 1 hr to fix

    Function Users has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const Users = () => {
      const intl = useIntl();
      const activeUserPermissions = useContext(PermissionsContext);
      const { appNavClick } = useChrome();
      const isITLess = useFlag('platform.rbac.itless');
    Severity: Minor
    Found in src/smart-components/user/users.tsx - About 1 hr to fix

      Function addUsers has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const addUsers = (usersData) => {
        const cache = createIntlCache();
        const intl = createIntl({ locale, messages: providerMessages }, cache);
        return {
          type: ActionTypes.ADD_USERS,
      Severity: Minor
      Found in src/redux/actions/user-actions.js - About 1 hr to fix

        Function createRows has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        export const createRows = (userLinks: boolean, data: UserProps[] = [], intl: IntlShape, checkedRows = [], isSelectable = false): RowProps[] =>
          data?.reduce<RowProps[]>((acc, { username, is_active: isActive, email, first_name: firstName, last_name: lastName, is_org_admin: isOrgAdmin }) => {
            const newEntry: RowProps = {
              uuid: username,
              cells: [
        Severity: Minor
        Found in src/smart-components/user/user-table-helpers.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 handleSubmit has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          const handleSubmit = (data) => {
            dispatchLocally({ type: 'update', payload: { changedResources: data['dual-list-select'] } });
            const dualListData = data['dual-list-select'].map((item) => (item === 'null' ? null : item));
            const newAccess = {
              permission: permissionId,
        Severity: Minor
        Found in src/smart-components/role/edit-resource-definitions-modal.js - About 1 hr to fix

          Function SetRoles has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

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

            Function onChange has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                          onChange: (_e, filterBy) => {
                            const newFilter =
                              typeof filterBy !== 'string' && !Array.isArray(filterBy) ? Object.keys(pickBy(filterBy[''], (value) => value)) : filterBy;
            
                            setFilterValue({
            Severity: Minor
            Found in src/presentational-components/shared/toolbar.js - About 1 hr to fix

              Function onDelete has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                onDelete: (_e, [deleted], isAll) => {
                  const setKeyValue = (value, type, key) => {
                    if (isAll) {
                      return type === 'group' || type === 'checkbox' ? [] : '';
                    }
              Severity: Minor
              Found in src/presentational-components/shared/toolbar.js - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                    if (
                      !baseRole ||
                      roleType !== 'copy' ||
                      formOptions.getState().values['base-permissions-loaded'] ||
                      selectedPermissions.length > 0 ||
                Severity: Major
                Found in src/smart-components/role/add-role/add-permissions.js - About 1 hr to fix

                  Function listPermissionOptions has 8 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  export async function listPermissionOptions(field, limit, offset, application, resourceType, verb, allowedOnly, options) {
                  Severity: Major
                  Found in src/helpers/permission/permission-helper.js - About 1 hr to fix

                    Function ReviewStep has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const ReviewStep = () => {
                      const intl = useIntl();
                      const enableWorkspacesNameChange = useFlag('platform.rbac.groups-to-workspaces-rename');
                      const formOptions = useFormApi();
                      const {
                    Severity: Minor
                    Found in src/smart-components/role/add-role/review.js - About 55 mins 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 getServiceAccounts has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export async function getServiceAccounts({ limit = defaultCompactSettings.limit, offset = 0, token, sso, groupId }: any) {
                      const page = Math.trunc(offset / limit) + 1;
                      const perPage = limit;
                    
                      const response = await serviceAccountsApi.getServiceAccounts(page, perPage, token, sso);
                    Severity: Minor
                    Found in src/helpers/service-account/service-account-helper.ts - About 55 mins 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 createRows has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export const createRows = (data, selectedRows, intl, expanded, adminGroup) =>
                      data.reduce(
                        (
                          acc,
                          { uuid, access = [], display_name, name, description, system, accessCount, groups_in_count: groupsCount, groups_in: groups, modified },
                    Severity: Minor
                    Found in src/smart-components/role/role-table-helpers.js - About 55 mins 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 a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const reducer = (state, action) => {
                      const prevState = state[action.key];
                      switch (action.type) {
                        case 'toggle':
                          return {
                    Severity: Minor
                    Found in src/smart-components/role/add-role/inventory-groups-role.js - About 45 mins 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 AddGroupRoles has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const AddGroupRoles = ({
                      afterSubmit,
                      fetchUuid,
                      selectedRoles,
                      setSelectedRoles,
                    Severity: Minor
                    Found in src/smart-components/group/role/add-group-roles.js - About 45 mins 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 fetchUsers has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export async function fetchUsers({ limit, offset = 0, orderBy, filters = {}, usesMetaInURL, matchCriteria = 'partial' }) {
                      const { username, email, status = [] } = filters;
                      const sortOrder = orderBy === '-username' ? 'desc' : 'asc';
                      const mappedStatus =
                        typeof status === 'string'
                    Severity: Minor
                    Found in src/helpers/user/user-helper.js - About 45 mins 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 a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export const schemaBuilder = (container, featureFlag) => {
                      const cache = createIntlCache();
                      const intl = createIntl({ locale, messages: providerMessages }, cache);
                    
                      return {
                    Severity: Minor
                    Found in src/smart-components/role/add-role-permissions/schema.js - About 45 mins 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 a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

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

                    Cognitive Complexity

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

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

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

                    Further reading

                    Severity
                    Category
                    Status
                    Source
                    Language