packages/babel-types/src/definitions/core.js

Summary

Maintainability
F
5 days
Test Coverage

File core.js has 1046 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// @flow

import is from "../validators/is";
import isValidIdentifier from "../validators/isValidIdentifier";
import { isKeyword, isReservedWord } from "@babel/helper-validator-identifier";
Severity: Major
Found in packages/babel-types/src/definitions/core.js - About 2 days to fix

    Function validate has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

      validate(parent, key, node) {
        if (!process.env.BABEL_TYPES_8_BREAKING) return;
    
        const match = /\.(\w+)$/.exec(key);
        if (!match) return;
    Severity: Minor
    Found in packages/babel-types/src/definitions/core.js - About 3 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

    Avoid deeply nested control flow statements.
    Open

        } else if (parentKey === "meta") {
          if (is("MetaProperty", parent, { meta: node })) return;
        }
    Severity: Major
    Found in packages/babel-types/src/definitions/core.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

            if (is("ImportSpecifier", parent, { imported: node })) return;
      Severity: Major
      Found in packages/babel-types/src/definitions/core.js - About 45 mins to fix

        Avoid too many return statements within this function.
        Open

              if (is("MetaProperty", parent, { meta: node })) return;
        Severity: Major
        Found in packages/babel-types/src/definitions/core.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                if (is("Property", parent, nonComp)) return;
          Severity: Major
          Found in packages/babel-types/src/definitions/core.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  if (is("ExportSpecifier", parent)) return;
            Severity: Major
            Found in packages/babel-types/src/definitions/core.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                    if (is("Method", parent, nonComp)) return;
              Severity: Major
              Found in packages/babel-types/src/definitions/core.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      if (is("ImportSpecifier", parent, { imported: node })) return;
                Severity: Major
                Found in packages/babel-types/src/definitions/core.js - About 30 mins to fix

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

                      key: {
                        validate: (function () {
                          const normal = assertNodeType(
                            "Identifier",
                            "StringLiteral",
                  Severity: Major
                  Found in packages/babel-types/src/definitions/core.js and 1 other location - About 3 hrs to fix
                  packages/babel-types/src/definitions/core.js on lines 740..762

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

                  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

                      key: {
                        validate: (function () {
                          const normal = assertNodeType(
                            "Identifier",
                            "StringLiteral",
                  Severity: Major
                  Found in packages/babel-types/src/definitions/core.js and 1 other location - About 3 hrs to fix
                  packages/babel-types/src/definitions/core.js on lines 805..827

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

                  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

                  defineType("LabeledStatement", {
                    visitor: ["label", "body"],
                    aliases: ["Statement"],
                    fields: {
                      label: {
                  Severity: Major
                  Found in packages/babel-types/src/definitions/core.js and 3 other locations - About 1 hr to fix
                  packages/babel-types/src/definitions/core.js on lines 1139..1150
                  packages/babel-types/src/definitions/es2015.js on lines 357..368
                  packages/babel-types/src/definitions/jsx.js on lines 122..133

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

                  defineType("WithStatement", {
                    visitor: ["object", "body"],
                    aliases: ["Statement"],
                    fields: {
                      object: {
                  Severity: Major
                  Found in packages/babel-types/src/definitions/core.js and 3 other locations - About 1 hr to fix
                  packages/babel-types/src/definitions/core.js on lines 547..558
                  packages/babel-types/src/definitions/es2015.js on lines 357..368
                  packages/babel-types/src/definitions/jsx.js on lines 122..133

                  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

                  defineType("ObjectExpression", {
                    visitor: ["properties"],
                    aliases: ["Expression"],
                    fields: {
                      properties: {
                  Severity: Major
                  Found in packages/babel-types/src/definitions/core.js and 1 other location - About 1 hr to fix
                  packages/babel-types/src/definitions/experimental.js on lines 314..327

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

                  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

                  defineType("BreakStatement", {
                    visitor: ["label"],
                    fields: {
                      label: {
                        validate: assertNodeType("Identifier"),
                  Severity: Minor
                  Found in packages/babel-types/src/definitions/core.js and 1 other location - About 50 mins to fix
                  packages/babel-types/src/definitions/core.js on lines 233..242

                  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

                  defineType("ContinueStatement", {
                    visitor: ["label"],
                    fields: {
                      label: {
                        validate: assertNodeType("Identifier"),
                  Severity: Minor
                  Found in packages/babel-types/src/definitions/core.js and 1 other location - About 50 mins to fix
                  packages/babel-types/src/definitions/core.js on lines 152..161

                  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

                  defineType("BooleanLiteral", {
                    builder: ["value"],
                    fields: {
                      value: {
                        validate: assertValueType("boolean"),
                  Severity: Minor
                  Found in packages/babel-types/src/definitions/core.js and 2 other locations - About 35 mins to fix
                  packages/babel-types/src/definitions/core.js on lines 560..568
                  packages/babel-types/src/definitions/experimental.js on lines 304..312

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

                  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

                  defineType("StringLiteral", {
                    builder: ["value"],
                    fields: {
                      value: {
                        validate: assertValueType("string"),
                  Severity: Minor
                  Found in packages/babel-types/src/definitions/core.js and 2 other locations - About 35 mins to fix
                  packages/babel-types/src/definitions/core.js on lines 585..593
                  packages/babel-types/src/definitions/experimental.js on lines 304..312

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

                  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

                  defineType("ParenthesizedExpression", {
                    visitor: ["expression"],
                    aliases: ["Expression", "ExpressionWrapper"],
                    fields: {
                      expression: {
                  Severity: Minor
                  Found in packages/babel-types/src/definitions/core.js and 1 other location - About 30 mins to fix
                  packages/babel-types/src/definitions/jsx.js on lines 89..97

                  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

                  There are no issues that match your filters.

                  Category
                  Status