freddi301/flow-validator

View on GitHub

Showing 207 of 207 total issues

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

declare function Vtakes<P, R>(t: VType<P>): (f: (p: P) => R) => (p: P) => R; // eslint-disable-line no-redeclare
Severity: Major
Found in src/sync/takes.js and 1 other location - About 1 hr to fix
src/sync/takes.js on lines 45..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 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

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

      try {
        result[key] = s[key].parse(o[key]);
      } catch (e) {
        if (e instanceof ValidationError) errors[key] = e;
        else throw e;
Severity: Major
Found in src/sync/object.js and 1 other location - About 1 hr to fix
src/sync/objectExact.js on lines 22..27

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

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

        try {
          result[key] = s[key].parse(o[key]);
        } catch (e) {
          if (e instanceof ValidationError) errors[key] = e;
          else throw e;
Severity: Major
Found in src/sync/objectExact.js and 1 other location - About 1 hr to fix
src/sync/object.js on lines 16..21

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

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 truthy: Type<true> = new Type("truthy", v => {
  if (Boolean(v) === true) return true;
  throw new ValidationError({ expected: truthy, got: v });
});
Severity: Major
Found in src/sync/base.js and 1 other location - About 1 hr to fix
src/sync/base.js on lines 82..85

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

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 falsy: Type<false> = new Type("falsy", v => {
  if (Boolean(v) === false) return true;
  throw new ValidationError({ expected: truthy, got: v });
});
Severity: Major
Found in src/sync/base.js and 1 other location - About 1 hr to fix
src/sync/base.js on lines 77..80

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

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 asyncMapping has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function asyncMapping<K: string, V>(
  keys: AsyncType<K>,
  values: AsyncType<V>
): AsyncMappingType<K, V> {
  const m = new AsyncMappingType(keys, values, async v => {
Severity: Minor
Found in src/async/asyncMapping.js - About 1 hr to fix

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

        const rf = new AsyncVRefinedType(this, async v => {
          const vResolved = await v;
          return refinement(
            await this.parse(v),
            (err: string) =>
    Severity: Major
    Found in src/async/AsyncVType.js and 1 other location - About 1 hr to fix
    src/async/AsyncType.js on lines 22..33

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

    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 noProperty: VType<void> = new VType("noProperty", v => {
      if (v === void 0) return v;
      throw new ValidationError({ expected: isUndefined, got: v });
    });
    Severity: Major
    Found in src/sync/base.js and 1 other location - About 1 hr to fix
    src/sync/base.js on lines 17..20

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

    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

        const tr = new AsyncType("transformation", async v => {
          const vResolved = await v;
          return transformation(
            await this.parse(v),
            (err: string) =>
    Severity: Major
    Found in src/async/AsyncType.js and 1 other location - About 1 hr to fix
    src/async/AsyncVType.js on lines 18..29

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

    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 isUndefined: VType<void> = new VType("undefined", v => {
      if (v === void 0) return v;
      throw new ValidationError({ expected: isUndefined, got: v });
    });
    Severity: Major
    Found in src/sync/base.js and 1 other location - About 1 hr to fix
    src/sync/base.js on lines 22..25

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

    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 mapping has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function mapping<K: string, V>(
      keys: Type<K>,
      values: Type<V>
    ): MappingType<K, V> {
      const m = new MappingType(keys, values, v => {
    Severity: Minor
    Found in src/sync/mapping.js - About 1 hr to fix

      Function Vobject has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      export function Vobject<S: { [key: string]: VType<any> }>(
        s: S
      ): VObjectType<S, $ObjMap<S, <F>(v: VType<F>) => F>> {
        const os = new VObjectType(s, v => {
          const o = objectType.validate(v);
      Severity: Minor
      Found in src/sync/Vobject.js - 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 tuple has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      export function tuple<S: Array<Type<any>>>(
        s: S
      ): TupleType<$TupleMap<S, <T>(v: Type<T>) => T>> {
        // eslint-disable-line no-redeclare
        const tt = new TupleType(s, v => {
      Severity: Minor
      Found in src/sync/tuple.js - 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 object has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      export function object<S: { [key: string]: Type<any> }>(
        s: S
      ): ObjectType<S, $ObjMap<S, <F>(v: Type<F>) => F>> {
        const os = new ObjectType(s, v => {
          const o = objectType.validate(v);
      Severity: Minor
      Found in src/sync/object.js - 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 Vtuple has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      export function Vtuple<S: Array<VType<any>>>(
        s: S
      ): VTupleType<$TupleMap<S, <T>(v: Type<T>) => T>> {
        // eslint-disable-line no-redeclare
        const tt = new VTupleType(s, v => {
      Severity: Minor
      Found in src/sync/tuple.js - 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

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

      declare function returns<P, R>(t: Type<R>): (f: (p: P) => R) => (p: P) => R;
      Severity: Major
      Found in src/sync/returns.js and 1 other location - About 1 hr to fix
      src/sync/returns.js on lines 61..61

      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

      declare function Vreturns<P, R>(t: VType<R>): (f: (p: P) => R) => (p: P) => R;
      Severity: Major
      Found in src/sync/returns.js and 1 other location - About 1 hr to fix
      src/sync/returns.js on lines 28..28

      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 m has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        const m = new AsyncMappingType(keys, values, async v => {
          const o = objectType.validate(await v);
          const ks = Object.keys(o);
          const result = {};
          const errors = {};
      Severity: Minor
      Found in src/async/asyncMapping.js - About 1 hr to fix

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

        export function asyncVmapping<K: string, V>(
          keys: AsyncVType<K>,
          values: AsyncVType<V>
        ): AsyncVMappingType<K, V> {
          const m = new AsyncVMappingType(keys, values, async v => {
        Severity: Minor
        Found in src/async/asyncVmapping.js - About 1 hr to fix

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

            const m = new MappingType(keys, values, v => {
              const o = objectType.validate(v);
              const ks = Object.keys(o);
              const result = {};
              const errors = {};
          Severity: Minor
          Found in src/sync/mapping.js - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language