pankod/refine

View on GitHub

Showing 959 of 983 total issues

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

      {
        group: "Pages",
        label: "ErrorPage",
        message: `
                **\`Info:\`**
Severity: Major
Found in packages/mantine/refine.config.js and 3 other locations - About 2 hrs to fix
packages/antd/refine.config.js on lines 287..314
packages/chakra-ui/refine.config.js on lines 232..259
packages/mui/refine.config.js on lines 142..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 88.

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 4 locations. Consider refactoring.
Open

      {
        group: "Pages",
        label: "ErrorPage",
        message: `
                **\`Info:\`**
Severity: Major
Found in packages/mui/refine.config.js and 3 other locations - About 2 hrs to fix
packages/antd/refine.config.js on lines 287..314
packages/chakra-ui/refine.config.js on lines 232..259
packages/mantine/refine.config.js on lines 232..259

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

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 4 locations. Consider refactoring.
Open

      {
        group: "Pages",
        label: "ErrorPage",
        message: `
                **\`Info:\`**
Severity: Major
Found in packages/antd/refine.config.js and 3 other locations - About 2 hrs to fix
packages/chakra-ui/refine.config.js on lines 232..259
packages/mantine/refine.config.js on lines 232..259
packages/mui/refine.config.js on lines 142..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 88.

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

export const ErrorComponent: React.FC<RefineErrorPageProps> = () => {
  const [errorMessage, setErrorMessage] = useState<string>();
  const translate = useTranslate();
  const { push } = useNavigation();
  const go = useGo();
Severity: Major
Found in packages/chakra-ui/src/components/pages/error/index.tsx - About 2 hrs to fix

    Function ReadyPage has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const ReadyPage: React.FC<RefineReadyPageProps> = () => {
      return (
        <Box
          p="4"
          display="flex"
    Severity: Major
    Found in packages/chakra-ui/src/components/pages/ready/index.tsx - About 2 hrs to fix

      Function basicInputFields has 65 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        const basicInputFields = (field: InferField) => {
          if (
            field.type === "text" ||
            field.type === "url" ||
            field.type === "email" ||
      Severity: Major
      Found in packages/inferencer/src/inferencers/headless/create.tsx - About 2 hrs to fix

        Function useInvalidate has 65 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const useInvalidate = (): ((
          props: UseInvalidateProp,
        ) => Promise<void>) => {
          const { resources } = useResource();
          const queryClient = useQueryClient();
        Severity: Major
        Found in packages/core/src/hooks/invalidate/index.tsx - About 2 hrs to fix

          Function getOperationFields has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

          export const getOperationFields = (documentNode: DocumentNode) => {
            const fieldLines: string[] = [];
            let isInitialEnter = true;
            let depth = 0;
            let isNestedField = false;
          Severity: Minor
          Found in packages/graphql/src/utils/graphql.ts - 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 getOperationFields has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

          export const getOperationFields = (documentNode: DocumentNode) => {
            const fieldLines: string[] = [];
            let isInitialEnter = true;
            let depth = 0;
            let isNestedField = false;
          Severity: Minor
          Found in packages/hasura/src/utils/graphql.ts - 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 useForm has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

          export const useForm = <
            TQueryFnData extends BaseRecord = BaseRecord,
            TError extends HttpError = HttpError,
            TVariables = Record<string, unknown>,
            TTransformed = TVariables,
          Severity: Minor
          Found in packages/mantine/src/hooks/form/useForm/index.ts - 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 go has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

            go: () => {
              const { push, replace, asPath: pathname } = useRouter();
          
              const fn = React.useCallback(
                ({
          Severity: Minor
          Found in packages/nextjs-router/src/pages/bindings.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 basicToRelation has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

          export const basicToRelation: FieldTransformer = (
            fields,
            resources,
            resource,
            record,
          Severity: Minor
          Found in packages/inferencer/src/field-transformers/basic-to-relation.ts - 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 fixUseListHasPaginationToPaginationMode has 64 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const fixUseListHasPaginationToPaginationMode = (
            j: JSCodeshift,
            source: Collection,
          ) => {
            const useListHooks = source.find(j.CallExpression, {
          Severity: Major
          Found in packages/codemod/src/transformations/v4/fix-v4-deprecations.ts - About 2 hrs to fix

            Function MockGoogleButton has 64 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const MockGoogleButton = () => {
              const { mutate } = useLogin();
            
              return (
                <button
            Severity: Major
            Found in packages/live-previews/src/scope/google.tsx - About 2 hrs to fix

              Function renderTreeView has 63 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                const renderTreeView = (tree: ITreeMenu[], selectedKey?: string) => {
                  return tree.map((item: ITreeMenu) => {
                    const {
                      icon,
                      label,
              Severity: Major
              Found in packages/antd/src/components/themedLayoutV2/sider/index.tsx - About 2 hrs to fix

                Function moveConfigProvider has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const moveConfigProvider = (j: JSCodeshift, root: Collection<any>) => {
                  const refineElement = root.find(j.JSXElement, {
                    openingElement: {
                      name: {
                        name: "Refine",
                Severity: Major
                Found in packages/codemod/src/transformations/refine2-to-refine3.ts - About 2 hrs to fix

                  Function booleanFields has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    const booleanFields = (field: InferField) => {
                      if (field.type === "boolean") {
                        imports.push(
                          ["Checkbox", "@mui/material"],
                          ["FormControlLabel", "@mui/material"],
                  Severity: Major
                  Found in packages/inferencer/src/inferencers/mui/edit.tsx - About 2 hrs to fix

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

                    export const FileField: React.FC<FileFieldProps> = ({
                      title,
                      src,
                      ...rest
                    }) => {
                    Severity: Major
                    Found in packages/mantine/src/components/fields/file/index.tsx and 1 other location - About 2 hrs to fix
                    packages/chakra-ui/src/components/fields/file/index.tsx on lines 7..17

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

                    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 FileField: React.FC<FileFieldProps> = ({
                      title,
                      src,
                      ...rest
                    }) => {
                    Severity: Major
                    Found in packages/chakra-ui/src/components/fields/file/index.tsx and 1 other location - About 2 hrs to fix
                    packages/mantine/src/components/fields/file/index.tsx on lines 7..17

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

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

                      const booleanFields = (field: InferField) => {
                        if (field.type === "boolean") {
                          imports.push(["Checkbox", "@chakra-ui/react"]);
                    
                          if (field.multiple) {
                    Severity: Major
                    Found in packages/inferencer/src/inferencers/chakra-ui/edit.tsx - About 2 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language