fratzinger/feathers-utils

View on GitHub

Showing 126 of 126 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    it("get:before", async function () {
      const context = {
        type: "before",
        method: "get",
        id: 1,
Severity: Major
Found in src/utils/getItemsIsArray.ts and 1 other location - About 1 hr to fix
src/utils/getItemsIsArray.ts on lines 174..185

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 68.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

  if (target?.$or) {
    target.$or = cleanOr(target.$or as Record<string, unknown>[]);
    if (!target.$or) {
      delete target.$or;
    }
Severity: Major
Found in src/utils/mergeQuery/utils.ts and 3 other locations - About 1 hr to fix
src/utils/mergeQuery/utils.ts on lines 52..57
src/utils/mergeQuery/utils.ts on lines 59..64
src/utils/mergeQuery/utils.ts on lines 66..71

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 65.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

  if (source?.$or) {
    source.$or = cleanOr(source.$or as Record<string, unknown>[]);
    if (!source.$or) {
      delete source.$or;
    }
Severity: Major
Found in src/utils/mergeQuery/utils.ts and 3 other locations - About 1 hr to fix
src/utils/mergeQuery/utils.ts on lines 46..51
src/utils/mergeQuery/utils.ts on lines 59..64
src/utils/mergeQuery/utils.ts on lines 66..71

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 65.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

  if (source?.$and) {
    source.$and = cleanAnd(source.$and as Record<string, unknown>[]);
    if (!source.$and) {
      delete source.$and;
    }
Severity: Major
Found in src/utils/mergeQuery/utils.ts and 3 other locations - About 1 hr to fix
src/utils/mergeQuery/utils.ts on lines 46..51
src/utils/mergeQuery/utils.ts on lines 52..57
src/utils/mergeQuery/utils.ts on lines 59..64

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 65.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

  if (target?.$and) {
    target.$and = cleanAnd(target.$and as Record<string, unknown>[]);
    if (!target.$and) {
      delete target.$and;
    }
Severity: Major
Found in src/utils/mergeQuery/utils.ts and 3 other locations - About 1 hr to fix
src/utils/mergeQuery/utils.ts on lines 46..51
src/utils/mergeQuery/utils.ts on lines 52..57
src/utils/mergeQuery/utils.ts on lines 66..71

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 65.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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 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 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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              it("pushes to existing array", function () {
                const obj = {
                  arr: [1],
                };
                pushSet(obj, ["arr"], 2);
            Severity: Major
            Found in src/utils/pushSet.ts and 1 other location - About 1 hr to fix
            src/utils/pushSet.ts on lines 51..57

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 60.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              it("adds existing element", function () {
                const obj = {
                  arr: [1],
                };
                pushSet(obj, ["arr"], 1);
            Severity: Major
            Found in src/utils/pushSet.ts and 1 other location - About 1 hr to fix
            src/utils/pushSet.ts on lines 37..43

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 60.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

            export type InferPatchResult<S, IdOrNullable = any> = S extends {
              patch: (id: Id, data: any, params: any) => infer R;
            }
              ? IdOrNullable extends Id
                ? Single<Awaited<R>>
            Severity: Major
            Found in src/utility-types/index.ts and 1 other location - About 1 hr to fix
            src/utility-types/index.ts on lines 66..74

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 60.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

            export type InferRemoveResult<S, IdOrNullable = any> = S extends {
              remove: (id: IdOrNullable, params: any) => infer R;
            }
              ? IdOrNullable extends Id
                ? Single<Awaited<R>>
            Severity: Major
            Found in src/utility-types/index.ts and 1 other location - About 1 hr to fix
            src/utility-types/index.ts on lines 56..64

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 60.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                      result[dataOrResult].forEach((item, i) => {
                        assert.strictEqual(
                          item.userId,
                          i,
                          `${type}/${method}': ${dataOrResult} has 'userId:${i}`,
            Severity: Major
            Found in src/hooks/setData.ts and 1 other location - About 1 hr to fix
            src/hooks/setData.ts on lines 576..582

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 60.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                      result[dataOrResult].forEach((item, i) => {
                        assert.strictEqual(
                          item.userId,
                          i,
                          `${type}/${method}': ${dataOrResult} has 'userId:${i}`,
            Severity: Major
            Found in src/hooks/setData.ts and 1 other location - About 1 hr to fix
            src/hooks/setData.ts on lines 434..440

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 60.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            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 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 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
                  Severity
                  Category
                  Status
                  Source
                  Language