packages/babel-parser/src/parser/statement.js

Summary

Maintainability
F
2 wks
Test Coverage

File statement.js has 1765 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// @flow

import * as N from "../types";
import { types as tt, type TokenType } from "../tokenizer/types";
import ExpressionParser from "./expression";
Severity: Major
Found in packages/babel-parser/src/parser/statement.js - About 4 days to fix

    StatementParser has 86 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class StatementParser extends ExpressionParser {
      // ### Statement parsing
    
      // Parse a program. Initializes the parser, reads any number of
      // statements, and wraps them in a Program node.  Optionally takes a
    Severity: Major
    Found in packages/babel-parser/src/parser/statement.js - About 1 day to fix

      Function parseStatementContent has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
      Open

        parseStatementContent(context: ?string, topLevel: ?boolean): N.Statement {
          let starttype = this.state.type;
          const node = this.startNode();
          let kind;
      
      
      Severity: Minor
      Found in packages/babel-parser/src/parser/statement.js - About 6 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 parseClassMemberWithIsStatic has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
      Open

        parseClassMemberWithIsStatic(
          classBody: N.ClassBody,
          member: N.ClassMember,
          state: { hadConstructor: boolean },
          isStatic: boolean,
      Severity: Minor
      Found in packages/babel-parser/src/parser/statement.js - About 6 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 checkExport has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

        checkExport(
          node: N.ExportNamedDeclaration,
          checkNames?: boolean,
          isDefault?: boolean,
          isFrom?: boolean,
      Severity: Minor
      Found in packages/babel-parser/src/parser/statement.js - About 5 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 parseClassMemberWithIsStatic has 126 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        parseClassMemberWithIsStatic(
          classBody: N.ClassBody,
          member: N.ClassMember,
          state: { hadConstructor: boolean },
          isStatic: boolean,
      Severity: Major
      Found in packages/babel-parser/src/parser/statement.js - About 5 hrs to fix

        Function parseStatementContent has 116 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          parseStatementContent(context: ?string, topLevel: ?boolean): N.Statement {
            let starttype = this.state.type;
            const node = this.startNode();
            let kind;
        
        
        Severity: Major
        Found in packages/babel-parser/src/parser/statement.js - About 4 hrs to fix

          Function parseSwitchStatement has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

            parseSwitchStatement(node: N.SwitchStatement): N.SwitchStatement {
              this.next();
              node.discriminant = this.parseHeaderExpression();
              const cases = (node.cases = []);
              this.expect(tt.braceL);
          Severity: Minor
          Found in packages/babel-parser/src/parser/statement.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 parseForStatement has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

            parseForStatement(node: N.Node): N.ForLike {
              this.next();
              this.state.labels.push(loopLabel);
          
              let awaitAt = -1;
          Severity: Minor
          Found in packages/babel-parser/src/parser/statement.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 parseVar has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            parseVar(
              node: N.VariableDeclaration,
              isFor: boolean,
              kind: "var" | "let" | "const",
            ): N.VariableDeclaration {
          Severity: Minor
          Found in packages/babel-parser/src/parser/statement.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 checkDeclaration has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            checkDeclaration(node: N.Pattern | N.ObjectProperty): void {
              if (node.type === "Identifier") {
                this.checkDuplicateExports(node, node.name);
              } else if (node.type === "ObjectPattern") {
                for (const prop of node.properties) {
          Severity: Minor
          Found in packages/babel-parser/src/parser/statement.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 checkExport has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            checkExport(
              node: N.ExportNamedDeclaration,
              checkNames?: boolean,
              isDefault?: boolean,
              isFrom?: boolean,
          Severity: Major
          Found in packages/babel-parser/src/parser/statement.js - About 2 hrs to fix

            Function parseForStatement has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              parseForStatement(node: N.Node): N.ForLike {
                this.next();
                this.state.labels.push(loopLabel);
            
                let awaitAt = -1;
            Severity: Minor
            Found in packages/babel-parser/src/parser/statement.js - About 1 hr to fix

              Function isExportDefaultSpecifier has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                isExportDefaultSpecifier(): boolean {
                  if (this.match(tt.name)) {
                    const value = this.state.value;
                    if (value === "async" || value === "let") {
                      return false;
              Severity: Minor
              Found in packages/babel-parser/src/parser/statement.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 parseExport has a Cognitive Complexity of 14 (exceeds 5 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

              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 verifyBreakContinue has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                verifyBreakContinue(
                  node: N.BreakStatement | N.ContinueStatement,
                  keyword: string,
                ) {
                  const isBreak = keyword === "break";
              Severity: Minor
              Found in packages/babel-parser/src/parser/statement.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 parseClassBody has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                parseClassBody(
                  constructorAllowsSuper: boolean,
                  oldStrict?: boolean,
                ): N.ClassBody {
                  this.classScope.enter();
              Severity: Minor
              Found in packages/babel-parser/src/parser/statement.js - About 1 hr to fix

                Function parseSwitchStatement has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  parseSwitchStatement(node: N.SwitchStatement): N.SwitchStatement {
                    this.next();
                    node.discriminant = this.parseHeaderExpression();
                    const cases = (node.cases = []);
                    this.expect(tt.braceL);
                Severity: Minor
                Found in packages/babel-parser/src/parser/statement.js - About 1 hr to fix

                  Function parseLabeledStatement has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                    parseLabeledStatement(
                      node: N.LabeledStatement,
                      maybeName: string,
                      expr: N.Identifier,
                      context: ?string,
                  Severity: Minor
                  Found in packages/babel-parser/src/parser/statement.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 parseBlockOrModuleBlockBody has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                    parseBlockOrModuleBlockBody(
                      body: N.Statement[],
                      directives: ?(N.Directive[]),
                      topLevel: boolean,
                      end: TokenType,
                  Severity: Minor
                  Found in packages/babel-parser/src/parser/statement.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 isExportDefaultSpecifier has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    isExportDefaultSpecifier(): boolean {
                      if (this.match(tt.name)) {
                        const value = this.state.value;
                        if (value === "async" || value === "let") {
                          return false;
                  Severity: Minor
                  Found in packages/babel-parser/src/parser/statement.js - About 1 hr to fix

                    Function maybeParseModuleAttributes has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      maybeParseModuleAttributes() {
                        if (this.match(tt._with) && !this.hasPrecedingLineBreak()) {
                          this.expectPlugin("moduleAttributes");
                          this.next();
                        } else {
                    Severity: Minor
                    Found in packages/babel-parser/src/parser/statement.js - About 1 hr to fix

                      Function parseFunction has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        parseFunction<T: N.NormalFunction>(
                          node: T,
                          statement?: number = FUNC_NO_FLAGS,
                          isAsync?: boolean = false,
                        ): T {
                      Severity: Minor
                      Found in packages/babel-parser/src/parser/statement.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 parseExportDefaultExpression has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                            parseExportDefaultExpression(): N.Expression | N.Declaration {
                              const expr = this.startNode();
                          
                              const isAsync = this.isAsyncFunction();
                          
                          
                          Severity: Minor
                          Found in packages/babel-parser/src/parser/statement.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 parseLabeledStatement has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            parseLabeledStatement(
                              node: N.LabeledStatement,
                              maybeName: string,
                              expr: N.Identifier,
                              context: ?string,
                          Severity: Minor
                          Found in packages/babel-parser/src/parser/statement.js - About 1 hr to fix

                            Function parseBlockOrModuleBlockBody has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              parseBlockOrModuleBlockBody(
                                body: N.Statement[],
                                directives: ?(N.Directive[]),
                                topLevel: boolean,
                                end: TokenType,
                            Severity: Minor
                            Found in packages/babel-parser/src/parser/statement.js - About 1 hr to fix

                              Function parseForIn has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                parseForIn(
                                  node: N.ForInOf,
                                  init: N.VariableDeclaration | N.AssignmentPattern,
                                  awaitAt: number,
                                ): N.ForInOf {
                              Severity: Minor
                              Found in packages/babel-parser/src/parser/statement.js - About 1 hr to fix

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

                                  parseVar(
                                    node: N.VariableDeclaration,
                                    isFor: boolean,
                                    kind: "var" | "let" | "const",
                                  ): N.VariableDeclaration {
                                Severity: Minor
                                Found in packages/babel-parser/src/parser/statement.js - About 1 hr to fix

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

                                    parseForIn(
                                      node: N.ForInOf,
                                      init: N.VariableDeclaration | N.AssignmentPattern,
                                      awaitAt: number,
                                    ): N.ForInOf {
                                  Severity: Minor
                                  Found in packages/babel-parser/src/parser/statement.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 maybeParseModuleAttributes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                    maybeParseModuleAttributes() {
                                      if (this.match(tt._with) && !this.hasPrecedingLineBreak()) {
                                        this.expectPlugin("moduleAttributes");
                                        this.next();
                                      } else {
                                  Severity: Minor
                                  Found in packages/babel-parser/src/parser/statement.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 parseExportDefaultExpression has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    parseExportDefaultExpression(): N.Expression | N.Declaration {
                                      const expr = this.startNode();
                                  
                                      const isAsync = this.isAsyncFunction();
                                  
                                  
                                  Severity: Minor
                                  Found in packages/babel-parser/src/parser/statement.js - About 1 hr to fix

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

                                      parseTryStatement(node: N.TryStatement): N.TryStatement {
                                        this.next();
                                    
                                        node.block = this.parseBlock();
                                        node.handler = null;
                                    Severity: Minor
                                    Found in packages/babel-parser/src/parser/statement.js - About 1 hr to fix

                                      Function parseTryStatement has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                        parseTryStatement(node: N.TryStatement): N.TryStatement {
                                          this.next();
                                      
                                          node.block = this.parseBlock();
                                          node.handler = null;
                                      Severity: Minor
                                      Found in packages/babel-parser/src/parser/statement.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 parseNamedImportSpecifiers has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                        parseNamedImportSpecifiers(node: N.ImportDeclaration) {
                                          let first = true;
                                          this.expect(tt.braceL);
                                          while (!this.eat(tt.braceR)) {
                                            if (first) {
                                      Severity: Minor
                                      Found in packages/babel-parser/src/parser/statement.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 parseClassMemberFromModifier has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                        parseClassMemberFromModifier(
                                          classBody: N.ClassBody,
                                          member: N.ClassMember,
                                        ): boolean {
                                          const containsEsc = this.state.containsEsc;
                                      Severity: Minor
                                      Found in packages/babel-parser/src/parser/statement.js - About 1 hr to fix

                                        Function parseDecorator has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                          parseDecorator(): N.Decorator {
                                            this.expectOnePlugin(["decorators-legacy", "decorators"]);
                                        
                                            const node = this.startNode();
                                            this.next();
                                        Severity: Minor
                                        Found in packages/babel-parser/src/parser/statement.js - About 1 hr to fix

                                          Consider simplifying this complex logical expression.
                                          Open

                                              if (
                                                (hasDefault && parseAfterDefault && !hasStar && !hasSpecifiers) ||
                                                (hasNamespace && parseAfterNamespace && !hasSpecifiers)
                                              ) {
                                                throw this.unexpected(null, tt.braceL);
                                          Severity: Major
                                          Found in packages/babel-parser/src/parser/statement.js - About 1 hr to fix

                                            Consider simplifying this complex logical expression.
                                            Open

                                                      if (
                                                        (result.type === "ExportNamedDeclaration" &&
                                                          (!result.exportKind || result.exportKind === "value")) ||
                                                        (result.type === "ExportAllDeclaration" &&
                                                          (!result.exportKind || result.exportKind === "value")) ||
                                            Severity: Major
                                            Found in packages/babel-parser/src/parser/statement.js - About 1 hr to fix

                                              Function parseExportSpecifiers has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                                parseExportSpecifiers(): Array<N.ExportSpecifier> {
                                                  const nodes = [];
                                                  let first = true;
                                              
                                                  // export { x, y as z } [from '...']
                                              Severity: Minor
                                              Found in packages/babel-parser/src/parser/statement.js - About 55 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

                                              Function isLet has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                                isLet(context: ?string): boolean {
                                                  if (!this.isContextual("let")) {
                                                    return false;
                                                  }
                                                  const next = this.nextTokenStart();
                                              Severity: Minor
                                              Found in packages/babel-parser/src/parser/statement.js - About 55 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

                                              Avoid deeply nested control flow statements.
                                              Open

                                                      if (
                                                        node.declaration.type === "FunctionDeclaration" ||
                                                        node.declaration.type === "ClassDeclaration"
                                                      ) {
                                                        const id = node.declaration.id;
                                              Severity: Major
                                              Found in packages/babel-parser/src/parser/statement.js - About 45 mins to fix

                                                Avoid deeply nested control flow statements.
                                                Open

                                                    } else if (this.isLineTerminator()) {
                                                      // an uninitialized class property (due to ASI, since we don't otherwise recognize the next token)
                                                      if (isPrivate) {
                                                        this.pushClassPrivateProperty(classBody, privateProp);
                                                      } else {
                                                Severity: Major
                                                Found in packages/babel-parser/src/parser/statement.js - About 45 mins to fix

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

                                                    pushClassPrivateMethod(
                                                      classBody: N.ClassBody,
                                                      method: N.ClassPrivateMethod,
                                                      isGenerator: boolean,
                                                      isAsync: boolean,
                                                  Severity: Minor
                                                  Found in packages/babel-parser/src/parser/statement.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

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

                                                    parseDecorator(): N.Decorator {
                                                      this.expectOnePlugin(["decorators-legacy", "decorators"]);
                                                  
                                                      const node = this.startNode();
                                                      this.next();
                                                  Severity: Minor
                                                  Found in packages/babel-parser/src/parser/statement.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

                                                  Avoid deeply nested control flow statements.
                                                  Open

                                                        if (method.key.type === "PrivateName") {
                                                          // private getter/setter
                                                          this.pushClassPrivateMethod(classBody, privateMethod, false, false);
                                                        } else {
                                                          if (this.isNonstaticConstructor(publicMethod)) {
                                                  Severity: Major
                                                  Found in packages/babel-parser/src/parser/statement.js - About 45 mins to fix

                                                    Avoid deeply nested control flow statements.
                                                    Open

                                                            if (this.isNonstaticConstructor(publicMethod)) {
                                                              this.raise(publicMethod.key.start, Errors.ConstructorIsAsync);
                                                            }
                                                    Severity: Major
                                                    Found in packages/babel-parser/src/parser/statement.js - About 45 mins to fix

                                                      Avoid deeply nested control flow statements.
                                                      Open

                                                                if (!isFrom && specifier.local) {
                                                                  // check for keywords used as local names
                                                                  this.checkReservedWord(
                                                                    specifier.local.name,
                                                                    specifier.local.start,
                                                      Severity: Major
                                                      Found in packages/babel-parser/src/parser/statement.js - About 45 mins to fix

                                                        Consider simplifying this complex logical expression.
                                                        Open

                                                            } else if (
                                                              isSimple &&
                                                              (key.name === "get" || key.name === "set") &&
                                                              !containsEsc &&
                                                              !(this.match(tt.star) && this.isLineTerminator())
                                                        Severity: Major
                                                        Found in packages/babel-parser/src/parser/statement.js - About 40 mins to fix

                                                          Consider simplifying this complex logical expression.
                                                          Open

                                                              if (
                                                                init.type === "VariableDeclaration" &&
                                                                init.declarations[0].init != null &&
                                                                (!isForIn ||
                                                                  this.state.strict ||
                                                          Severity: Major
                                                          Found in packages/babel-parser/src/parser/statement.js - About 40 mins to fix

                                                            Function parseDecorators has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                            Open

                                                              parseDecorators(allowExport?: boolean): void {
                                                                const currentContextDecorators = this.state.decoratorStack[
                                                                  this.state.decoratorStack.length - 1
                                                                ];
                                                                while (this.match(tt.at)) {
                                                            Severity: Minor
                                                            Found in packages/babel-parser/src/parser/statement.js - About 35 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

                                                            Function parseClassId has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                            Open

                                                              parseClassId(
                                                                node: N.Class,
                                                                isStatement: boolean,
                                                                optionalId: ?boolean,
                                                                bindingType: BindingTypes = BIND_CLASS,
                                                            Severity: Minor
                                                            Found in packages/babel-parser/src/parser/statement.js - About 35 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

                                                            Function shouldParseExportDeclaration has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                            Open

                                                              shouldParseExportDeclaration(): boolean {
                                                                if (this.match(tt.at)) {
                                                                  this.expectOnePlugin(["decorators", "decorators-legacy"]);
                                                                  if (this.hasPlugin("decorators")) {
                                                                    if (this.getPluginOption("decorators", "decoratorsBeforeExport")) {
                                                            Severity: Minor
                                                            Found in packages/babel-parser/src/parser/statement.js - About 35 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

                                                            Avoid too many return statements within this function.
                                                            Open

                                                                      return this.parseFunctionStatement(node, true, !context);
                                                            Severity: Major
                                                            Found in packages/babel-parser/src/parser/statement.js - About 30 mins to fix

                                                              Avoid too many return statements within this function.
                                                              Open

                                                                    return this.parseExpressionStatement(node, expr);
                                                              Severity: Major
                                                              Found in packages/babel-parser/src/parser/statement.js - About 30 mins to fix

                                                                Avoid too many return statements within this function.
                                                                Open

                                                                      if (!keywordRelationalOperator.test(ident)) return true;
                                                                Severity: Major
                                                                Found in packages/babel-parser/src/parser/statement.js - About 30 mins to fix

                                                                  Avoid too many return statements within this function.
                                                                  Open

                                                                      return false;
                                                                  Severity: Major
                                                                  Found in packages/babel-parser/src/parser/statement.js - About 30 mins to fix

                                                                    Avoid too many return statements within this function.
                                                                    Open

                                                                          return this.parseLabeledStatement(node, maybeName, expr, context);
                                                                    Severity: Major
                                                                    Found in packages/babel-parser/src/parser/statement.js - About 30 mins to fix

                                                                      Avoid too many return statements within this function.
                                                                      Open

                                                                          return false;
                                                                      Severity: Major
                                                                      Found in packages/babel-parser/src/parser/statement.js - About 30 mins to fix

                                                                        Avoid too many return statements within this function.
                                                                        Open

                                                                              return (
                                                                                nextAfterFrom === charCodes.quotationMark ||
                                                                                nextAfterFrom === charCodes.apostrophe
                                                                              );
                                                                        Severity: Major
                                                                        Found in packages/babel-parser/src/parser/statement.js - About 30 mins to fix

                                                                          Avoid too many return statements within this function.
                                                                          Open

                                                                              return this.parseFor(node, init);
                                                                          Severity: Major
                                                                          Found in packages/babel-parser/src/parser/statement.js - About 30 mins to fix

                                                                            Function maybeParseExportDeclaration has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                            Open

                                                                              maybeParseExportDeclaration(node: N.Node): boolean {
                                                                                if (this.shouldParseExportDeclaration()) {
                                                                                  if (this.isContextual("async")) {
                                                                                    const next = this.nextTokenStart();
                                                                            
                                                                            
                                                                            Severity: Minor
                                                                            Found in packages/babel-parser/src/parser/statement.js - About 25 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

                                                                            There are no issues that match your filters.

                                                                            Category
                                                                            Status