Showing 1,982 of 1,982 total issues

Function parseImportSpecifier has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    parseImportSpecifier(node: N.ImportDeclaration): void {
      const specifier = this.startNode();
      const firstIdentLoc = this.state.start;
      const firstIdent = this.parseIdentifier(true);

Severity: Major
Found in packages/babel-parser/src/plugins/flow.js - About 2 hrs to fix

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

        typeCastToParameter(node: N.TsTypeCastExpression): N.Node {
          node.expression.typeAnnotation = node.typeAnnotation;
    
          this.resetEndLocation(
            node.expression,
    Severity: Major
    Found in packages/babel-parser/src/plugins/typescript/index.js and 1 other location - About 2 hrs to fix
    packages/babel-parser/src/plugins/flow.js on lines 1656..1666

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

    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

        typeCastToParameter(node: N.Node): N.Node {
          node.expression.typeAnnotation = node.typeAnnotation;
    
          this.resetEndLocation(
            node.expression,
    Severity: Major
    Found in packages/babel-parser/src/plugins/flow.js and 1 other location - About 2 hrs to fix
    packages/babel-parser/src/plugins/typescript/index.js on lines 2604..2614

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

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

    function placeholderVisitorHandler(
      node: BabelNode,
      ancestors: TraversalAncestors,
      state: MetadataState,
    ) {
    Severity: Major
    Found in packages/babel-template/src/parse.js - About 2 hrs to fix

      Function readEscapedChar has 70 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        readEscapedChar(inTemplate: boolean): string | null {
          const throwOnInvalid = !inTemplate;
          const ch = this.input.charCodeAt(++this.state.pos);
          ++this.state.pos;
          switch (ch) {
      Severity: Major
      Found in packages/babel-parser/src/tokenizer/index.js - About 2 hrs to fix

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

          Object: {
            assign: "es6.object.assign",
            create: "es6.object.create",
            defineProperty: "es6.object.define-property",
            defineProperties: "es6.object.define-properties",
        packages/babel-preset-env/src/polyfills/corejs2/built-in-definitions.js on lines 133..151

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

        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

          Math: {
            acosh: "es6.math.acosh",
            asinh: "es6.math.asinh",
            atanh: "es6.math.atanh",
            cbrt: "es6.math.cbrt",
        packages/babel-preset-env/src/polyfills/corejs2/built-in-definitions.js on lines 113..131

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

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

        function convertTemplateType(tokens) {
          let curlyBrace = null;
          let templateTokens = [];
          const result = [];
        
        
        Severity: Major
        Found in eslint/babel-eslint-parser/src/convert/convertTokens.js - About 2 hrs to fix

          Function readInt has 69 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            readInt(
              radix: number,
              len?: number,
              forceLen?: boolean,
              allowNumSeparator: boolean = true,
          Severity: Major
          Found in packages/babel-parser/src/tokenizer/index.js - About 2 hrs to fix

            Function parseExprOp has 69 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              parseExprOp(
                left: N.Expression,
                leftStartPos: number,
                leftStartLoc: Position,
                minPrec: number,
            Severity: Major
            Found in packages/babel-parser/src/parser/expression.js - About 2 hrs to fix

              Function getReferenceOrigin has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

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

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

                adjustCommentsAfterTrailingComma(
                  node: Node,
                  elements: (Node | null)[],
                  // When the current node is followed by a token which hasn't a respective AST node, we
                  // need to take all the trailing comments to prevent them from being attached to an
              Severity: Minor
              Found in packages/babel-parser/src/parser/comments.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 enableFeature has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

              export function enableFeature(file, feature, loose) {
                // We can't blindly enable the feature because, if it was already set,
                // "loose" can't be changed, so that
                //   @babel/plugin-class-properties { loose: true }
                //   @babel/plugin-class-properties { loose: false }
              Severity: Minor
              Found in packages/babel-helper-create-class-features-plugin/src/features.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 getMarkerLines has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

              function getMarkerLines(
                loc: NodeLocation,
                source: Array<string>,
                opts: Object,
              ): { start: number, end: number, markerLines: Object } {
              Severity: Minor
              Found in packages/babel-code-frame/src/index.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 codeFrameColumns has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

              export function codeFrameColumns(
                rawLines: string,
                loc: NodeLocation,
                opts: Object = {},
              ): string {
              Severity: Minor
              Found in packages/babel-code-frame/src/index.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 generateCode has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

              export default function generateCode(
                pluginPasses: PluginPasses,
                file: File,
              ): {
                outputCode: string,
              Severity: Minor
              Found in packages/babel-core/src/transformation/file/generate.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

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

              export function assertRootMode(loc: OptionPath, value: mixed): RootMode | void {
                if (
                  value !== undefined &&
                  value !== "root" &&
                  value !== "upward" &&
              packages/babel-core/src/config/validation/option-assertions.js on lines 105..120

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

              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

              export function assertSourceType(
                loc: OptionPath,
                value: mixed,
              ): SourceTypeOption | void {
                if (
              packages/babel-core/src/config/validation/option-assertions.js on lines 64..76

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

              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

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

              import assert from "assert";
              import * as t from "@babel/types";
              import template from "@babel/template";
              import chunk from "lodash/chunk";
              
              
              Severity: Minor
              Found in packages/babel-helper-module-transforms/src/index.js - About 2 hrs to fix

                Function output has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  async output(summary) {
                    const goodnews = [
                      summary.allowed.success.length + " valid programs parsed without error",
                      summary.allowed.failure.length +
                        " invalid programs produced a parsing error",
                Severity: Major
                Found in scripts/parser-tests/utils/parser-test-runner.js - About 2 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language