codenautas/backend-plus

View on GitHub

Showing 408 of 408 total issues

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    addLoggedServices(){
        var be = this;
        super.addLoggedServices();
        this.app.get('/echo', function(req,res){
            res.end('echo');
Severity: Major
Found in examples/4test/server/app-4test.js and 1 other location - About 1 hr to fix
examples/tables/server/server-tables.js on lines 71..77

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 59.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    addLoggedServices(){
        var be = this;
        super.addLoggedServices();
        this.app.get('/echo', function(req,res){
            res.end('echo');
Severity: Major
Found in examples/tables/server/server-tables.js and 1 other location - About 1 hr to fix
examples/4test/server/app-4test.js on lines 20..26

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 59.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function setInheritedFields has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    grid.setInheritedFields = function(depot, filterFun){
        var promiseArray = [];
        grid.def.foreignKeys.concat(grid.def.softForeignKeys).filter(filterFun||(x=>x))
        .filter(x=>(x.inheritFieldsMode ?? my.config.config['inherit-fields-mode']) != 'no-inherit' ).forEach(function(fkDef){
            var fixedFields = fkDef.fields.map(function(field){
Severity: Minor
Found in for-client/my-tables.js - About 1 hr to fix

    Function rowsForUpsert has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                            var rowsForUpsert=lines.slice(1).map(function(line){
                                var othersArray = [];
                                if(separator=='|'){
                                    var row = splitRawRowIntoRow(line);
    
    Severity: Minor
    Found in lib/procedures-table.js - About 1 hr to fix

      Function exports has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function(context){
          var $1_is_num=`$1 ~ '^\\s*(\\d+(\\.\\d*)?|\\.\\d+)\\s*$'`
          return context.be.tableDefAdapt({
              name:'summary',
              schema:'his',
      Severity: Minor
      Found in lib/tables/table-summary.js - About 1 hr to fix

        Function informProgress has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                                    context.informProgress=function informProgress(progressInfo){
                                        var progress2send={};
                                        if(progressInfo instanceof Error){
                                            MiniTools.globalOpts.serveErr.propertiesWhiteList.forEach(function(attr){
                                                progress2send[attr] = progressInfo[attr];
        Severity: Minor
        Found in lib/backend-plus.js - About 1 hr to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  be.app.get('/menu',function(req,res,next){
                      return MiniTools.serveText(be.mainPage(req, false).toHtmlDoc(),'html')(req,res,next);
                  });
          Severity: Major
          Found in lib/backend-plus.js and 1 other location - About 1 hr to fix
          lib/backend-plus.js on lines 2301..2303

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 58.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                      be.app.get('/ext', function(req,res,next){
                          return MiniTools.serveText(be.mainPage(req, true).toHtmlDoc(),'html')(req,res,next);
                      });
          Severity: Major
          Found in lib/backend-plus.js and 1 other location - About 1 hr to fix
          lib/backend-plus.js on lines 2295..2297

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 58.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Function table has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          myOwn.wScreens.table = function(addrParams){
              setTimeout(function(){
                  var layout = document.getElementById('main_layout');
                  var opts={tableDef: addrParams.td ?? {}};
                  if(addrParams.ff){
          Severity: Minor
          Found in for-client/my-menu.js - About 1 hr to fix

            Function getData has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            myOwn.TableConnector.prototype.getData = function getData(){
                var connector = this;
                if(((connector.opts||{}).tableDef||{}).forInsertOnlyMode){
                    return Promise.resolve([]);
                }
            Severity: Minor
            Found in for-client/my-tables.js - About 1 hr to fix

              Function exports has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports = function(context){
                  var allow = function(roles){
                      return {
                          select:!!roles[context.user.rol],
                          insert:context.user.rol==='admin',
              Severity: Minor
              Found in examples/fichero/server/table-autores.js - About 1 hr to fix

                Function inTransaction has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    async inTransaction<T>(callback:(ldb:LocalDb)=>Promise<T>):Promise<T>{
                        var name=this.localDbName;
                        this.oneByOneChain = this.oneByOneChain.then(async function(){
                            var ldb = new LocalDb(name);
                            async function closeLdb(err:Error):Promise<never>;
                Severity: Minor
                Found in src/for-client/my-localdb.ts - About 1 hr to fix

                  Function getDbClient has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                                  be.getDbClient = function getDbClient(req){
                                      var paramsDb = be.DoubleDragon?.dbParams?.[req?.user?.[be.config.login.userFieldName]] ?? be.config.db;
                                      return pg.connect(paramsDb).then(function(client){
                                          var dbAppName=req?(
                                              ((req.user||{})[be.config.login.userFieldName]||'!logged')+
                  Severity: Minor
                  Found in lib/backend-plus.js - About 1 hr to fix

                    Function constructor has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        constructor(public name:string){
                            var ldb=this;
                            var initialStores:StoreDefs={
                                $structures:'name',
                                $internals:'var',
                    Severity: Minor
                    Found in src/for-client/my-localdb.ts - About 1 hr to fix

                      Identical blocks of code found in 2 locations. Consider refactoring.
                      Open

                                  be.updateDatabase(
                                      "UPDATE bep.datos SET estado=$2 WHERE id = $1 RETURNING contenido",
                                      [parametros.id, parametros.estado]
                                  ).then(function(result){
                                      res.end("recibi: "+JSON.stringify(parametros));
                      Severity: Major
                      Found in ejemplos/encuesta.js and 1 other location - About 1 hr to fix
                      ejemplos/encuesta.js on lines 233..239

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 57.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Identical blocks of code found in 2 locations. Consider refactoring.
                      Open

                              return Promises.start(function(){
                                  return be.updateDatabase(sqlUpdate,parametros);
                              }).then(function(result){
                                  res.end("recibi: "+JSON.stringify(parametros));
                              },function(err){
                      Severity: Major
                      Found in ejemplos/encuesta.js and 1 other location - About 1 hr to fix
                      ejemplos/encuesta.js on lines 272..279

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 57.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                              mainApp.get(Path.posix.join(baseUrl,be.config.login.forget.urlPathOk), be.config.login.plus.newPassPageServe2)
                      Severity: Major
                      Found in lib/backend-plus.js and 1 other location - About 1 hr to fix
                      lib/backend-plus.js on lines 1817..1817

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 57.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                              mainApp.get(Path.posix.join(baseUrl,be.config.login.forget.urlPath), be.config.login.plus.newPassPageServe)
                      Severity: Major
                      Found in lib/backend-plus.js and 1 other location - About 1 hr to fix
                      lib/backend-plus.js on lines 1818..1818

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 57.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

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

                          showParams:function(formDef, main_layout, addrParams, mainAction){
                              var autoproced = addrParams.autoproced || false
                              addrParams.up=addrParams.up||addrParams.ff||{};
                              var params=addrParams.up;
                              // var button = html.button(formDef.proceedLabel||my.messages.proceed).create();
                      Severity: Minor
                      Found in for-client/my-menu.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 doneFun has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              menuOptions.push({img:my.path.img+'delete-all-rows.png', value:true, label:my.messages.deleteAllRecords, doneFun:function(){
                                  return confirmPromise(my.messages.confirmDeleteAll+(
                                      grid.depotsToDisplay.length<grid.depots.length?my.messages.xOverTWillDelete:(
                                          grid.connector.fixedFields.length?my.messages.allGWillDelete:my.messages.allTWillDelete
                                      )
                      Severity: Minor
                      Found in for-client/my-tables.js - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language