codenautas/backend-plus

View on GitHub

Showing 408 of 408 total issues

Function tableDatum has 83 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        async function tableDatum(context, parameters){
            var be=context.be;
            var tableName=parameters.table;
            var defTable=be.tableStructures[tableName];
            if(!defTable){
Severity: Major
Found in lib/procedures-table.js - About 3 hrs to fix

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

        var allow = function(roles){
            return {
                select:!!roles[context.user.rol],
                insert:!!roles[context.user.rol],
                update:!!roles[context.user.rol],
    Severity: Major
    Found in examples/fichero/server/table-tipos_medios.js and 2 other locations - About 3 hrs to fix
    examples/fichero/server/table-apariciones.js on lines 4..11
    examples/fichero/server/table-medios.js on lines 4..11

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

    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 3 locations. Consider refactoring.
    Open

        var allow = function(roles){
            return {
                select:!!roles[context.user.rol],
                insert:!!roles[context.user.rol],
                update:!!roles[context.user.rol],
    Severity: Major
    Found in examples/fichero/server/table-medios.js and 2 other locations - About 3 hrs to fix
    examples/fichero/server/table-apariciones.js on lines 4..11
    examples/fichero/server/table-tipos_medios.js on lines 4..11

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

    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 3 locations. Consider refactoring.
    Open

        var allow = function(roles){
            return {
                select:!!roles[context.user.rol],
                insert:!!roles[context.user.rol],
                update:!!roles[context.user.rol],
    Severity: Major
    Found in examples/fichero/server/table-apariciones.js and 2 other locations - About 3 hrs to fix
    examples/fichero/server/table-medios.js on lines 4..11
    examples/fichero/server/table-tipos_medios.js on lines 4..11

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

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

        detailControl.displayDetailGrid = function(opts,event){
            var result;
            event=event||{};
            if(!('fixedFields' in opts)){
                opts.fixedFields = calculateFixedFields();
    Severity: Major
    Found in for-client/my-tables.js - About 3 hrs to fix

      Function checkDatabaseStructure has 81 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      AppBackend.prototype.checkDatabaseStructure = async function checkDatabaseStructure(client){
          var be=this;
          var result = await client.query(`select setting from pg_settings where name='server_version';`).fetchUniqueValue();
          if(result.value<be.config.db['min-version']){
              console.log('PARA INSTALACIONES VIEJAS QUE NO USEN generatedAs O NO ACTUALICEN operativos:');
      Severity: Major
      Found in lib/backend-plus.js - About 3 hrs to fix

        Function displayBody has 80 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            grid.displayBody=function displayBody(){
                var grid = this;
                var depotsToDisplay = grid.filterDepots(grid.depots);
                grid.sortDepotsToDisplay = function sortDepotsToDisplay(depotsToDisplay){
                    if(grid.view.sortColumns.length>0){
        Severity: Major
        Found in for-client/my-tables.js - About 3 hrs to fix

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

              my.autoSetup().then(function(){
                  linkButtons('button.tables', function(){
                      var layout = document.getElementById('table_layout');
                      my.tableGrid(this.getAttribute('id-table'),layout);
                  });
          Severity: Major
          Found in examples/fichero/client/index.js and 1 other location - About 3 hrs to fix
          examples/fichero/client/admin.js on lines 16..24

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

          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

              my.autoSetup().then(function(){
                  linkButtons('button.tables', function(){
                      var layout = document.getElementById('table_layout');
                      my.tableGrid(this.getAttribute('id-table'),layout);
                  });
          Severity: Major
          Found in examples/fichero/client/admin.js and 1 other location - About 3 hrs to fix
          examples/fichero/client/index.js on lines 27..35

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

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

          AppBackend.prototype.mainPage = function mainPage(req, offlineMode, opts){
              opts = opts||{};
              if(!opts.icons){
                  if(!opts.icon){
                      opts.icons={
          Severity: Major
          Found in lib/backend-plus.js - About 2 hrs to fix

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

                                    if(result.uploaded.skipped==1){
                                        messages.push(my.messages.oneRowSkipped);
                                    }else if(result.uploaded.skipped>1){
                                        messages.push(my.messages.xRowsSkipped.replace('{$x}',result.uploaded.skipped));
                                    }
            Severity: Major
            Found in for-client/my-tables.js and 3 other locations - About 2 hrs to fix
            for-client/my-tables.js on lines 1470..1474
            for-client/my-tables.js on lines 1475..1479
            for-client/my-tables.js on lines 1485..1489

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

            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 4 locations. Consider refactoring.
            Open

                                    if(result.uploaded.updated==1){
                                        messages.push(my.messages.oneRowUpdated);
                                    }else if(result.uploaded.updated>1){
                                        messages.push(my.messages.xRowsUpdated.replace('{$x}',result.uploaded.updated));
                                    }
            Severity: Major
            Found in for-client/my-tables.js and 3 other locations - About 2 hrs to fix
            for-client/my-tables.js on lines 1470..1474
            for-client/my-tables.js on lines 1480..1484
            for-client/my-tables.js on lines 1485..1489

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

            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 4 locations. Consider refactoring.
            Open

                                    if(result.uploaded.inserted==1){
                                        messages.push(my.messages.oneRowInserted);
                                    }else if(result.uploaded.inserted>1){
                                        messages.push(my.messages.xRowsInserted.replace('{$x}',result.uploaded.inserted));
                                    }
            Severity: Major
            Found in for-client/my-tables.js and 3 other locations - About 2 hrs to fix
            for-client/my-tables.js on lines 1475..1479
            for-client/my-tables.js on lines 1480..1484
            for-client/my-tables.js on lines 1485..1489

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

            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 4 locations. Consider refactoring.
            Open

                                    if(result.uploaded.deleted==1){
                                        messages.push(my.messages.oneRowDeleted);
                                    }else if(result.uploaded.deleted>1){
                                        messages.push(my.messages.xRowsDeleted.replace('{$x}',result.uploaded.deleted));
                                    }
            Severity: Major
            Found in for-client/my-tables.js and 3 other locations - About 2 hrs to fix
            for-client/my-tables.js on lines 1470..1474
            for-client/my-tables.js on lines 1475..1479
            for-client/my-tables.js on lines 1480..1484

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

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

                    coreFunction:async function(context,parameters){
                        var {be} = context;
                        var {db} = be;
                        var tableName = parameters.table;
                        var rows = await be.inTransaction(null, async function(client){
            Severity: Major
            Found in lib/procedures-table.js - About 2 hrs to fix

              Function tipoCeldas has 71 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  tipoCeldas(){
                      //var tiposCeldas = {
                      return {
                          titulo:{
                              completar: function completar(){
              Severity: Major
              Found in ejemplos/encuesta.js - About 2 hrs to fix

                Function doneFun has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    menuOptions.push({img:my.path.img+'show-hide-columns.png', value:true, label: my.messages.hideOrShow, doneFun:function(){
                        dialogPromise(function(dialogWindow, closeWindow){
                            var button=html.button({class:'hide-or-show'},'ok').create();
                            var createSelectElement=function createSelectElement(columns,hideOrShowId,disabledItems){
                                var selectElement=html.select(
                Severity: Major
                Found in for-client/my-tables.js - About 2 hrs to fix

                  Function tableGrid has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                  myOwn.tableGrid = function tableGrid(tableName, mainElement, opts){
                      var my = this;
                      var grid = new my.TableGrid({my: this}, mainElement);
                      opts = opts || {};
                      grid.detailingForUrl=opts.detailingForUrl;
                  Severity: Minor
                  Found in for-client/my-tables.js - About 2 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 mainPage has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                  AppBackend.prototype.mainPage = function mainPage(req, offlineMode, opts){
                      opts = opts||{};
                      if(!opts.icons){
                          if(!opts.icon){
                              opts.icons={
                  Severity: Minor
                  Found in lib/backend-plus.js - About 2 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

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

                      var allow = function(roles){
                          return {
                              select:!!roles[context.user.rol],
                              insert:context.user.rol==='admin',
                              update:context.user.rol==='admin',
                  Severity: Major
                  Found in examples/fichero/server/table-autores.js and 1 other location - About 2 hrs to fix
                  examples/fichero/server/table-fichas.js on lines 4..11

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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language