Showing 1,982 of 1,982 total issues

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

  declareName(name: string, bindingType: BindingTypes, pos: number) {
    let scope = this.currentScope();
    if (bindingType & BIND_SCOPE_LEXICAL || bindingType & BIND_SCOPE_FUNCTION) {
      this.checkRedeclarationInScope(scope, name, bindingType, pos);

Severity: Minor
Found in packages/babel-parser/src/util/scope.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 skipSpace has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  skipSpace(): void {
    loop: while (this.state.pos < this.length) {
      const ch = this.input.charCodeAt(this.state.pos);
      switch (ch) {
        case charCodes.space:
Severity: Minor
Found in packages/babel-parser/src/tokenizer/index.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 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 parseFunctionBody has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  parseFunctionBody(
    node: N.Function,
    allowExpression: ?boolean,
    isMethod?: boolean = false,
  ): void {
Severity: Minor
Found in packages/babel-parser/src/parser/expression.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 parseBindingList has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  parseBindingList(
    close: TokenType,
    closeCharCode: $Values<typeof charCodes>,
    allowEmpty?: boolean,
    allowModifiers?: boolean,
Severity: Minor
Found in packages/babel-parser/src/parser/lval.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 rewriteLiveReferences has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

export default function rewriteLiveReferences(
  programPath: NodePath,
  metadata: ModuleMetadata,
) {
  const imported = new Map();

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

function dedupDescriptors(
  items: Array<UnloadedDescriptor>,
): Array<UnloadedDescriptor> {
  const map: Map<
    Function,
Severity: Minor
Found in packages/babel-core/src/config/config-chain.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 _printComment has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  _printComment(comment, skipNewLines?: boolean) {
    if (!this.format.shouldPrintComment(comment.value)) return;

    // Some plugins use this to mark comments as removed using the AST-root 'comments' property,
    // where they can't manually mutate the AST node comment lists.
Severity: Minor
Found in packages/babel-generator/src/printer.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 registerDeclaration has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  registerDeclaration(path: NodePath) {
    if (path.isLabeledStatement()) {
      this.registerLabel(path);
    } else if (path.isFunctionDeclaration()) {
      this.registerBinding("hoisted", path.get("id"), path);
Severity: Minor
Found in packages/babel-traverse/src/scope/index.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 exit has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    exit(path) {
      const { node, scope } = path;
      const declar = node.declaration;
      if (t.isClassDeclaration(declar) || t.isFunctionDeclaration(declar)) {
        const id = declar.id;
Severity: Minor
Found in packages/babel-traverse/src/scope/index.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 _call has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

export function _call(fns?: Array<Function>): boolean {
  if (!fns) return false;

  for (const fn of fns) {
    if (!fn) continue;
Severity: Minor
Found in packages/babel-traverse/src/path/context.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 _visitTypeAnnotation has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  _visitTypeAnnotation(node) {
    if (!node) {
      return;
    }
    if (Array.isArray(node)) {
Severity: Minor
Found in eslint/babel-eslint-parser/src/analyze-scope.js - About 1 hr to fix

    Function default has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export default function (
      fixturesLoc: string,
      name: string,
      suiteOpts = {},
      taskOpts = {},
    Severity: Minor
    Found in packages/babel-helper-transform-fixture-test-runner/src/index.js - About 1 hr to fix

      Function parseConditional has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          parseConditional(
            expr: N.Expression,
            noIn: ?boolean,
            startPos: number,
            startLoc: Position,
      Severity: Minor
      Found in packages/babel-parser/src/plugins/flow.js - About 1 hr to fix

        Function parseFunctionBody has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          parseFunctionBody(
            node: N.Function,
            allowExpression: ?boolean,
            isMethod?: boolean = false,
          ): void {
        Severity: Minor
        Found in packages/babel-parser/src/parser/expression.js - About 1 hr to fix

          Function transformFile has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function* transformFile(file: File, pluginPasses: PluginPasses): Handler<void> {
            for (const pluginPairs of pluginPasses) {
              const passPairs = [];
              const passes = [];
              const visitors = [];
          Severity: Minor
          Found in packages/babel-core/src/transformation/index.js - About 1 hr to fix

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

              if (
                hasPlugin(plugins, "pipelineOperator") &&
                !PIPELINE_PROPOSALS.includes(
                  getPluginOption(plugins, "pipelineOperator", "proposal"),
                )
            Severity: Major
            Found in packages/babel-parser/src/plugin-utils.js and 1 other location - About 1 hr to fix
            packages/babel-parser/src/plugin-utils.js on lines 103..113

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

            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 (
                hasPlugin(plugins, "recordAndTuple") &&
                !RECORD_AND_TUPLE_SYNTAX_TYPES.includes(
                  getPluginOption(plugins, "recordAndTuple", "syntaxType"),
                )
            Severity: Major
            Found in packages/babel-parser/src/plugin-utils.js and 1 other location - About 1 hr to fix
            packages/babel-parser/src/plugin-utils.js on lines 77..87

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

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

              interpret(results, allowlist) {
                const summary = {
                  passed: true,
                  allowed: {
                    success: [],
            Severity: Minor
            Found in scripts/parser-tests/utils/parser-test-runner.js - About 1 hr to fix

              Function parseSubscript has 46 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  parseSubscript(
                    base: N.Expression,
                    startPos: number,
                    startLoc: Position,
                    noCalls: ?boolean,
              Severity: Minor
              Found in packages/babel-parser/src/plugins/typescript/index.js - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language