lib/mini-tools.js
Function readConfig
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
Open
async function readConfig(listOfFileNamesOrConfigObjects, opts = {}) {
let listOfConfig = await Promise.all(listOfFileNamesOrConfigObjects.map(async function (fileNameOrObject) {
let result;
if (typeof fileNameOrObject === "string") {
let ext = Path.extname(fileNameOrObject);
- 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 serveTransforming
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function serveTransforming(pathToFile, anyFileOrOptions, extOriginal, extTarget, renderizer, textType) {
let regExpExtDetect;
let regExpExtReplace;
let anyFile;
var renderOptions = null;
File mini-tools.js
has 265 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.readConfig = exports.serveYaml = exports.serveJson = exports.serveJade = exports.serveStylus = exports.getTraceroute = exports.escapeRegExp = exports.serveFile = exports.serveText = exports.serveImage = exports.serveBuffer = exports.preEval = exports.serveErr = exports.globalOpts = void 0;
const Path = require("path");
const url = require("url");
Function readConfig
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function readConfig(listOfFileNamesOrConfigObjects, opts = {}) {
let listOfConfig = await Promise.all(listOfFileNamesOrConfigObjects.map(async function (fileNameOrObject) {
let result;
if (typeof fileNameOrObject === "string") {
let ext = Path.extname(fileNameOrObject);
Function listOfConfig
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
let listOfConfig = await Promise.all(listOfFileNamesOrConfigObjects.map(async function (fileNameOrObject) {
let result;
if (typeof fileNameOrObject === "string") {
let ext = Path.extname(fileNameOrObject);
let exts;
Function unchainedFunction
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function unchainedFunction() {
try {
let pathname = ('path' in req /*never*/ ? req.path : url.parse(req.url).pathname);
/* istanbul ignore next */
if (traceRoute) {
Function serveErr
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function serveErr(_req, res, next) {
return async function (err) {
if (err.message === 'next') {
return next();
}
Function serveTransforming
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
function serveTransforming(pathToFile, anyFileOrOptions, extOriginal, extTarget, renderizer, textType) {
let regExpExtDetect;
let regExpExtReplace;
let anyFile;
var renderOptions = null;
- 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 serveTransforming
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function serveTransforming(pathToFile, anyFileOrOptions, extOriginal, extTarget, renderizer, textType) {
TODO found Open
Open
// TODO: algún día esto no va a ser necesario porque van a implementar los arreglos compactos!
- Exclude checks