src/core/index.js
Function handleRequest
has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring. Invalid
Invalid
let handleRequest = async function (request, clientInfo) {
if (idleShutdown > 0) {
lastActive = Date.now();
};
// Generate a pre-determinted response if nothing is configured.
- 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 handleRequest
has 200 lines of code (exceeds 25 allowed). Consider refactoring. Invalid
Invalid
let handleRequest = async function (request, clientInfo) {
if (idleShutdown > 0) {
lastActive = Date.now();
};
// Generate a pre-determinted response if nothing is configured.
File index.js
has 268 lines of code (exceeds 250 allowed). Consider refactoring. Invalid
Invalid
"use strict";
import {wrapHtml} from "./genHtml.js";
import {headerSet, headerMap, adaptResp, adaptReqHeaders} from "./header.js";
import {langMatch} from "./langMatch.js";
Avoid too many return
statements within this function. Invalid
Invalid
return response;
Avoid too many return
statements within this function. Invalid
Invalid
return await adaptResp(response, false, {strip: headerStripDown, set: localHeaders}) || wrapHtml(500, "Empty response", `${keepGoing ? "Successful" : "Failed"} empty response from trace: ${backTrace}.<br/>Last requested URL: ${reqUrl.toString()}`);
Avoid too many return
statements within this function. Invalid
Invalid
return await adaptResp(response, false, {set: localHeaders});