codenautas/backend-plus

View on GitHub

Showing 408 of 408 total issues

Consider simplifying this complex logical expression.
Open

        if(evento.which==115 && !evento.shiftKey  && !evento.ctrlKey  && !evento.altKey  && !evento.metaKey){ // F4
            /** @type {HTMLElement} */
            var activeElement = this.activeElement && this.activeElement.tagName!='BODY' && this.activeElement || document.mayBeRepetibleButton; 
            var info=tableInfo(activeElement);
            if(info.table){
Severity: Critical
Found in for-client/my-things.js - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

            if(pol && pol.enabled){
                otherColumns.push(`(${(pol.enabled && (pol.update.using || pol.all.using) || 'true' )}) is true as "$allow.update"`);
                otherColumns.push(`(${(pol.enabled && (pol.delete.using || pol.all.using) || 'true' )}) is true as "$allow.delete"`);
            }
    Severity: Critical
    Found in lib/table-def-adapt.js - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

              if(!fieldDef.clientSide && fieldDef.inTable!==false && !fieldDef.inJoin && !(tableDef.sql.fields[fieldDef.name]||{}).expr || fieldDef.inTable){
                  var fieldType=typeDb[fieldDef.typeName]||'"'+fieldDef.typeName+'"';
                  if(fieldDef.sizeByte==4){
                      fieldType = 'integer';
                  }
      Severity: Critical
      Found in lib/backend-plus.js - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

                if(config.nodb){
                    console.log("server without database");
                }else{
                    if(be.config.login["double-dragon"]){
                        be.DoubleDragon = {dbParams:{}}
        Severity: Critical
        Found in lib/backend-plus.js - About 1 hr to fix

          Function updateRowData has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              grid.updateRowData = function updateRowData(depot, skipUpdateStatus){
                  var grid = this;
                  var forInsert = false; // not define how to detect
                  var tr = depot;
                  grid.setRowStyle(depot,depot.row, skipUpdateStatus);
          Severity: Minor
          Found in for-client/my-tables.js - About 1 hr to fix

            Function saveRow has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                var saveRow = function(depot, opts){
                    if(!('saving' in depot)){
                        depot.saving = Promise.resolve();
                    }
                    changeIoStatus(depot,'updating',depot.rowPendingForUpdate);
            Severity: Minor
            Found in for-client/my-tables.js - About 1 hr to fix

              Function getChild has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  async getChild<T>(tableName:string, parentKey:Key):Promise<T[]>{
                      var ldb=this;
                      var db=await ldb.wait4db
                      var rows:T[]=[];
                      var internalKey:string|Key;
              Severity: Minor
              Found in src/for-client/my-localdb.ts - About 1 hr to fix

                Function validateBitacora has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                AppBackend.prototype.validateBitacora = function validateBitacora(procedureDef){
                    var be = this;
                    if(procedureDef.bitacora.targetTable in be.tableStructures){
                        var contextForDump=be.getContextForDump();
                        var tableDefFields = be.tableStructures[procedureDef.bitacora.targetTable](contextForDump).fields;
                Severity: Minor
                Found in lib/backend-plus.js - About 1 hr to fix

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

                      updateDatabase(updateSql, parametros) {
                          var id=parametros[0];
                          var be=this;
                          var client;
                          return this.getDbClient().then(function(cli) {
                  Severity: Minor
                  Found in ejemplos/encuesta.js - About 1 hr to fix

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

                    myOwn.TableGrid.prototype.prepareAndDisplayGrid = function prepareAndDisplayGrid(){
                        var grid = this;
                        grid.displayPreLoadMessage();
                        var structureRequest = grid.connector.getStructure().then(function(tableDef){
                            grid.def = tableDef;
                    Severity: Minor
                    Found in for-client/my-tables.js - About 1 hr to fix

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

                          resultTableDef.fields = resultTableDef.fields.map(function(fieldDef){
                              var resultFieldDef = changing(changing({
                                  visible: true,
                                  allow:{},
                                  defaultForOtherFields: false,
                      Severity: Minor
                      Found in lib/table-def-adapt.js - About 1 hr to fix

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

                            constructor(){
                                let be = this;
                                /** @type {any} */
                                this.config={};
                                /** @type {{path:string}[]} */
                        Severity: Minor
                        Found in lib/backend-plus.js - About 1 hr to fix

                          Function next_number has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                              next_number:function(fieldName, aboveDepot, belowDepot){ 
                                  var manager = aboveDepot.manager ?? belowDepot.manager
                                  if(!manager){
                                      return 1;
                                  }else{
                          Severity: Minor
                          Found in for-client/my-tables.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 registerStructureInside has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                              private async registerStructureInside(tableDef:TableDefinition, wait4db:Promise<IDBDatabase>):Promise<{
                                  wait4db:Promise<IDBDatabase>,
                                  result:RegisterResult
                              }>{
                                  var ldb=this;
                          Severity: Minor
                          Found in src/for-client/my-localdb.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

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

                              var sql =  `INSERT INTO ${db.quoteIdent(schemaName)}.${db.quoteIdent(tableName)}
                                  (${cleanKeys.join(',')}) VALUES (${cleanValues.join(',')}) returning id`;
                          Severity: Major
                          Found in lib/backend-plus.js and 1 other location - About 1 hr to fix
                          lib/backend-plus.js on lines 1356..1358

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

                          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

                              var sql =  `UPDATE ${db.quoteIdent(schemaName)}.${db.quoteIdent(tableName)} 
                                  SET ${setPairs.join(',')}
                                  WHERE ${filterPairs.join(' AND ')}`;
                          Severity: Major
                          Found in lib/backend-plus.js and 1 other location - About 1 hr to fix
                          lib/backend-plus.js on lines 1340..1341

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

                          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

                                                              try{
                                                                  await context.client.query("BEGIN TRANSACTION").execute();
                                                              }catch(err2){
                                                                  err.detail+=' *** in BEGIN TRANSACTION ' + err2.message;
                                                                  throw err
                          Severity: Major
                          Found in lib/procedures-table.js and 1 other location - About 1 hr to fix
                          lib/procedures-table.js on lines 1076..1081

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

                          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

                                                              try{
                                                                  await context.client.query('ROLLBACK').execute();
                                                              }catch(err2){
                                                                  err.detail+=' *** in ROLLBACK ' + err2.message;
                                                                  throw err
                          Severity: Major
                          Found in lib/procedures-table.js and 1 other location - About 1 hr to fix
                          lib/procedures-table.js on lines 1082..1087

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

                          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 filterDepots has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              grid.filterDepots = function filterDepots(depotsToFilter){
                                  var grid = this;
                                  var filterRows = grid.view.filter;
                                  var depotsToDisplay;
                                  if(filterRows && filterRows.length){
                          Severity: Minor
                          Found in for-client/my-tables.js - About 1 hr to fix

                            Function refreshAggregates has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            myOwn.TableGrid.prototype.refreshAggregates = function refreshAggregates(){
                                var grid = this;
                                var my = grid.my;
                                var aggData={};
                                grid.def.fields.forEach(function(fieldDef){
                            Severity: Minor
                            Found in for-client/my-tables.js - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language