Showing 1,982 of 1,982 total issues

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

  prop(superMember) {
    const { property } = superMember.node;
    if (this.memoiser.has(property)) {
      return t.cloneNode(this.memoiser.get(property));
    }
Severity: Major
Found in packages/babel-helper-replace-supers/src/index.js and 1 other location - About 2 hrs to fix
packages/babel-helper-create-class-features-plugin/src/fields.js on lines 189..197

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

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

  receiver(member) {
    const { object } = member.node;

    if (this.memoiser.has(object)) {
      return t.cloneNode(this.memoiser.get(object));
packages/babel-helper-replace-supers/src/index.js on lines 169..176

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

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

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

      } else {
        this.scope.enter(SCOPE_TS_MODULE);
        this.prodParam.enter(PARAM);
        node.body = this.tsParseModuleBlock();
        this.prodParam.exit();
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/typescript/index.js on lines 1317..1323

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

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

Referencer has 21 functions (exceeds 20 allowed). Consider refactoring.
Open

class Referencer extends OriginalReferencer {
  // inherits.
  visitPattern(node, options, callback) {
    if (!node) {
      return;
Severity: Minor
Found in eslint/babel-eslint-parser/src/analyze-scope.js - About 2 hrs to fix

    Function tsParseNonArrayType has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        tsParseNonArrayType(): N.TsType {
          switch (this.state.type) {
            case tt.name:
            case tt._void:
            case tt._null: {
    Severity: Major
    Found in packages/babel-parser/src/plugins/typescript/index.js - About 2 hrs to fix

      Function parseObjectMember has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        parseObjectMember(
          isPattern: boolean,
          refExpressionErrors?: ?ExpressionErrors,
        ): N.ObjectMember | N.SpreadElement | N.RestElement {
          let decorators = [];
      Severity: Major
      Found in packages/babel-parser/src/parser/expression.js - About 2 hrs to fix

        Function CallExpression has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              CallExpression(path) {
                if (!injectCoreJS) return;
        
                const { node } = path;
                const { callee } = node;
        Severity: Major
        Found in packages/babel-plugin-transform-runtime/src/index.js - About 2 hrs to fix

          Function enter has 54 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  enter(path) {
                    if (!injectCoreJS) return;
                    if (!path.isReferenced()) return;
                    // skip transforming `delete something.includes`
                    if (path.parentPath.isUnaryExpression({ operator: "delete" })) return;
          Severity: Major
          Found in packages/babel-plugin-transform-runtime/src/index.js - About 2 hrs to fix

            File xhtml.js has 256 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            // @flow
            
            const entities: { [name: string]: string } = {
              quot: "\u0022",
              amp: "&",
            Severity: Minor
            Found in packages/babel-parser/src/plugins/jsx/xhtml.js - About 2 hrs to fix

              File import-injector.js has 256 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import assert from "assert";
              import * as t from "@babel/types";
              
              import ImportBuilder from "./import-builder";
              import isModule from "./is-module";
              Severity: Minor
              Found in packages/babel-helper-module-imports/src/import-injector.js - About 2 hrs to fix

                Function Class has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      Class(path) {
                        const { node } = path;
                        let comments = [];
                        if (node.typeParameters) {
                          const typeParameters = path.get("typeParameters");
                Severity: Major
                Found in packages/babel-plugin-transform-flow-comments/src/index.js - About 2 hrs to fix

                  Function plainFunction has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function plainFunction(path: NodePath, callId: Object) {
                    const node = path.node;
                    const isDeclaration = path.isFunctionDeclaration();
                    const functionId = node.id;
                    const wrapper = isDeclaration
                  Severity: Major
                  Found in packages/babel-helper-wrap-function/src/index.js - About 2 hrs to fix

                    Function flowParseDeclareExportDeclaration has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        flowParseDeclareExportDeclaration(
                          node: N.FlowDeclareExportDeclaration,
                          insideModule: ?boolean,
                        ): N.FlowDeclareExportDeclaration {
                          this.expect(tt._export);
                    Severity: Major
                    Found in packages/babel-parser/src/plugins/flow.js - About 2 hrs to fix

                      Function enableFeature has 53 lines of code (exceeds 25 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: Major
                      Found in packages/babel-helper-create-class-features-plugin/src/features.js - About 2 hrs to fix

                        Function walk has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          async function walk(filenames: Array<string>): Promise<void> {
                            const _filenames = [];
                        
                            filenames.forEach(function (filename) {
                              if (!fs.existsSync(filename)) return;
                        Severity: Major
                        Found in packages/babel-cli/src/babel/file.js - About 2 hrs to fix

                          Function readConfigJS has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const readConfigJS = makeStrongCache(function* readConfigJS(
                            filepath: string,
                            cache: CacheConfigurator<{
                              envName: string,
                              caller: CallerMetadata | void,
                          Severity: Major
                          Found in packages/babel-core/src/config/files/configuration.js - About 2 hrs to fix

                            Function isPure has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              isPure(node, constantsOnly?: boolean) {
                                if (t.isIdentifier(node)) {
                                  const binding = this.getBinding(node.name);
                                  if (!binding) return false;
                                  if (constantsOnly) return binding.constant;
                            Severity: Major
                            Found in packages/babel-traverse/src/scope/index.js - About 2 hrs to fix

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

                                      if (context[context.length - 1] === ct.j_oTag) {
                                        context.length -= 2;
                                      } else if (context[context.length - 1] === ct.j_expr) {
                                        context.length -= 1;
                                      }
                              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 2661..2665

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

                              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 (context[context.length - 1] === tc.j_oTag) {
                                        context.length -= 2;
                                      } else if (context[context.length - 1] === tc.j_expr) {
                                        context.length -= 1;
                                      }
                              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 2339..2343

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

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

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

                              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

                              Severity
                              Category
                              Status
                              Source
                              Language