meteor/meteor

View on GitHub
tools/packaging/catalog/catalog-remote.js

Summary

Maintainability
F
4 days
Test Coverage

File catalog-remote.js has 735 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var _ = require('underscore');
var sqlite3 = require('sqlite3');

var files = require('../../fs/files');
var utils = require('../../utils/utils.js');
Severity: Major
Found in tools/packaging/catalog/catalog-remote.js - About 1 day to fix

    `` has 36 functions (exceeds 20 allowed). Consider refactoring.
    Open

    Object.assign(RemoteCatalog.prototype, {
      toString: function () {
        var self = this;
        return "RemoteCatalog";
      },
    Severity: Minor
    Found in tools/packaging/catalog/catalog-remote.js - About 4 hrs to fix

      Function runInTransaction has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

        runInTransaction: function (action) {
          var self = this;
      
          var runOnce = Profile("sqlite query", function () {
            var txn = new Txn(self);
      Severity: Minor
      Found in tools/packaging/catalog/catalog-remote.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 runInTransaction has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        runInTransaction: function (action) {
          var self = this;
      
          var runOnce = Profile("sqlite query", function () {
            var txn = new Txn(self);
      Severity: Minor
      Found in tools/packaging/catalog/catalog-remote.js - About 1 hr to fix

        Function initialize has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          initialize: function (options) {
            var self = this;
        
            options = options || {};
            // We should to figure out if we are intending to connect to the package server.
        Severity: Minor
        Found in tools/packaging/catalog/catalog-remote.js - About 1 hr to fix

          Function _query has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            _query: function (sql, params) {
              var self = this;
          
              var prepared = null;
              var prepare = self._autoPrepare && !_.isEmpty(params);
          Severity: Minor
          Found in tools/packaging/catalog/catalog-remote.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 _execute has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            _execute: function (sql, params) {
              var self = this;
          
              var prepared = null;
              // We don't prepare non-parametrized statements, because (a) there's not
          Severity: Minor
          Found in tools/packaging/catalog/catalog-remote.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 _execute has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            _execute: function (sql, params) {
              var self = this;
          
              var prepared = null;
              // We don't prepare non-parametrized statements, because (a) there's not
          Severity: Minor
          Found in tools/packaging/catalog/catalog-remote.js - About 1 hr to fix

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

              refresh: function (options) {
                var self = this;
                options = options || {};
            
                Console.debug("In remote catalog refresh");
            Severity: Minor
            Found in tools/packaging/catalog/catalog-remote.js - About 1 hr to fix

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

                refresh: function (options) {
                  var self = this;
                  options = options || {};
              
                  Console.debug("In remote catalog refresh");
              Severity: Minor
              Found in tools/packaging/catalog/catalog-remote.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 runOnce has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  var runOnce = Profile("sqlite query", function () {
                    var txn = new Txn(self);
              
                    var t1 = Date.now();
              
              
              Severity: Minor
              Found in tools/packaging/catalog/catalog-remote.js - About 1 hr to fix

                Function _query has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  _query: function (sql, params) {
                    var self = this;
                
                    var prepared = null;
                    var prepare = self._autoPrepare && !_.isEmpty(params);
                Severity: Minor
                Found in tools/packaging/catalog/catalog-remote.js - About 1 hr to fix

                  Function _retry has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                    _retry: function (f, options) {
                      options = Object.assign({ maxAttempts: 3, delay: 500}, options || {});
                  
                      for (var attempt = 1; attempt <= options.maxAttempts; attempt++) {
                        try {
                  Severity: Minor
                  Found in tools/packaging/catalog/catalog-remote.js - About 55 mins 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 createTable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    createTable: function (txn) {
                      var self = this;
                  
                      var sql = 'CREATE TABLE IF NOT EXISTS ' + self.name + '(';
                      for (var i = 0; i < self.jsonFields.length; i++) {
                  Severity: Minor
                  Found in tools/packaging/catalog/catalog-remote.js - About 25 mins 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

                  There are no issues that match your filters.

                  Category
                  Status