regevbr/json-expression-eval

View on GitHub

Showing 21 of 69 total issues

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

export interface NinCompareOp<C extends Context, Ignore, V extends Primitive> {
    nin: (V | PropertyRef<C, Ignore, V> | (V extends number ? MathOp<C, Ignore> : never))[];
}
Severity: Major
Found in src/types/evaluator.ts and 1 other location - About 2 hrs to fix
src/types/evaluator.ts on lines 43..45

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

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 interface InqCompareOp<C extends Context, Ignore, V extends Primitive> {
    inq: (V | PropertyRef<C, Ignore, V> | (V extends number ? MathOp<C, Ignore> : never))[];
}
Severity: Major
Found in src/types/evaluator.ts and 1 other location - About 2 hrs to fix
src/types/evaluator.ts on lines 47..49

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

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 interface NotEqualCompareOp<C extends Context, Ignore, V extends Primitive> {
    neq: V | PropertyRef<C, Ignore, V> | (V extends number ? MathOp<C, Ignore> : never);
}
Severity: Major
Found in src/types/evaluator.ts and 1 other location - About 1 hr to fix
src/types/evaluator.ts on lines 35..37

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

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 interface EqualCompareOp<C extends Context, Ignore, V extends Primitive> {
    eq: V | PropertyRef<C, Ignore, V> | (V extends number ? MathOp<C, Ignore> : never);
}
Severity: Major
Found in src/types/evaluator.ts and 1 other location - About 1 hr to fix
src/types/evaluator.ts on lines 39..41

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

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 const isNinCompareOp = (op: ExtendedCompareOp<any, any, any>)
    : op is NinCompareOp<any, any, any> => {
    return Array.isArray((op as NinCompareOp<any, any, any>).nin);
}
Severity: Major
Found in src/lib/typeGuards.ts and 1 other location - About 1 hr to fix
src/lib/typeGuards.ts on lines 103..106

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

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 const isInqCompareOp = (op: ExtendedCompareOp<any, any, any>)
    : op is InqCompareOp<any, any, any> => {
    return Array.isArray((op as InqCompareOp<any, any, any>).inq);
}
Severity: Major
Found in src/lib/typeGuards.ts and 1 other location - About 1 hr to fix
src/lib/typeGuards.ts on lines 108..111

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

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 const isNotEqualCompareOp = (op: ExtendedCompareOp<any, any, any>)
    : op is NotEqualCompareOp<any, any, any> => {
    return (op as NotEqualCompareOp<any, any, any>).neq !== undefined;
}
Severity: Major
Found in src/lib/typeGuards.ts and 1 other location - About 1 hr to fix
src/lib/typeGuards.ts on lines 93..96

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

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 const isEqualCompareOp = (op: ExtendedCompareOp<any, any, any>)
    : op is EqualCompareOp<any, any, any> => {
    return (op as EqualCompareOp<any, any, any>).eq !== undefined;
}
Severity: Major
Found in src/lib/typeGuards.ts and 1 other location - About 1 hr to fix
src/lib/typeGuards.ts on lines 98..101

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

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 evaluateCompareOp has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

async function evaluateCompareOp<C extends Context, Ignore>(expressionValue: ExtendedCompareOp<any, any, any>,
                                                            expressionKey: string, contextValue: any,
                                                            context: C, validation: boolean)
Severity: Minor
Found in src/lib/evaluator.ts - About 35 mins to fix

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

        } else if (isLteCompareOp(expressionValue)) {
            contextNumberAssertion(expressionKey, contextValue);
            const lteValue = computeValue(context, validation, expressionValue.lte, expressionKey);
            expressionNumberAssertion(expressionKey, lteValue);
            return contextValue <= lteValue;
    Severity: Major
    Found in src/lib/evaluator.ts and 3 other locations - About 30 mins to fix
    src/lib/evaluator.ts on lines 111..147
    src/lib/evaluator.ts on lines 116..147
    src/lib/evaluator.ts on lines 126..147

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

    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 too many return statements within this function.
    Open

            return expressionValue.nin.map((value) => computeValue(context, validation, value, expressionKey))
                .indexOf(contextValue) < 0;
    Severity: Major
    Found in src/lib/evaluator.ts - About 30 mins to fix

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

          } else if (isGteCompareOp(expressionValue)) {
              contextNumberAssertion(expressionKey, contextValue);
              const gteValue = computeValue(context, validation, expressionValue.gte, expressionKey);
              expressionNumberAssertion(expressionKey, gteValue);
              return contextValue >= gteValue;
      Severity: Major
      Found in src/lib/evaluator.ts and 3 other locations - About 30 mins to fix
      src/lib/evaluator.ts on lines 111..147
      src/lib/evaluator.ts on lines 121..147
      src/lib/evaluator.ts on lines 126..147

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

      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 too many return statements within this function.
      Open

              return evaluateCompareOp<C, Ignore>(
                  (expression as PropertyCompareOps<C, Ignore>)
                      [expressionKey as any as keyof PropertyCompareOps<C, Ignore>] as
                      unknown as ExtendedCompareOp<any, any, any>,
                  expressionKey, contextValue, context, validation);
      Severity: Major
      Found in src/lib/evaluator.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return contextValue > gtValue;
        Severity: Major
        Found in src/lib/evaluator.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return Boolean(contextValue.match(new RegExp(regexpiValue, `i`)));
          Severity: Major
          Found in src/lib/evaluator.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return contextValue < ltValue;
            Severity: Major
            Found in src/lib/evaluator.ts - About 30 mins to fix

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

                  } else if (isGtCompareOp(expressionValue)) {
                      contextNumberAssertion(expressionKey, contextValue);
                      const gtValue = computeValue(context, validation, expressionValue.gt, expressionKey);
                      expressionNumberAssertion(expressionKey, gtValue);
                      return contextValue > gtValue;
              Severity: Major
              Found in src/lib/evaluator.ts and 3 other locations - About 30 mins to fix
              src/lib/evaluator.ts on lines 116..147
              src/lib/evaluator.ts on lines 121..147
              src/lib/evaluator.ts on lines 126..147

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

              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 too many return statements within this function.
              Open

                      return Boolean(contextValue.match(new RegExp(regexpValue)));
              Severity: Major
              Found in src/lib/evaluator.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return contextValue >= gteValue;
                Severity: Major
                Found in src/lib/evaluator.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                          return contextValue <= lteValue;
                  Severity: Major
                  Found in src/lib/evaluator.ts - About 30 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language