fratzinger/feathers-utils

View on GitHub

Showing 126 of 126 total issues

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

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

                result[dataOrResult].forEach((item) => {
                  assert.strictEqual(
                    item.userId,
                    1,
                    `${type}/${method}': ${dataOrResult} has 'userId:1'`,
      Severity: Major
      Found in src/hooks/setData.ts and 3 other locations - About 1 hr to fix
      src/hooks/setData.ts on lines 164..170
      src/hooks/setData.ts on lines 196..202
      src/hooks/setData.ts on lines 470..476

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

      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

              result[dataOrResult].forEach((item) => {
                assert.strictEqual(
                  item.userId,
                  1,
                  `'${type}/${method}': ${dataOrResult} has 'userId:1'`,
      Severity: Major
      Found in src/hooks/setData.ts and 3 other locations - About 1 hr to fix
      src/hooks/setData.ts on lines 164..170
      src/hooks/setData.ts on lines 400..406
      src/hooks/setData.ts on lines 470..476

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

      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

              result[dataOrResult].forEach((item) => {
                assert.strictEqual(
                  item.userId,
                  1,
                  `'${type}/${method}': ${dataOrResult} has 'userId:1'`,
      Severity: Major
      Found in src/hooks/setData.ts and 3 other locations - About 1 hr to fix
      src/hooks/setData.ts on lines 196..202
      src/hooks/setData.ts on lines 400..406
      src/hooks/setData.ts on lines 470..476

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

      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

                result[dataOrResult].forEach((item) => {
                  assert.strictEqual(
                    item.userId,
                    1,
                    `'${type}/${method}': ${dataOrResult} has 'userId:1'`,
      Severity: Major
      Found in src/hooks/setData.ts and 3 other locations - About 1 hr to fix
      src/hooks/setData.ts on lines 164..170
      src/hooks/setData.ts on lines 196..202
      src/hooks/setData.ts on lines 400..406

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

      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

      export type InferPatchData<S> = S extends {
        patch: (id: any, data: infer D, params: any) => any;
      }
        ? D
        : never;
      Severity: Minor
      Found in src/utility-types/index.ts and 1 other location - About 55 mins to fix
      src/utility-types/index.ts on lines 14..18

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

      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

      export type InferUpdateData<S> = S extends {
        update: (id: any, data: infer D, params: any) => any;
      }
        ? D
        : never;
      Severity: Minor
      Found in src/utility-types/index.ts and 1 other location - About 55 mins to fix
      src/utility-types/index.ts on lines 20..24

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

      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

            flattenQuery({
              a: {
                b: 1,
              },
              $and: [
      Severity: Minor
      Found in src/utils/flattenQuery.ts and 1 other location - About 50 mins to fix
      src/utils/deflattenQuery.ts on lines 75..107

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

      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("share same properties", function () {
            const query = areQueriesOverlapping({ id: 1 }, { id: 1 });
      
            expect(query).toBe(true);
          });
      Severity: Minor
      Found in src/utils/mergeQuery/utils.ts and 1 other location - About 50 mins to fix
      src/utils/mergeQuery/utils.ts on lines 412..416

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

      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("share same properties with different values", function () {
            const query = areQueriesOverlapping({ id: 1 }, { id: 2 });
      
            expect(query).toBe(true);
          });
      Severity: Minor
      Found in src/utils/mergeQuery/utils.ts and 1 other location - About 50 mins to fix
      src/utils/mergeQuery/utils.ts on lines 406..410

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

      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

          expect(
            deflattenQuery({
              "a.b": 1,
              $and: [
                {
      Severity: Minor
      Found in src/utils/deflattenQuery.ts and 1 other location - About 50 mins to fix
      src/utils/flattenQuery.ts on lines 121..139

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

      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

            ["get", "create", "update", "patch", "remove"].forEach((method) => {
              const context = makeContext(type, method);
              assert.strictEqual(
                isMulti(context),
                false,
      Severity: Minor
      Found in src/utils/isMulti.ts and 1 other location - About 45 mins to fix
      src/utils/isMulti.ts on lines 44..51

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

      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

      Avoid deeply nested control flow statements.
      Open

              if (!$in.some((x: unknown) => _isEqual(x, otherVal))) {
                $in.push(otherVal);
              }
      Severity: Major
      Found in src/utils/mergeQuery/utils.ts - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                if (!targetParent.$or) {
                  delete targetParent.$or;
                }
        Severity: Major
        Found in src/utils/mergeQuery/utils.ts - About 45 mins to fix

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

          export const validateQueryProperty = (
            query: any,
            operators: string[] = [],
          ): Query => {
            if (!isObject(query)) {
          Severity: Minor
          Found in src/utils/validateQueryProperty.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 deeply nested control flow statements.
          Open

                } else if (defaultHandle === "intersect") {
                  const newVals = sourceVal.filter(
                    (x: unknown) => !targetVal.some((y: unknown) => _isEqual(x, y)),
                  );
                  targetVal.push(...newVals);
          Severity: Major
          Found in src/utils/mergeQuery/utils.ts - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                  } else if (defaultHandle === "intersect") {
                    if ($in.some((x: unknown) => _isEqual(x, otherVal))) {
                      _set(target, prependKey, otherVal);
                    } else {
                      actionOnEmptyIntersect(target, source, prependKey);
            Severity: Major
            Found in src/utils/mergeQuery/utils.ts - About 45 mins to fix

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

                    ["find", "create", "patch", "remove"].forEach((method) => {
                      const context = makeContext(type, method);
                      assert.strictEqual(
                        isMulti(context),
                        true,
              Severity: Minor
              Found in src/utils/isMulti.ts and 1 other location - About 45 mins to fix
              src/utils/isMulti.ts on lines 68..75

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

              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

              Avoid deeply nested control flow statements.
              Open

                    if (defaultHandle === "combine") {
                      let $in: unknown[] = targetVal.concat(sourceVal);
                      $in = [...new Set($in)];
                      _set(target, prependKey, $in);
                      return;
              Severity: Major
              Found in src/utils/mergeQuery/utils.ts - About 45 mins to fix
                Severity
                Category
                Status
                Source
                Language