hansololai/postgraphile-polymorphic-relation-plugin

View on GitHub

Showing 15 of 25 total issues

Function generateFieldWithHookFunc has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const generateFieldWithHookFunc = (
  build: GraphileBuild,
  innerTable: PgClass,
  joinCallback: (qb1: QueryBuilder, qb2: QueryBuilder) => void,
  isUnique: boolean = true,
Severity: Major
Found in src/utils.ts - About 3 hrs to fix

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

    export const addBackwardPolyAssociation = (builder: SchemaBuilder, option: Options) => {
    
      // const { pgSimpleCollections } = option;
      // const hasConnections = pgSimpleCollections !== 'only';
      builder.hook('GraphQLObjectType:fields', (fields, build, context) => {
    Severity: Major
    Found in src/add_backward_poly_association_plugin.ts - About 2 hrs to fix

      Function backwardRelationFields has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            .reduce((acc, currentPoly) => {
              const foreignTable = currentPoly.from;
              if (!foreignTable || omit(foreignTable, 'read')) {
                return acc;
              }
      Severity: Major
      Found in src/pgConnectionArgFilterBackwardPolyRelationPlugin.ts - About 2 hrs to fix

        Function addForwardPolyAssociation has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const addForwardPolyAssociation = (builder: SchemaBuilder, option: Options) => {
          builder.hook('inflection', inflection => ({
            ...inflection,
            forwardRelationByPolymorphic(table: PgClass, polymorphicName: string) {
              return this.camelCase(`${this.singularize(table.name)}-as-${polymorphicName}`);
        Severity: Major
        Found in src/add_forward_poly_association_plugin.ts - About 2 hrs to fix

          Function addForwardPolyRelationFilter has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const addForwardPolyRelationFilter = (builder: SchemaBuilder) => {
            builder.hook('GraphQLInputObjectType:fields', (fields, build, context) => {
              const {
                extend,
                inflection,
          Severity: Minor
          Found in src/pgConnectionArgFilterForwardPolyRelationPlugin.ts - About 1 hr to fix

            Function columnToPolyConstraint has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const columnToPolyConstraint = (build: GraphileBuild, attr: PgAttribute) => {
              const {
                name,
                tags: { polymorphicTo = [], isPolymorphic },
              } = attr;
            Severity: Minor
            Found in src/utils.ts - About 1 hr to fix

              Function backwardPolyAssociation has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    .reduce((memo, currentPoly) => {
                      // const { name } = currentPoly;
                      const foreignTable = currentPoly.from;
                      if (omit(foreignTable, 'read')) {
                        return memo;
              Severity: Minor
              Found in src/add_backward_poly_association_plugin.ts - About 1 hr to fix

                Function addBackwardPolyAssociation has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                export const addBackwardPolyAssociation = (builder: SchemaBuilder, option: Options) => {
                
                  // const { pgSimpleCollections } = option;
                  // const hasConnections = pgSimpleCollections !== 'only';
                  builder.hook('GraphQLObjectType:fields', (fields, build, context) => {
                Severity: Minor
                Found in src/add_backward_poly_association_plugin.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 pgQuery has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        pgQuery: (queryBuilder: QueryBuilder) => {
                          queryBuilder.select(() => {
                            const resolveData = getDataFromParsedResolveInfoFragment(
                              parsedResolveInfoFragment,
                              returnType,
                Severity: Minor
                Found in src/utils.ts - About 1 hr to fix

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

                        .reduce((memo, currentPoly) => {
                          const { name } = currentPoly;
                          const fieldsPerPolymorphicConstraint = currentPoly.to.reduce((acc, polyC) => {
                            const { pgClass: foreignTable,
                              name: mName,
                  Severity: Minor
                  Found in src/add_forward_poly_association_plugin.ts - About 1 hr to fix

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

                    export const addForwardPolyRelationFilter = (builder: SchemaBuilder) => {
                      builder.hook('GraphQLInputObjectType:fields', (fields, build, context) => {
                        const {
                          extend,
                          inflection,
                    Severity: Minor
                    Found in src/pgConnectionArgFilterForwardPolyRelationPlugin.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

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

                    export const columnToPolyConstraint = (build: GraphileBuild, attr: PgAttribute) => {
                      const {
                        name,
                        tags: { polymorphicTo = [], isPolymorphic },
                      } = attr;
                    Severity: Minor
                    Found in src/utils.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 true;
                    Severity: Major
                    Found in src/utils.ts - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return sql.query`not exists(${sqlSelectWhereKeysMatch} and (${sqlFragment}))`;
                      Severity: Major
                      Found in src/pgConnectionArgFilterBackwardPolyRelationPlugin.ts - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                            if (!c.keyAttributes.find(a => a.name === sourceTableType)) return false;
                        Severity: Major
                        Found in src/utils.ts - About 30 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language