tantalim/tantalim-server

View on GitHub

Showing 59 of 59 total issues

Function compile has 203 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function compile(modelDefinition) {
    var ARTIFACT = pageService.ARTIFACT; // Easy alias

    logger.info('Starting model compile', modelDefinition.name);

Severity: Major
Found in app/services/modelCompiler.js - About 1 day to fix

    Function compile has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

    function compile(modelDefinition) {
        var ARTIFACT = pageService.ARTIFACT; // Easy alias
    
        logger.info('Starting model compile', modelDefinition.name);
    
    
    Severity: Minor
    Found in app/services/modelCompiler.js - About 3 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 desktop has 80 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    exports.desktop = function (req, res, appLocals) {
        if (!req.user) {
            res.redirect('/login');
            return;
        }
    Severity: Major
    Found in app/controllers/pageController.js - About 3 hrs to fix

      Function buildSteps has 70 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function buildSteps(modelDefinition, todo) {
              if (_.isEmpty(modelDefinition.steps)) {
                  return;
              }
      
      
      Severity: Major
      Found in app/services/modelCompiler.js - About 2 hrs to fix

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

        var start = function () {
            var app = express();
        
            app.locals = _.extend(app.locals, config.locals || {});
        
        
        Severity: Major
        Found in server.js - About 2 hrs to fix

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

                                  service.getDefinition(service.ARTIFACT.MODEL, page.model)
                                      .then(function (model) {
                                          attachModelToPage(page, model);
                                          return renderDesktop(page, menu);
                                      })
          Severity: Major
          Found in app/controllers/pageController.js and 1 other location - About 2 hrs to fix
          app/controllers/pageController.js on lines 67..102

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

          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

                      service.getDefinition(service.ARTIFACT.PAGE, req.pageName)
                          .then(function (page) {
                              if (page.model) {
                                  service.getDefinition(service.ARTIFACT.MODEL, page.model)
                                      .then(function (model) {
          Severity: Major
          Found in app/controllers/pageController.js and 1 other location - About 2 hrs to fix
          app/controllers/pageController.js on lines 70..86

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

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

          function updateData(modelDefinition, row) {
              return new BluebirdPromise(function (resolve, reject) {
                  logger.debug('starting updateData() for ', modelDefinition.name);
          
                  checkConnection();
          Severity: Major
          Found in app/services/modelSaver.js - About 2 hrs to fix

            File modelSaver.js has 259 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            'use strict';
            
            var _ = require('lodash'),
                BluebirdPromise = require('bluebird'),
                knex = require('knex').knex,
            Severity: Minor
            Found in app/services/modelSaver.js - About 2 hrs to fix

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

              function convertErrorToJson(err) {
                  if (typeof err === 'string') {
                      logger.warn('Try throwing an error instead for message: ' + err);
                      return {
                          code: 'Error',
              Severity: Major
              Found in app/controllers/dataController.js and 1 other location - About 2 hrs to fix
              app/controllers/pageController.js on lines 9..22

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

              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

              function convertErrorToJson(err) {
                  if (typeof err === 'string') {
                      logger.warn('Try throwing an error instead for message: ' + err);
                      return {
                          code: 'Error',
              Severity: Major
              Found in app/controllers/pageController.js and 1 other location - About 2 hrs to fix
              app/controllers/dataController.js on lines 8..21

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

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

                  function mapFields(modelDefinition) {
                      if (!modelDefinition.fields) {
                          logger.warn('Model had no fields');
                          return;
                      }
              Severity: Major
              Found in app/services/modelCompiler.js - About 2 hrs to fix

                Function getModelByName has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function getModelByName(modelName) {
                    return new BluebirdPromise(function (resolveGetModelByName, rejectGetModelByName) {
                        logger.debug('starting modelService.getModelByName for ', modelName);
                        var names = toWhere(modelName);
                
                
                Severity: Minor
                Found in app/services/db/modelDatabaseService.js - About 2 hrs to fix

                  Function compile has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function compile(menuDefinition) {
                      logger.info('Starting compile', menuDefinition.name);
                  
                      var pageNames = [];
                  
                  
                  Severity: Minor
                  Found in app/services/menuCompiler.js - About 1 hr to fix

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

                    function addDataApi(app) {
                        var dataController = require('../controllers/dataController');
                    
                        app.get('/data/:pageName', function (req, res) {
                            dataController.query(req, res);
                    Severity: Major
                    Found in app/routes/index.js and 1 other location - About 1 hr to fix
                    app/routes/index.js on lines 55..65

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

                    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

                    function addSourceEtl(app) {
                        var sourceEtlController = require('../controllers/sourceEtlController');
                    
                        app.get('/exportAll', function (req, res) {
                            sourceEtlController.exportAll(req, res);
                    Severity: Major
                    Found in app/routes/index.js and 1 other location - About 1 hr to fix
                    app/routes/index.js on lines 34..43

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

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

                    function apply(filterString, sql, fields) {
                        if (!filterString) {
                            return;
                        }
                    
                    
                    Severity: Minor
                    Found in app/services/filter.js - About 1 hr to fix

                      Function parseAndCompile has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          function parseAndCompile(modelDefinition) {
                              logger.info('Running parseAndCompile for ' + modelDefinition.name);
                              //logger.debug(modelDefinition);
                              var todo = [];
                      
                      
                      Severity: Minor
                      Found in app/services/modelCompiler.js - About 1 hr to fix

                        Function queryModelData has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        function queryModelData(model) {
                            return new BluebirdPromise(function (resolve, reject) {
                                logger.debug('starting queryModelData');
                                var sql = convertModelToKnexSql(model);
                        
                        
                        Severity: Minor
                        Found in app/services/dataReader.js - About 1 hr to fix

                          Function convertModelToKnexSql has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function convertModelToKnexSql(model) {
                              logger.debug('starting convertModelToKnexSql for ' + model.name);
                              //logger.debug(JSON.stringify(model));
                          
                              if (!knex) {
                          Severity: Minor
                          Found in app/services/dataReader.js - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language