pankod/refine

View on GitHub

Showing 293 of 385 total issues

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

export default defineConfig({
    entry: ["src/index.tsx"],
    splitting: false,
    sourcemap: true,
    clean: false,
Severity: Major
Found in packages/chakra-ui/tsup.config.ts and 1 other location - About 2 days to fix
packages/mui/tsup.config.ts on lines 9..99

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

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

export default defineConfig({
    entry: ["src/index.tsx"],
    splitting: false,
    sourcemap: true,
    clean: false,
Severity: Major
Found in packages/mui/tsup.config.ts and 1 other location - About 2 days to fix
packages/chakra-ui/tsup.config.ts on lines 9..99

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

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

export const notificationProvider = (): NotificationProvider => {
    const activeNotifications: string[] = [];

    const isNotificationActive = (key?: string) => {
        return activeNotifications.includes(key as string);
Severity: Minor
Found in packages/mantine/src/providers/notificationProvider.tsx - About 7 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 Edit has 178 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const Edit: React.FC<EditProps> = (props) => {
    const {
        children,
        resource: resourceFromProps,
        recordItemId,
Severity: Major
Found in packages/chakra-ui/src/components/crud/edit/index.tsx - About 7 hrs to fix

    Function useRefineKbar has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
    Open

    export const useRefineKbar = (): void => {
        const t = useTranslate();
        const { resources } = useResource();
        const { useParams } = useRouterContext();
        const { mutate } = useDelete();
    Severity: Minor
    Found in packages/kbar/src/hooks/useRefineKbar/index.tsx - About 7 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 createActionWithResource has 176 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        const createActionWithResource = async (resource: IResourceItem) => {
            const {
                name,
                label,
                list,
    Severity: Major
    Found in packages/kbar/src/hooks/useRefineKbar/index.tsx - About 7 hrs to fix

      Function Show has 171 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const Show: React.FC<ShowProps> = (props) => {
          const {
              children,
              resource: resourceFromProps,
              recordItemId,
      Severity: Major
      Found in packages/chakra-ui/src/components/crud/show/index.tsx - About 6 hrs to fix

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

                    <Box
                        mb="3"
                        display="flex"
                        justifyContent="space-between"
                        alignItems="center"
        Severity: Major
        Found in packages/chakra-ui/src/components/crud/create/index.tsx and 1 other location - About 6 hrs to fix
        packages/chakra-ui/src/components/crud/show/index.tsx on lines 185..210

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

        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

                    <Box
                        mb="3"
                        display="flex"
                        justifyContent="space-between"
                        alignItems="center"
        Severity: Major
        Found in packages/chakra-ui/src/components/crud/show/index.tsx and 1 other location - About 6 hrs to fix
        packages/chakra-ui/src/components/crud/create/index.tsx on lines 144..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 159.

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

        const DataProvider = (
            apiUrl: string,
            httpClient: AxiosInstance = axiosInstance,
        ): Required<DataProviderType> => {
            return {
        Severity: Major
        Found in packages/medusa/src/dataProvider/index.ts - About 5 hrs to fix

          Function Sider has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
          Open

          export const Sider: React.FC<RefineLayoutSiderProps> = ({ render }) => {
              const [collapsed, setCollapsed] = useState(false);
              const [opened, setOpened] = useState(false);
          
              const drawerWidth = () => {
          Severity: Minor
          Found in packages/mui/src/components/layout/sider/index.tsx - About 5 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 renderTreeView has 140 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              const renderTreeView = (tree: ITreeMenu[], selectedKey: string) => {
                  return tree.map((item: ITreeMenu) => {
                      const { icon, label, route, name, children, parentName } = item;
                      const isOpen = open[route || ""] || false;
          
          
          Severity: Major
          Found in packages/mui/src/components/layout/sider/index.tsx - About 5 hrs to fix

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

            export const handleFilterValue = (operator: CrudOperators, value: any) => {
                switch (operator) {
                    case "startswiths":
                    case "nstartswiths":
                        return `${value}%`;
            Severity: Major
            Found in packages/nhost/src/dataProvider/index.ts and 1 other location - About 5 hrs to fix
            packages/hasura/src/dataProvider/index.ts on lines 88..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 147.

            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

            export const handleFilterValue = (operator: CrudOperators, value: any) => {
                switch (operator) {
                    case "startswiths":
                    case "nstartswiths":
                        return `${value}%`;
            Severity: Major
            Found in packages/hasura/src/dataProvider/index.ts and 1 other location - About 5 hrs to fix
            packages/nhost/src/dataProvider/index.ts on lines 89..110

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

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

            export const useTable = <
                TData extends BaseRecord = BaseRecord,
                TError extends HttpError = HttpError,
                TSearchVariables = unknown,
            >(
            Severity: Minor
            Found in packages/antd/src/hooks/table/useTable/useTable.ts - About 5 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 Edit has 139 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const Edit: React.FC<EditProps> = (props) => {
                const {
                    children,
                    resource: resourceFromProps,
                    recordItemId,
            Severity: Major
            Found in packages/mantine/src/components/crud/edit/index.tsx - About 5 hrs to fix

              Function notificationProvider has 136 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const notificationProvider = (): NotificationProvider => {
                  const activeNotifications: string[] = [];
              
                  const isNotificationActive = (key?: string) => {
                      return activeNotifications.includes(key as string);
              Severity: Major
              Found in packages/mantine/src/providers/notificationProvider.tsx - About 5 hrs to fix

                Function Create has 136 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export const Create: React.FC<CreateProps> = (props) => {
                    const {
                        children,
                        saveButtonProps,
                        isLoading,
                Severity: Major
                Found in packages/chakra-ui/src/components/crud/create/index.tsx - About 5 hrs to fix

                  Function ResourceComponentWrapper has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export const ResourceComponentWrapper: React.FC<{ route: string }> = ({
                      route,
                  }) => {
                      const { catchAll } = useRefineContext();
                      const { useParams } = useRouterContext();
                  Severity: Minor
                  Found in packages/react-location/src/resourceComponent.tsx - About 5 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 Show has 131 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export const Show: React.FC<ShowProps> = (props) => {
                      const {
                          children,
                          resource: resourceFromProps,
                          recordItemId,
                  Severity: Major
                  Found in packages/mantine/src/components/crud/show/index.tsx - About 5 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language