packages/babel-plugin-transform-classes/src/transformClass.js

Summary

Maintainability
F
1 wk
Test Coverage

Function transformClass has a Cognitive Complexity of 160 (exceeds 5 allowed). Consider refactoring.
Open

export default function transformClass(
  path: NodePath,
  file: any,
  builtinClasses: ReadonlySet<string>,
  isLoose: boolean,
Severity: Minor
Found in packages/babel-plugin-transform-classes/src/transformClass.js - About 3 days 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 transformClass has 532 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function transformClass(
  path: NodePath,
  file: any,
  builtinClasses: ReadonlySet<string>,
  isLoose: boolean,
Severity: Major
Found in packages/babel-plugin-transform-classes/src/transformClass.js - About 2 days to fix

    File transformClass.js has 559 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import type { NodePath } from "@babel/traverse";
    import nameFunction from "@babel/helper-function-name";
    import ReplaceSupers, {
      environmentVisitor,
    } from "@babel/helper-replace-supers";
    Severity: Major
    Found in packages/babel-plugin-transform-classes/src/transformClass.js - About 1 day to fix

      Function verifyConstructor has 86 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function verifyConstructor() {
          if (!classState.isDerived) return;
      
          const path = classState.userConstructorPath;
          const body = path.get("body");
      Severity: Major
      Found in packages/babel-plugin-transform-classes/src/transformClass.js - About 3 hrs to fix

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

          function classTransformer(
            path: NodePath,
            file,
            builtinClasses: ReadonlySet<string>,
            isLoose: boolean,
        Severity: Major
        Found in packages/babel-plugin-transform-classes/src/transformClass.js - About 2 hrs to fix

          Function wrapSuperCall has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function wrapSuperCall(bareSuper, superRef, thisRef, body) {
              const bareSuperNode = bareSuper.node;
              let call;
          
              if (classState.isLoose) {
          Severity: Minor
          Found in packages/babel-plugin-transform-classes/src/transformClass.js - About 1 hr to fix

            Function pushBody has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              function pushBody() {
                const classBodyPaths: Array<Object> = classState.path.get("body.body");
            
                for (const path of classBodyPaths) {
                  const node = path.node;
            Severity: Minor
            Found in packages/babel-plugin-transform-classes/src/transformClass.js - About 1 hr to fix

              Function pushDescriptors has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                function pushDescriptors() {
                  pushInheritsToBody();
              
                  const { body } = classState;
              
              
              Severity: Minor
              Found in packages/babel-plugin-transform-classes/src/transformClass.js - About 1 hr to fix

                Function processMethod has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  function processMethod(node, scope) {
                    if (classState.isLoose && !node.decorators) {
                      // use assignments instead of define properties for loose classes
                      let { classRef } = classState;
                      if (!node.static) {
                Severity: Minor
                Found in packages/babel-plugin-transform-classes/src/transformClass.js - About 1 hr to fix

                  Function maybeCreateConstructor has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    function maybeCreateConstructor() {
                      let hasConstructor = false;
                      const paths = classState.path.get("body.body");
                      for (const path of paths) {
                        hasConstructor = path.equals("kind", "constructor");
                  Severity: Minor
                  Found in packages/babel-plugin-transform-classes/src/transformClass.js - About 1 hr to fix

                    There are no issues that match your filters.

                    Category
                    Status