Showing 1,982 of 1,982 total issues

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

  getBlockParent() {
    let scope = this;
    do {
      if (scope.path.isBlockParent()) {
        return scope;
Severity: Major
Found in packages/babel-traverse/src/scope/index.js and 1 other location - About 1 hr to fix
packages/babel-traverse/src/scope/index.js on lines 911..919

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

      if (isPattern) {
        this.next();
        // Don't use parseRestBinding() as we only allow Identifier here.
        prop.argument = this.parseIdentifier();
        this.checkCommaAfterRest(charCodes.rightCurlyBrace);
Severity: Major
Found in packages/babel-parser/src/parser/expression.js and 1 other location - About 1 hr to fix
packages/babel-parser/src/plugins/jsx/index.js on lines 328..334

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

  getProgramParent() {
    let scope = this;
    do {
      if (scope.path.isProgram()) {
        return scope;
Severity: Major
Found in packages/babel-traverse/src/scope/index.js and 1 other location - About 1 hr to fix
packages/babel-traverse/src/scope/index.js on lines 940..950

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Consider simplifying this complex logical expression.
Open

  } else if (
    prevType.beforeExpr &&
    prevType !== tt.semi &&
    prevType !== tt._else &&
    !(
Severity: Critical
Found in packages/babel-parser/src/tokenizer/context.js - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

      if (
        nodeType === "UserWhitespacable" ||
        "ObjectMethod" === nodeType ||
        "ObjectProperty" === nodeType ||
        "ObjectTypeInternalSlot" === nodeType ||
    Severity: Critical
    Found in packages/babel-types/src/validators/generated/index.js - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

          if (
            // If the current active position is forced, we only want to reactivate
            // the old position if it is different from the newest position.
            (!this._sourcePosition.force ||
              this._sourcePosition.line !== originalLine ||
      Severity: Critical
      Found in packages/babel-generator/src/buffer.js - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

            if (
              (str === "--" && this.endsWith("!")) ||
              // Need spaces for operators of the same kind to avoid: `a+++b`
              (str[0] === "+" && this.endsWith("+")) ||
              (str[0] === "-" && this.endsWith("-")) ||
        Severity: Critical
        Found in packages/babel-generator/src/printer.js - About 1 hr to fix

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

            function buildBrowserInit(
              browserGlobals,
              exactGlobals,
              filename,
              moduleName,
          Severity: Minor
          Found in packages/babel-plugin-transform-modules-umd/src/index.js - About 1 hr to fix

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

                resolveId(importee) {
                  if (importee === "@babel/runtime/regenerator") {
                    return path.join(
                      dirname,
                      "packages",
            Severity: Minor
            Found in scripts/rollup-plugin-babel-source.js - About 1 hr to fix

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

              function translateEnumValues(path, t) {
                const seen: PreviousEnumMembers = Object.create(null);
                // Start at -1 so the first enum member is its increment, 0.
                let prev: number | typeof undefined = -1;
                return path.node.members.map(member => {
              Severity: Minor
              Found in packages/babel-plugin-transform-typescript/src/enum.js - About 1 hr to fix

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

                    isAssignable(node: N.Node, isBinding?: boolean): boolean {
                      switch (node.type) {
                        case "Identifier":
                        case "ObjectPattern":
                        case "ArrayPattern":
                Severity: Minor
                Found in packages/babel-parser/src/plugins/flow.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 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 ForOfStatement|ForInStatement has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        "ForOfStatement|ForInStatement"(path) {
                          const { scope, node } = path;
                          const { left } = node;
                          const { exported, scope: programScope } = this;
                      
                      

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

                          toAssignableList(
                            exprList: Expression[],
                            trailingCommaPos?: ?number,
                          ): $ReadOnlyArray<Pattern> {
                            let end = exprList.length;
                        Severity: Minor
                        Found in packages/babel-parser/src/parser/lval.js - About 1 hr to fix

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

                          export default function removeTypeDuplicates(
                            nodes: Array<Object>,
                          ): Array<Object> {
                            const generics = {};
                            const bases = {};

                            Function _printComment has 33 lines of code (exceeds 25 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

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

                              function assertVersion(range: string | number): void {
                                if (typeof range === "number") {
                                  if (!Number.isInteger(range)) {
                                    throw new Error("Expected string or integer value.");
                                  }
                              Severity: Minor
                              Found in packages/babel-core/src/config/helpers/config-api.js - About 1 hr to fix

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

                                function makeCachedFunction<ArgT, ResultT, SideChannel, Cache: *>(
                                  CallCache: Class<Cache>,
                                  handler: (ArgT, CacheConfigurator<SideChannel>) => Handler<ResultT> | ResultT,
                                ): (ArgT, SideChannel) => Handler<ResultT> {
                                  const callCacheSync = new CallCache();
                                Severity: Minor
                                Found in packages/babel-core/src/config/caching.js - About 1 hr to fix

                                  Function BreakStatement|ContinueStatement|ReturnStatement has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    "BreakStatement|ContinueStatement|ReturnStatement"(path, state) {
                                      const { node, scope } = path;
                                      if (node[this.LOOP_IGNORE]) return;
                                  
                                      let replace;
                                  Severity: Minor
                                  Found in packages/babel-plugin-transform-block-scoping/src/index.js - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language