fratzinger/feathers-trigger

View on GitHub

Showing 4 of 4 total issues

Function triggerAfter has a Cognitive Complexity of 50 (exceeds 8 allowed). Consider refactoring.
Open

const triggerAfter = async <H extends HookContext>(context: H): Promise<H> => {
  const subs = getConfig(context, "subscriptions");
  if (!subs?.length) {
    return context;
  }
Severity: Minor
Found in src/hooks/trigger.ts - About 7 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 trigger.ts has 434 lines of code (exceeds 300 allowed). Consider refactoring.
Open

import { checkContext } from "feathers-hooks-common";
import type { ManipulateParams, Change } from "./changesById";
import {
  changesByIdBefore,
  changesByIdAfter,
Severity: Minor
Found in src/hooks/trigger.ts - About 5 hrs to fix

    Function triggerAfter has 115 lines of code (exceeds 100 allowed). Consider refactoring.
    Open

    const triggerAfter = async <H extends HookContext>(context: H): Promise<H> => {
      const subs = getConfig(context, "subscriptions");
      if (!subs?.length) {
        return context;
      }
    Severity: Major
    Found in src/hooks/trigger.ts - About 1 hr to fix

      Function triggerBefore has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
      Open

      const triggerBefore = async <H extends HookContext, T = Record<string, any>>(
        context: H,
        options: HookTriggerOptions<H, T>,
      ): Promise<H> => {
        let subs = await getSubscriptions(context, options);
      Severity: Minor
      Found in src/hooks/trigger.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

      Severity
      Category
      Status
      Source
      Language