hansololai/postgraphile-polymorphic-relation-plugin

View on GitHub
src/pgConnectionArgFilterBackwardPolyRelationPlugin.ts

Summary

Maintainability
A
2 hrs
Test Coverage
A
96%

Function addBackwardPolyManyFilter has 96 lines of code (exceeds 25 allowed). Consider refactoring.
Wontfix

const addBackwardPolyManyFilter = (builder: SchemaBuilder) => {

  builder.hook('GraphQLInputObjectType:fields', (fields, build, context) => {
    const {
      extend,
Severity: Major
Found in src/pgConnectionArgFilterBackwardPolyRelationPlugin.ts - About 3 hrs to fix

    Function addBackwardPolySingleFilter has 80 lines of code (exceeds 25 allowed). Consider refactoring.
    Wontfix

    const addBackwardPolySingleFilter = (builder: SchemaBuilder) => {
      // const { pgSimpleCollections } = option;
      // const hasConnections = pgSimpleCollections !== 'only';
      builder.hook('GraphQLInputObjectType:fields', (fields, build, context) => {
        const {
    Severity: Major
    Found in src/pgConnectionArgFilterBackwardPolyRelationPlugin.ts - About 3 hrs to fix

      Function addBackwardPolyManyFilter has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Wontfix

      const addBackwardPolyManyFilter = (builder: SchemaBuilder) => {
      
        builder.hook('GraphQLInputObjectType:fields', (fields, build, context) => {
          const {
            extend,
      Severity: Minor
      Found in src/pgConnectionArgFilterBackwardPolyRelationPlugin.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 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 addBackwardPolySingleFilter has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Wontfix

        const addBackwardPolySingleFilter = (builder: SchemaBuilder) => {
          // const { pgSimpleCollections } = option;
          // const hasConnections = pgSimpleCollections !== 'only';
          builder.hook('GraphQLInputObjectType:fields', (fields, build, context) => {
            const {
        Severity: Minor
        Found in src/pgConnectionArgFilterBackwardPolyRelationPlugin.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

        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

          There are no issues that match your filters.

          Category
          Status