Showing 1,982 of 1,982 total issues

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

  removeTrailingNewline(): void {
    if (this._queue.length > 0 && this._queue[0][0] === "\n") {
      this._queue.shift();
    }
  }
Severity: Major
Found in packages/babel-generator/src/buffer.js and 1 other location - About 1 hr to fix
packages/babel-generator/src/buffer.js on lines 151..155

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

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

    tsInType<T>(cb: () => T): T {
      const oldInType = this.state.inType;
      this.state.inType = true;
      try {
        return cb();
Severity: Major
Found in packages/babel-parser/src/plugins/typescript/index.js and 1 other location - About 1 hr to fix
packages/babel-parser/src/parser/expression.js on lines 2462..2471

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

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

      if (
        this.hasPlugin("recordAndTuple") &&
        next === charCodes.rightCurlyBrace
      ) {
        if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
Severity: Major
Found in packages/babel-parser/src/tokenizer/index.js and 1 other location - About 1 hr to fix
packages/babel-parser/src/tokenizer/index.js on lines 560..573

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

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

      this.scopeStack[0].lexical.indexOf(id.name) === -1 &&
      this.scopeStack[0].var.indexOf(id.name) === -1 &&
Severity: Major
Found in packages/babel-parser/src/util/scope.js and 1 other location - About 1 hr to fix
packages/babel-parser/src/plugins/typescript/scope.js on lines 99..100

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

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

  SwitchCase(path, state) {
    const oldInSwitchCase = state.inSwitchCase;
    state.inSwitchCase = true;
    path.traverse(loopVisitor, state);
    state.inSwitchCase = oldInSwitchCase;
Severity: Major
Found in packages/babel-plugin-transform-block-scoping/src/index.js and 1 other location - About 1 hr to fix
packages/babel-plugin-transform-block-scoping/src/index.js on lines 275..281

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

Function getReferenceOrigin has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function getReferenceOrigin(
  node,
  scope,
) /*: ?ReferenceOrigin */ {
  if (node.type === "Identifier") {

    Function loadHelper has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function loadHelper(name) {
      if (!helperData[name]) {
        const helper = helpers[name];
        if (!helper) {
          throw Object.assign(new ReferenceError(`Unknown helper ${name}`), {
    Severity: Minor
    Found in packages/babel-helpers/src/index.js - About 1 hr to fix

      Function parseExport has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        parseExport(node: N.Node): N.AnyExport {
          const hasDefault = this.maybeParseExportDefaultSpecifier(node);
          const parseAfterDefault = !hasDefault || this.eat(tt.comma);
          const hasStar = parseAfterDefault && this.eatExportStar(node);
          const hasNamespace =
      Severity: Minor
      Found in packages/babel-parser/src/parser/statement.js - About 1 hr to fix

        Function AssignmentExpression has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              AssignmentExpression(path) {
                const { node, scope } = path;
                if (!t.isPattern(node.left)) return;
        
                const nodes = [];
        Severity: Minor
        Found in packages/babel-plugin-transform-destructuring/src/index.js - About 1 hr to fix

          Function populatePlaceholders has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export default function populatePlaceholders(
            metadata: Metadata,
            replacements: TemplateReplacements,
          ): BabelNodeFile {
            const ast = t.cloneNode(metadata.ast);
          Severity: Minor
          Found in packages/babel-template/src/populate.js - About 1 hr to fix

            Function set has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              set(member, value) {
                const { classRef, privateNamesMap, file } = this;
                const { name } = member.node.property.id;
                const {
                  id,
            Severity: Minor
            Found in packages/babel-helper-create-class-features-plugin/src/fields.js - About 1 hr to fix

              Function print has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                print(node, parent) {
                  if (!node) return;
              
                  const oldConcise = this.format.concise;
                  if (node._compact) {
              Severity: Minor
              Found in packages/babel-generator/src/printer.js - About 1 hr to fix

                Function ArrowFunctionExpression has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function ArrowFunctionExpression(node: Object) {
                  if (node.async) {
                    this.word("async");
                    this.space();
                  }
                Severity: Minor
                Found in packages/babel-generator/src/generators/methods.js - About 1 hr to fix

                  Function save has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function save() {
                    if (isCacheDisabled()) return;
                    let serialised: string = "{}";
                  
                    try {
                  Severity: Minor
                  Found in packages/babel-register/src/cache.js - About 1 hr to fix

                    Function createObjectSpread has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      function createObjectSpread(path, file, objRef) {
                        const props = path.get("properties");
                        const last = props[props.length - 1];
                        t.assertRestElement(last.node);
                        const restElement = t.cloneNode(last.node);
                    Severity: Minor
                    Found in packages/babel-plugin-proposal-object-rest-spread/src/index.js - About 1 hr to fix

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

                                case "number": {
                                  this.flowEnumCheckExplicitTypeMismatch(init.pos, context, "number");
                                  memberNode.init = init.value;
                                  members.numberMembers.push(
                                    this.finishNode(memberNode, "EnumNumberMember"),
                      Severity: Major
                      Found in packages/babel-parser/src/plugins/flow.js and 2 other locations - About 1 hr to fix
                      packages/babel-parser/src/plugins/flow.js on lines 3249..3260
                      packages/babel-parser/src/plugins/flow.js on lines 3269..3276

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

                                case "boolean": {
                                  this.flowEnumCheckExplicitTypeMismatch(
                                    init.pos,
                                    context,
                                    "boolean",
                      Severity: Major
                      Found in packages/babel-parser/src/plugins/flow.js and 2 other locations - About 1 hr to fix
                      packages/babel-parser/src/plugins/flow.js on lines 3261..3268
                      packages/babel-parser/src/plugins/flow.js on lines 3269..3276

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

                                case "string": {
                                  this.flowEnumCheckExplicitTypeMismatch(init.pos, context, "string");
                                  memberNode.init = init.value;
                                  members.stringMembers.push(
                                    this.finishNode(memberNode, "EnumStringMember"),
                      Severity: Major
                      Found in packages/babel-parser/src/plugins/flow.js and 2 other locations - About 1 hr to fix
                      packages/babel-parser/src/plugins/flow.js on lines 3249..3260
                      packages/babel-parser/src/plugins/flow.js on lines 3261..3268

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

                      function addIsHelper(type, aliasKeys, deprecated) {
                        const targetType = JSON.stringify(type);
                        let aliasSource = "";
                        if (aliasKeys) {
                          aliasSource = " || " + joinComparisons(aliasKeys, "nodeType");
                      Severity: Minor
                      Found in packages/babel-types/scripts/generators/generateValidators.js - About 1 hr to fix

                        Function pushDescriptors has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          function pushDescriptors() {
                            pushInheritsToBody();
                        
                            const { body } = classState;
                        
                        
                        Severity: Minor
                        Found in packages/babel-plugin-transform-classes/src/transformClass.js - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language