fratzinger/feathers-utils

View on GitHub

Showing 60 of 126 total issues

Function handleCircular has a Cognitive Complexity of 93 (exceeds 5 allowed). Consider refactoring.
Open

export function handleCircular(
  target: Record<string, unknown>,
  source: Record<string, unknown>,
  prependKey: Path,
  options: MergeQueryOptions,
Severity: Minor
Found in src/utils/mergeQuery/utils.ts - About 1 day 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 setData.ts has 520 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import _get from "lodash/get.js";
import _set from "lodash/set.js";
import _has from "lodash/has.js";

import { Forbidden } from "@feathersjs/errors";
Severity: Major
Found in src/hooks/setData.ts - About 1 day to fix

    Function handleCircular has 181 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function handleCircular(
      target: Record<string, unknown>,
      source: Record<string, unknown>,
      prependKey: Path,
      options: MergeQueryOptions,
    Severity: Major
    Found in src/utils/mergeQuery/utils.ts - About 7 hrs to fix

      File utils.ts has 394 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { Forbidden } from "@feathersjs/errors";
      import _get from "lodash/get.js";
      import _has from "lodash/has.js";
      
      import _set from "lodash/set.js";
      Severity: Minor
      Found in src/utils/mergeQuery/utils.ts - About 5 hrs to fix

        Function mergeArrays has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

        export function mergeArrays<T>(
          targetArr: T[] | undefined,
          sourceArr: T[] | undefined,
          handle: Handle,
          prependKey?: Path,
        Severity: Minor
        Found in src/utils/mergeQuery/mergeArrays.ts - About 3 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 getItemsIsArray.ts has 274 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import type { HookContext } from "@feathersjs/feathers";
        
        export type GetItemsIsArrayFrom = "data" | "result" | "automatic";
        
        export type GetItemsIsArrayOptions = {
        Severity: Minor
        Found in src/utils/getItemsIsArray.ts - About 2 hrs to fix

          File setResultEmpty.ts has 260 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import type { HookContext } from "@feathersjs/feathers";
          import { isMulti } from "./isMulti";
          import { isPaginated } from "./isPaginated";
          
          /**
          Severity: Minor
          Found in src/utils/setResultEmpty.ts - About 2 hrs to fix

            Function flattenQuery has 52 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function flattenQuery(q: Query) {
              if (Array.isArray(q)) {
                return q.map(flattenQuery);
              }
            
            
            Severity: Major
            Found in src/utils/flattenQuery.ts - About 2 hrs to fix

              Function getItemsIsArray has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              export const getItemsIsArray = <T = any, H extends HookContext = HookContext>(
                context: H,
                options?: GetItemsIsArrayOptions,
              ): GetItemsIsArrayResult<T> => {
                const { from = "automatic" } = options || {};
              Severity: Minor
              Found in src/utils/getItemsIsArray.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 setData has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function setData<H extends HookContext = HookContext>(
                from: PropertyPath,
                to: PropertyPath,
                _options?: HookSetDataOptions,
              ) {
              Severity: Minor
              Found in src/hooks/setData.ts - About 1 hr to fix

                Function mergeArrays has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function mergeArrays<T>(
                  targetArr: T[] | undefined,
                  sourceArr: T[] | undefined,
                  handle: Handle,
                  prependKey?: Path,
                Severity: Minor
                Found in src/utils/mergeQuery/mergeArrays.ts - About 1 hr to fix

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

                  export const setQueryKeySafely = (
                    params: Params,
                    key: string,
                    value: any,
                    operator = "$eq",
                  Severity: Minor
                  Found in src/utils/setQueryKeySafely.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 defineParamsFromClient has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function defineParamsFromClient(keyToHide: string) {
                    return function paramsFromClient(
                      ...whitelist: string[]
                    ): (context: HookContext) => HookContext {
                      return (context: HookContext): HookContext => {
                  Severity: Minor
                  Found in src/hooks/from-client-for-server/paramsFromClient.ts - About 1 hr to fix

                    Function setQueryKeySafely has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export const setQueryKeySafely = (
                      params: Params,
                      key: string,
                      value: any,
                      operator = "$eq",
                    Severity: Minor
                    Found in src/utils/setQueryKeySafely.ts - About 1 hr to fix

                      Function forEach has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export const forEach = <H extends HookContext = HookContext, T = any, R = any>(
                        actionPerItem: ActionPerItem<T, H, R>,
                        options?: HookForEachOptions<T, H, R>,
                      ): ReturnAsyncHook<H> => {
                        const { wait = "parallel", items: from = "automatic" } = options || {};
                      Severity: Minor
                      Found in src/hooks/forEach.ts - About 1 hr to fix

                        Function step has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          function step(object: Query, options?: StepOptions) {
                            const { prev = [], result = res } = options ?? {};
                        
                            Object.keys(object).forEach((key) => {
                              const value = object[key];
                        Severity: Minor
                        Found in src/utils/flattenQuery.ts - About 1 hr to fix

                          Function defineParamsForServer has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export function defineParamsForServer(keyToHide: string) {
                            return function paramsForServer(...whitelist: string[]) {
                              return <H extends HookContext>(context: H) => {
                                // clone params on demand
                                let clonedParams;
                          Severity: Minor
                          Found in src/hooks/from-client-for-server/paramsForServer.ts - About 1 hr to fix

                            Function paramsFromClient has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              return function paramsFromClient(
                                ...whitelist: string[]
                              ): (context: HookContext) => HookContext {
                                return (context: HookContext): HookContext => {
                                  if (
                            Severity: Minor
                            Found in src/hooks/from-client-for-server/paramsFromClient.ts - About 1 hr to fix

                              Function optimizeBatchPatch has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export function optimizeBatchPatch<
                                T extends Record<string, any>,
                                IdKey extends KeyOf<T>,
                                P extends Params,
                                R extends Omit<T, IdKey> = Omit<T, IdKey>,
                              Severity: Minor
                              Found in src/utils/optimizeBatchPatch.ts - About 1 hr to fix

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

                                  return function paramsForServer(...whitelist: string[]) {
                                    return <H extends HookContext>(context: H) => {
                                      // clone params on demand
                                      let clonedParams;
                                
                                
                                Severity: Minor
                                Found in src/hooks/from-client-for-server/paramsForServer.ts - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language