packages/babel-plugin-transform-classes/src/transformClass.js
Function transformClass
has a Cognitive Complexity of 160 (exceeds 5 allowed). Consider refactoring. Open
Open
export default function transformClass(
path: NodePath,
file: any,
builtinClasses: ReadonlySet<string>,
isLoose: boolean,
- Read upRead up
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
Open
export default function transformClass(
path: NodePath,
file: any,
builtinClasses: ReadonlySet<string>,
isLoose: boolean,
File transformClass.js
has 559 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import type { NodePath } from "@babel/traverse";
import nameFunction from "@babel/helper-function-name";
import ReplaceSupers, {
environmentVisitor,
} from "@babel/helper-replace-supers";
Function verifyConstructor
has 86 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function verifyConstructor() {
if (!classState.isDerived) return;
const path = classState.userConstructorPath;
const body = path.get("body");
Function classTransformer
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function classTransformer(
path: NodePath,
file,
builtinClasses: ReadonlySet<string>,
isLoose: boolean,
Function wrapSuperCall
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function wrapSuperCall(bareSuper, superRef, thisRef, body) {
const bareSuperNode = bareSuper.node;
let call;
if (classState.isLoose) {
Function pushBody
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function pushBody() {
const classBodyPaths: Array<Object> = classState.path.get("body.body");
for (const path of classBodyPaths) {
const node = path.node;
Function pushDescriptors
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function pushDescriptors() {
pushInheritsToBody();
const { body } = classState;
Function processMethod
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
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) {
Function maybeCreateConstructor
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function maybeCreateConstructor() {
let hasConstructor = false;
const paths = classState.path.get("body.body");
for (const path of paths) {
hasConstructor = path.equals("kind", "constructor");