pankod/refine

View on GitHub
packages/inferencer/src/use-relation-fetch/index.ts

Summary

Maintainability
F
4 days
Test Coverage

Function useRelationFetch has a Cognitive Complexity of 126 (exceeds 5 allowed). Consider refactoring.
Open

export const useRelationFetch = ({
  record,
  fields,
  infer,
  meta,
Severity: Minor
Found in packages/inferencer/src/use-relation-fetch/index.ts - About 2 days 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 resolver has 206 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    async (allFields: (InferField | false | null)[]) => {
      console.groupCollapsed(
        "@refinedev/inferencer is trying to detect relations",
      );
      const attempts: Array<ResourceInferenceAttempt> = [];
Severity: Major
Found in packages/inferencer/src/use-relation-fetch/index.ts - About 1 day to fix

    Function promises has 175 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            const promises = allFields.map(async (field) => {
              if (field && (field.relation || field.canRelation)) {
                if (record) {
                  if (field.relationInfer) {
                    return field;
    Severity: Major
    Found in packages/inferencer/src/use-relation-fetch/index.ts - About 7 hrs to fix

      Avoid too many return statements within this function.
      Open

                    return {
                      ...field,
                      relationInfer: null,
                    };
      Severity: Major
      Found in packages/inferencer/src/use-relation-fetch/index.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                        return {
                          ...field,
                          relation: true,
                          type: "relation",
                          resource: {
        Severity: Major
        Found in packages/inferencer/src/use-relation-fetch/index.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                    return field;
          Severity: Major
          Found in packages/inferencer/src/use-relation-fetch/index.ts - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status