baublet/w8mngr

View on GitHub
api/helpers/buildConnectionResolver/buildConnectionResolver.ts

Summary

Maintainability
D
2 days
Test Coverage

Function buildConnectionResolver has 183 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function buildConnectionResolver<TEntity, TNode = TEntity>(
  query: QueryBuilder,
  args: {
    before?: string | null;
    last?: number | null;
Severity: Major
Found in api/helpers/buildConnectionResolver/buildConnectionResolver.ts - About 7 hrs to fix

    Function buildConnectionResolver has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

    export async function buildConnectionResolver<TEntity, TNode = TEntity>(
      query: QueryBuilder,
      args: {
        before?: string | null;
        last?: number | null;
    Severity: Minor
    Found in api/helpers/buildConnectionResolver/buildConnectionResolver.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 buildConnectionResolver.ts has 276 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { assertIsError } from "../../../shared";
    import { Resolvable } from "../../../shared/types";
    import { QueryBuilder } from "../../config/db";
    import { log } from "../../config/log";
    import { isBefore } from "./isBefore";
    Severity: Minor
    Found in api/helpers/buildConnectionResolver/buildConnectionResolver.ts - About 2 hrs to fix

      Function edgesFn has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          const edgesFn = () => {
            if (!edges) {
              edges = new Promise<
                {
                  cursor: string;
      Severity: Minor
      Found in api/helpers/buildConnectionResolver/buildConnectionResolver.ts - About 1 hr to fix

        Function orZero has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        function orZero(value: any): number {
          if (typeof value === "number") return value;
          if (typeof value === "string") {
            const num = parseInt(value, 10);
            if (num < 0) {
        Severity: Minor
        Found in api/helpers/buildConnectionResolver/buildConnectionResolver.ts - About 45 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 0;
        Severity: Major
        Found in api/helpers/buildConnectionResolver/buildConnectionResolver.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return num;
          Severity: Major
          Found in api/helpers/buildConnectionResolver/buildConnectionResolver.ts - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status