codenautas/mini-tools

View on GitHub
src/mini-tools.ts

Summary

Maintainability
D
1 day
Test Coverage

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 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

    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 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 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: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

                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 src/mini-tools.ts by fixme

              There are no issues that match your filters.

              Category
              Status