codenautas/mini-tools

View on GitHub

Showing 19 of 19 total issues

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 readConfig has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

export async function readConfig<T>(listOfFileNamesOrConfigObjects:(string|T)[], opts:{whenNotExist?:'ignore'}={}):Promise<T>{
    let listOfConfig = await Promise.all(listOfFileNamesOrConfigObjects.map(async function(fileNameOrObject){
        type FileNameExtObjOrEmpty = {fileName:string, ext:string}|{empty:true}
        let result:FileNameExtObjOrEmpty;
        if(typeof fileNameOrObject==="string"){
Severity: Minor
Found in src/mini-tools.ts - 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

    Function serveTransforming has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function serveTransforming(
        pathToFile:string, 
        anyFileOrOptions:null|boolean|RenderOptions, 
        extOriginal:string, 
        extTarget:string, 
    Severity: Major
    Found in src/mini-tools.ts - 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 readConfig has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export async function readConfig<T>(listOfFileNamesOrConfigObjects:(string|T)[], opts:{whenNotExist?:'ignore'}={}):Promise<T>{
                let listOfConfig = await Promise.all(listOfFileNamesOrConfigObjects.map(async function(fileNameOrObject){
                    type FileNameExtObjOrEmpty = {fileName:string, ext:string}|{empty:true}
                    let result:FileNameExtObjOrEmpty;
                    if(typeof fileNameOrObject==="string"){
            Severity: Minor
            Found in src/mini-tools.ts - 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 listOfConfig has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    let listOfConfig = await Promise.all(listOfFileNamesOrConfigObjects.map(async function(fileNameOrObject){
                        type FileNameExtObjOrEmpty = {fileName:string, ext:string}|{empty:true}
                        let result:FileNameExtObjOrEmpty;
                        if(typeof fileNameOrObject==="string"){
                                let ext=Path.extname(fileNameOrObject);
                Severity: Minor
                Found in src/mini-tools.ts - About 1 hr to fix

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

                          async function unchainedFunction():Promise<void>{
                              try{
                                  let pathname:string = ('path' in (req as any /*never*/) ? req.path : url.parse(req.url).pathname) as string;
                                  /* istanbul ignore next */
                                  if(traceRoute){
                  Severity: Minor
                  Found in src/mini-tools.ts - 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 serveErr has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export function serveErr(_req:Request,res:Response,next:NextFunction):(err:AnyErrorDuck) => Promise<void>{
                          return async function(err:AnyErrorDuck){
                              if(err.message==='next'){
                                  return next();
                              }
                      Severity: Minor
                      Found in src/mini-tools.ts - 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 a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function serveTransforming(
                            pathToFile:string, 
                            anyFileOrOptions:null|boolean|RenderOptions, 
                            extOriginal:string, 
                            extTarget:string, 
                        Severity: Minor
                        Found in src/mini-tools.ts - 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

                          Function serveTransforming has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              pathToFile:string, 
                              anyFileOrOptions:null|boolean|RenderOptions, 
                              extOriginal:string, 
                              extTarget:string, 
                              renderizer:{render:Function, args:object}, 
                          Severity: Minor
                          Found in src/mini-tools.ts - 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

                            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 src/mini-tools.ts by fixme
                            Severity
                            Category
                            Status
                            Source
                            Language