src/core/index.js

Summary

Maintainability
A
0 mins
Test Coverage

Function handleRequest has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring.
Invalid

let handleRequest = async function (request, clientInfo) {
    if (idleShutdown > 0) {
        lastActive = Date.now();
    };
    // Generate a pre-determinted response if nothing is configured.
Severity: Minor
Found in src/core/index.js - About 1 day 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 handleRequest has 200 lines of code (exceeds 25 allowed). Consider refactoring.
Invalid

let handleRequest = async function (request, clientInfo) {
    if (idleShutdown > 0) {
        lastActive = Date.now();
    };
    // Generate a pre-determinted response if nothing is configured.
Severity: Major
Found in src/core/index.js - About 1 day to fix

    File index.js has 268 lines of code (exceeds 250 allowed). Consider refactoring.
    Invalid

    "use strict";
    
    import {wrapHtml} from "./genHtml.js";
    import {headerSet, headerMap, adaptResp, adaptReqHeaders} from "./header.js";
    import {langMatch} from "./langMatch.js";
    Severity: Minor
    Found in src/core/index.js - About 2 hrs to fix

      Avoid too many return statements within this function.
      Invalid

                  return response;
      Severity: Major
      Found in src/core/index.js - About 30 mins to fix

        Avoid too many return statements within this function.
        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()}`);
        Severity: Major
        Found in src/core/index.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Invalid

                      return await adaptResp(response, false, {set: localHeaders});
          Severity: Major
          Found in src/core/index.js - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status