codenautas/mini-tools

View on GitHub
lib/mini-tools.js

Summary

Maintainability
D
2 days
Test Coverage

Function readConfig has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
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);
Severity: Minor
Found in lib/mini-tools.js - About 4 hrs 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 serveTransforming has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function serveTransforming(pathToFile, anyFileOrOptions, extOriginal, extTarget, renderizer, textType) {
    let regExpExtDetect;
    let regExpExtReplace;
    let anyFile;
    var renderOptions = null;
Severity: Major
Found in lib/mini-tools.js - About 2 hrs to fix

    File mini-tools.js has 265 lines of code (exceeds 250 allowed). Consider refactoring.
    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");
    Severity: Minor
    Found in lib/mini-tools.js - About 2 hrs to fix

      Function readConfig has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      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);
      Severity: Minor
      Found in lib/mini-tools.js - About 2 hrs to fix

        Function listOfConfig has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            let listOfConfig = await Promise.all(listOfFileNamesOrConfigObjects.map(async function (fileNameOrObject) {
                let result;
                if (typeof fileNameOrObject === "string") {
                    let ext = Path.extname(fileNameOrObject);
                    let exts;
        Severity: Minor
        Found in lib/mini-tools.js - About 1 hr to fix

          Function unchainedFunction has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  async function unchainedFunction() {
                      try {
                          let pathname = ('path' in req /*never*/ ? req.path : url.parse(req.url).pathname);
                          /* istanbul ignore next */
                          if (traceRoute) {
          Severity: Minor
          Found in lib/mini-tools.js - About 1 hr to fix

            Function serveErr has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function serveErr(_req, res, next) {
                return async function (err) {
                    if (err.message === 'next') {
                        return next();
                    }
            Severity: Minor
            Found in lib/mini-tools.js - About 1 hr to fix

              Function serveTransforming has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              function serveTransforming(pathToFile, anyFileOrOptions, extOriginal, extTarget, renderizer, textType) {
                  let regExpExtDetect;
                  let regExpExtReplace;
                  let anyFile;
                  var renderOptions = null;
              Severity: Minor
              Found in lib/mini-tools.js - About 1 hr 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 serveTransforming has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              function serveTransforming(pathToFile, anyFileOrOptions, extOriginal, extTarget, renderizer, textType) {
              Severity: Minor
              Found in lib/mini-tools.js - About 45 mins to fix

                TODO found
                Open

                                    // TODO: algún día esto no va a ser necesario porque van a implementar los arreglos compactos!
                Severity: Minor
                Found in lib/mini-tools.js by fixme

                There are no issues that match your filters.

                Category
                Status