modules/formidable-mini/src/multipart.js
Function write
has a Cognitive Complexity of 112 (exceeds 5 allowed). Consider refactoring. Open
Open
write(data) {
let i = 0;
const length_ = data.length;
let previousIndex = this.index;
let { lookbehind, boundary, boundaryChars, index, state, flags } = this;
- 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 write
has 197 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
write(data) {
let i = 0;
const length_ = data.length;
let previousIndex = this.index;
let { lookbehind, boundary, boundaryChars, index, state, flags } = this;
File multipart.js
has 365 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
/* eslint-disable */
import { FormData } from 'formdata-polyfill/esm.min.js';
import { FormidableFile } from './FormidableFile.js';
Function multipart
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export async function multipart(req, options = {}) {
const ct = req.headers['content-type'];
if (!/multipart/i.test(ct)) {
throw new TypeError('Failed to fetch');
Function multipart
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
Open
export async function multipart(req, options = {}) {
const ct = req.headers['content-type'];
if (!/multipart/i.test(ct)) {
throw new TypeError('Failed to fetch');
- 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
Avoid deeply nested control flow statements. Open
Open
if (c === CR) {
// CR = part boundary
flags |= F.PART_BOUNDARY;
} else if (c === HYPHEN) {
// HYPHEN = end boundary
Avoid deeply nested control flow statements. Open
Open
if (flags & F.LAST_BOUNDARY && c === HYPHEN) {
state = S.END;
flags = 0;
} else if (!(flags & F.LAST_BOUNDARY) && c === LF) {
index = 0;
Avoid deeply nested control flow statements. Open
Open
if (index === 0) {
dataCallback('onPartData', true);
}
Avoid deeply nested control flow statements. Open
Open
} else if (index - 1 === boundary.length) {
if (flags & F.PART_BOUNDARY) {
index = 0;
if (c === LF) {
// unset the PART_BOUNDARY flag
Avoid too many return
statements within this function. Open
Open
return;
Avoid too many return
statements within this function. Open
Open
return;