packages/babel-parser/src/plugins/jsx/index.js

Summary

Maintainability
F
3 days
Test Coverage

File index.js has 481 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// @flow

import * as charCodes from "charcodes";

import XHTMLEntities from "./xhtml";
Severity: Minor
Found in packages/babel-parser/src/plugins/jsx/index.js - About 7 hrs to fix

    Function jsxParseElementAt has 78 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        jsxParseElementAt(startPos: number, startLoc: Position): N.JSXElement {
          const node = this.startNodeAt(startPos, startLoc);
          const children = [];
          const openingElement = this.jsxParseOpeningElementAt(startPos, startLoc);
          let closingElement = null;
    Severity: Major
    Found in packages/babel-parser/src/plugins/jsx/index.js - About 3 hrs to fix

      Function jsxReadToken has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          jsxReadToken(): void {
            let out = "";
            let chunkStart = this.state.pos;
            for (;;) {
              if (this.state.pos >= this.length) {
      Severity: Minor
      Found in packages/babel-parser/src/plugins/jsx/index.js - About 1 hr to fix

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

            jsxReadEntity(): string {
              let str = "";
              let count = 0;
              let entity;
              let ch = this.input[this.state.pos];
        Severity: Minor
        Found in packages/babel-parser/src/plugins/jsx/index.js - About 1 hr to fix

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

              getTokenFromCode(code: number): void {
                if (this.state.inPropertyName) return super.getTokenFromCode(code);
          
                const context = this.curContext();
          
          
          Severity: Minor
          Found in packages/babel-parser/src/plugins/jsx/index.js - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                          if (HEX_NUMBER.test(str)) {
                            entity = String.fromCodePoint(parseInt(str, 16));
                          }
            Severity: Major
            Found in packages/babel-parser/src/plugins/jsx/index.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                            if (DECIMAL_NUMBER.test(str)) {
                              entity = String.fromCodePoint(parseInt(str, 10));
                            }
              Severity: Major
              Found in packages/babel-parser/src/plugins/jsx/index.js - About 45 mins to fix

                Avoid too many return statements within this function.
                Open

                      return super.getTokenFromCode(code);
                Severity: Major
                Found in packages/babel-parser/src/plugins/jsx/index.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                            return this.jsxReadString(code);
                  Severity: Major
                  Found in packages/babel-parser/src/plugins/jsx/index.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return this.finishToken(tt.jsxTagStart);
                    Severity: Major
                    Found in packages/babel-parser/src/plugins/jsx/index.js - About 30 mins to fix

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

                                  if (isNewLine(ch)) {
                                    out += this.input.slice(chunkStart, this.state.pos);
                                    out += this.jsxReadNewLine(true);
                                    chunkStart = this.state.pos;
                                  } else {
                      Severity: Major
                      Found in packages/babel-parser/src/plugins/jsx/index.js and 1 other location - About 2 hrs to fix
                      packages/babel-parser/src/plugins/jsx/index.js on lines 168..174

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

                      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 (isNewLine(ch)) {
                                out += this.input.slice(chunkStart, this.state.pos);
                                out += this.jsxReadNewLine(false);
                                chunkStart = this.state.pos;
                              } else {
                      Severity: Major
                      Found in packages/babel-parser/src/plugins/jsx/index.js and 1 other location - About 2 hrs to fix
                      packages/babel-parser/src/plugins/jsx/index.js on lines 124..130

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

                      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

                          jsxParseSpreadChild(node: N.JSXSpreadChild): N.JSXSpreadChild {
                            this.next(); // ellipsis
                            node.expression = this.parseExpression();
                            this.expect(tt.braceR);
                      
                      
                      Severity: Major
                      Found in packages/babel-parser/src/plugins/jsx/index.js and 1 other location - About 1 hr to fix
                      packages/babel-parser/src/parser/expression.js on lines 1614..1620

                      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

                            if (this.match(tt.braceR)) {
                              node.expression = this.jsxParseEmptyExpression();
                            } else {
                              node.expression = this.parseExpression();
                            }
                      Severity: Major
                      Found in packages/babel-parser/src/plugins/jsx/index.js and 1 other location - About 1 hr to fix
                      packages/babel-parser/src/plugins/flow.js on lines 376..380

                      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

                                  if (str[1] === "x") {
                                    str = str.substr(2);
                                    if (HEX_NUMBER.test(str)) {
                                      entity = String.fromCodePoint(parseInt(str, 16));
                                    }
                      Severity: Minor
                      Found in packages/babel-parser/src/plugins/jsx/index.js and 1 other location - About 55 mins to fix
                      packages/babel-parser/src/plugins/jsx/index.js on lines 196..201

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

                      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 {
                                    str = str.substr(1);
                                    if (DECIMAL_NUMBER.test(str)) {
                                      entity = String.fromCodePoint(parseInt(str, 10));
                                    }
                      Severity: Minor
                      Found in packages/babel-parser/src/plugins/jsx/index.js and 1 other location - About 55 mins to fix
                      packages/babel-parser/src/plugins/jsx/index.js on lines 191..196

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

                      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

                              if (this.state.pos >= this.length) {
                                throw this.raise(this.state.start, JsxErrors.UnterminatedJsxContent);
                              }
                      Severity: Major
                      Found in packages/babel-parser/src/plugins/jsx/index.js and 3 other locations - About 35 mins to fix
                      packages/babel-parser/src/plugins/jsx/index.js on lines 158..160
                      packages/babel-parser/src/tokenizer/index.js on lines 1227..1229
                      packages/babel-parser/src/tokenizer/index.js on lines 1261..1263

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

                              if (this.state.pos >= this.length) {
                                throw this.raise(this.state.start, Errors.UnterminatedString);
                              }
                      Severity: Major
                      Found in packages/babel-parser/src/plugins/jsx/index.js and 3 other locations - About 35 mins to fix
                      packages/babel-parser/src/plugins/jsx/index.js on lines 98..100
                      packages/babel-parser/src/tokenizer/index.js on lines 1227..1229
                      packages/babel-parser/src/tokenizer/index.js on lines 1261..1263

                      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

                            if (this.match(tt.jsxTagEnd)) {
                              this.expect(tt.jsxTagEnd);
                              return this.finishNode(node, "JSXClosingFragment");
                            }
                      Severity: Minor
                      Found in packages/babel-parser/src/plugins/jsx/index.js and 1 other location - About 35 mins to fix
                      packages/babel-parser/src/plugins/jsx/index.js on lines 372..375

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

                      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.match(tt.jsxTagEnd)) {
                              this.expect(tt.jsxTagEnd);
                              return this.finishNode(node, "JSXOpeningFragment");
                            }
                      Severity: Minor
                      Found in packages/babel-parser/src/plugins/jsx/index.js and 1 other location - About 35 mins to fix
                      packages/babel-parser/src/plugins/jsx/index.js on lines 400..403

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

                      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