UnlyEd/ra-data-graphql-prisma

View on GitHub

Showing 40 of 40 total issues

Function buildUpdateVariables has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

const buildUpdateVariables = (introspectionResults: IntrospectionResult) => (
  resource: Resource,
  aorFetchType: string,
  params: UpdateParams,
  fieldAliasResolver?: RAGqlPrismaFieldAliasResolver,
Severity: Minor
Found in src/buildVariables.ts - About 6 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 buildCreateVariables has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

const buildCreateVariables = (introspectionResults: IntrospectionResult) => (
  resource: Resource,
  aorFetchType: string,
  params: CreateParams,
  fieldAliasResolver?: RAGqlPrismaFieldAliasResolver,
Severity: Minor
Found in src/buildVariables.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 buildGetListVariables has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

const buildGetListVariables = (introspectionResults: IntrospectionResult) => (
  resource: Resource,
  aorFetchType: string,
  params: GetListParams,
) => {
Severity: Minor
Found in src/buildVariables.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 sanitizeResource has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

const sanitizeResource = (
  introspectionResults: IntrospectionResult,
  resource: Resource,
  fieldAliasResolver?: RAGqlPrismaFieldAliasResolver,
) => (record: GqlRecord): any => {
Severity: Minor
Found in src/getResponseParser.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

File buildVariables.ts has 454 lines of code (exceeds 400 allowed). Consider refactoring.
Open

/* eslint-disable @typescript-eslint/camelcase */
import { IntrospectionField, IntrospectionInputObjectType, IntrospectionNamedTypeRef, IntrospectionObjectType } from 'graphql';
import get from 'lodash/get';
import isDate from 'lodash/isDate';
import isObject from 'lodash/isObject';
Severity: Minor
Found in src/buildVariables.ts - About 3 hrs to fix

    Function buildUpdateVariables has 142 lines of code (exceeds 100 allowed). Consider refactoring.
    Open

    const buildUpdateVariables = (introspectionResults: IntrospectionResult) => (
      resource: Resource,
      aorFetchType: string,
      params: UpdateParams,
      fieldAliasResolver?: RAGqlPrismaFieldAliasResolver,
    Severity: Major
    Found in src/buildVariables.ts - About 2 hrs to fix

      Function buildFields has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      export const buildFields = (introspectionResults: IntrospectionResult) => (
        fields: IntrospectionField[],
      ): FieldNode[] => {
        return fields.reduce(
          (acc: FieldNode[], field: IntrospectionField) => {
      Severity: Minor
      Found in src/buildGqlQuery.ts - 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 buildCreateVariables has 105 lines of code (exceeds 100 allowed). Consider refactoring.
      Open

      const buildCreateVariables = (introspectionResults: IntrospectionResult) => (
        resource: Resource,
        aorFetchType: string,
        params: CreateParams,
        fieldAliasResolver?: RAGqlPrismaFieldAliasResolver,
      Severity: Major
      Found in src/buildVariables.ts - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                          if (typeof nestedId === 'string') {
                            // XXX Handling a nested relationship field update. Must use connect on the updated id
                            return {
                              ...subAcc,
                              [subFieldName]: { [PRISMA_CONNECT]: { id: nestedId } },
        Severity: Major
        Found in src/buildVariables.ts - About 45 mins to fix

          Function buildFieldsFromFragment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          const buildFieldsFromFragment = (
            fragment: DocumentNode | string,
            resourceName: string,
            fetchType: string,
          ): SelectionNode[] => {
          Severity: Minor
          Found in src/buildGqlQuery.ts - 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

          Avoid too many return statements within this function.
          Open

              return { ...acc, [key]: params.filter[key] };
          Severity: Major
          Found in src/buildVariables.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  return acc;
            Severity: Major
            Found in src/buildVariables.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return { ...acc, [key]: parseFloat(params.filter[key]) };
              Severity: Major
              Found in src/buildVariables.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return {
                          ...acc,
                          where: {
                            id: value,
                          },
                Severity: Major
                Found in src/buildVariables.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                        return acc;
                  Severity: Major
                  Found in src/buildVariables.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return { ...acc, [key]: parseInt(params.filter[key]) };
                    Severity: Major
                    Found in src/buildVariables.ts - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return {
                                ...acc,
                                data: {
                                  ...acc.data,
                                  [fieldName]: data,
                      Severity: Major
                      Found in src/buildVariables.ts - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return {
                                  ...acc,
                                  data: {
                                    ...acc.data,
                                    [fieldName]: { [PRISMA_CONNECT]: { ...fieldsToConnect } },
                        Severity: Major
                        Found in src/buildVariables.ts - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return {
                                    ...acc,
                                    data: {
                                      ...acc.data,
                                      [fieldName]: value,
                          Severity: Major
                          Found in src/buildVariables.ts - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                        return {
                                          ...acc,
                                          data: {
                                            ...acc.data,
                                            [fieldName]: { [PRISMA_UPDATE]: { ...fieldsToUpdate } },
                            Severity: Major
                            Found in src/buildVariables.ts - About 30 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language