packages/babel-core/src/config/validation/option-assertions.js

Summary

Maintainability
D
2 days
Test Coverage

File option-assertions.js has 333 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// @flow

import type {
  ConfigFileSearch,
  BabelrcSearch,
Severity: Minor
Found in packages/babel-core/src/config/validation/option-assertions.js - About 4 hrs to fix

    Function assertPluginItem has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    function assertPluginItem(loc: GeneralPath, value: mixed): PluginItem {
      if (Array.isArray(value)) {
        if (value.length === 0) {
          throw new Error(`${msg(loc)} must include an object`);
        }
    Severity: Minor
    Found in packages/babel-core/src/config/validation/option-assertions.js - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function assertPluginItem has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function assertPluginItem(loc: GeneralPath, value: mixed): PluginItem {
      if (Array.isArray(value)) {
        if (value.length === 0) {
          throw new Error(`${msg(loc)} must include an object`);
        }
    Severity: Minor
    Found in packages/babel-core/src/config/validation/option-assertions.js - About 1 hr to fix

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

      export function assertCallerMetadata(
        loc: OptionPath,
        value: mixed,
      ): CallerMetadata | void {
        const obj = assertObject(loc, value);
      Severity: Minor
      Found in packages/babel-core/src/config/validation/option-assertions.js - 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

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

      export function assertSourceType(
        loc: OptionPath,
        value: mixed,
      ): SourceTypeOption | void {
        if (
      packages/babel-core/src/config/validation/option-assertions.js on lines 64..76

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

      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 function assertRootMode(loc: OptionPath, value: mixed): RootMode | void {
        if (
          value !== undefined &&
          value !== "root" &&
          value !== "upward" &&
      packages/babel-core/src/config/validation/option-assertions.js on lines 105..120

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

      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

        if (Array.isArray(value)) {
          value.forEach((item, i) => {
            if (!checkValidTest(item)) {
              throw new Error(
                `${msg(access(loc, i))} must be a string/Function/RegExp.`,
      packages/babel-core/src/config/validation/option-assertions.js on lines 294..307

      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

        if (Array.isArray(value)) {
          value.forEach((item, i) => {
            if (!checkValidTest(item)) {
              throw new Error(
                `${msg(access(loc, i))} must be a string/Function/RegExp.`,
      packages/babel-core/src/config/validation/option-assertions.js on lines 246..258

      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

        } else if (!checkValidTest(value)) {
          throw new Error(
            `${msg(loc)} must be a undefined, a boolean, a string/Function/RegExp ` +
              `or an array of those, got ${JSON.stringify((value: any))}`,
          );
      Severity: Minor
      Found in packages/babel-core/src/config/validation/option-assertions.js and 1 other location - About 50 mins to fix
      packages/babel-core/src/config/validation/option-assertions.js on lines 274..283

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

      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

        if (
          value !== undefined &&
          typeof value !== "boolean" &&
          typeof value !== "string"
        ) {
      Severity: Minor
      Found in packages/babel-core/src/config/validation/option-assertions.js and 1 other location - About 50 mins to fix
      packages/babel-core/src/config/validation/option-assertions.js on lines 302..307

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

      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 3 locations. Consider refactoring.
      Open

      export function assertString(loc: GeneralPath, value: mixed): string | void {
        if (value !== undefined && typeof value !== "string") {
          throw new Error(`${msg(loc)} must be a string, or undefined`);
        }
        return value;
      Severity: Minor
      Found in packages/babel-core/src/config/validation/option-assertions.js and 2 other locations - About 40 mins to fix
      packages/babel-core/src/config/validation/option-assertions.js on lines 178..186
      packages/babel-core/src/config/validation/option-assertions.js on lines 188..193

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

      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 3 locations. Consider refactoring.
      Open

      export function assertFunction(
        loc: GeneralPath,
        value: mixed,
      ): Function | void {
        if (value !== undefined && typeof value !== "function") {
      Severity: Minor
      Found in packages/babel-core/src/config/validation/option-assertions.js and 2 other locations - About 40 mins to fix
      packages/babel-core/src/config/validation/option-assertions.js on lines 171..176
      packages/babel-core/src/config/validation/option-assertions.js on lines 188..193

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

      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 3 locations. Consider refactoring.
      Open

      export function assertBoolean(loc: GeneralPath, value: mixed): boolean | void {
        if (value !== undefined && typeof value !== "boolean") {
          throw new Error(`${msg(loc)} must be a boolean, or undefined`);
        }
        return value;
      Severity: Minor
      Found in packages/babel-core/src/config/validation/option-assertions.js and 2 other locations - About 40 mins to fix
      packages/babel-core/src/config/validation/option-assertions.js on lines 171..176
      packages/babel-core/src/config/validation/option-assertions.js on lines 178..186

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

      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

      There are no issues that match your filters.

      Category
      Status