e-ucm/rage-analytics-backend

View on GitHub
bin/upgrade/controllers/upgrade-elastic-indices.js

Summary

Maintainability
B
5 hrs
Test Coverage

Function guessModelVersion has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

ElasticController.prototype.guessModelVersion = function(esClient, callback) {
    console.log('Trying to guess elasticsearch existing model version!');
    var defaultIndex = require(Path.resolve(__dirname, '../../../lib/kibana/defaultIndex.js'));
    var indexId = 'defaultIndex';

Severity: Major
Found in bin/upgrade/controllers/upgrade-elastic-indices.js - About 2 hrs to fix

    Function getModelVersion has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    ElasticController.prototype.getModelVersion = function (config, callback) {
        var esClient = config.elasticsearch.esClient;
        var modelVersion = null;
    
        esClient.get({
    Severity: Minor
    Found in bin/upgrade/controllers/upgrade-elastic-indices.js - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                                  for (var i = 0; i < fields.length; ++i) {
                                      var field = fields[i];
                                      if (field && field.name && field.name.indexOf('ext.') === 0) {
                                          isVersion2 = field;
                                          break;
      Severity: Major
      Found in bin/upgrade/controllers/upgrade-elastic-indices.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                    if (isVersion2) {
                                        console.log('Fields parsed, found ext. def at field ' + JSON.stringify(isVersion2, null, 4));
                                        callback('2');
                                    } else {
                                        console.log('Fields parsed object has elements but no ext valued found, defaulting to minimum version');
        Severity: Major
        Found in bin/upgrade/controllers/upgrade-elastic-indices.js - About 45 mins to fix

          There are no issues that match your filters.

          Category
          Status