meteor/meteor

View on GitHub
packages/mongo/collection.js

Summary

Maintainability
F
5 days
Test Coverage

File collection.js has 579 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// options.connection, if given, is a LivedataClient or LivedataServer
// XXX presently there is no way to destroy/clean up a Collection
import {
  ASYNC_COLLECTION_METHODS,
  getAsyncMethodName,
Severity: Major
Found in packages/mongo/collection.js - About 1 day to fix

    Function _maybeSetUpReplication has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
    Open

      _maybeSetUpReplication(name, { _suppressSameNameError = false }) {
        const self = this;
        if (!(self._connection && self._connection.registerStore)) {
          return;
        }
    Severity: Minor
    Found in packages/mongo/collection.js - About 1 day 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 _maybeSetUpReplication has 105 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      _maybeSetUpReplication(name, { _suppressSameNameError = false }) {
        const self = this;
        if (!(self._connection && self._connection.registerStore)) {
          return;
        }
    Severity: Major
    Found in packages/mongo/collection.js - About 4 hrs to fix

      Function Collection has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

      Mongo.Collection = function Collection(name, options) {
        if (!name && name !== null) {
          Meteor._debug(
            'Warning: creating anonymous collection. It will not be ' +
              'saved or synchronized over the network. (Pass null for ' +
      Severity: Minor
      Found in packages/mongo/collection.js - About 4 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 Collection has 92 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Mongo.Collection = function Collection(name, options) {
        if (!name && name !== null) {
          Meteor._debug(
            'Warning: creating anonymous collection. It will not be ' +
              'saved or synchronized over the network. (Pass null for ' +
      Severity: Major
      Found in packages/mongo/collection.js - About 3 hrs to fix

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

              update(msg) {
                var mongoId = MongoID.idParse(msg.id);
                var doc = self._collection._docs.get(mongoId);
        
                //When the server's mergebox is disabled for a collection, the client must gracefully handle it when:
        Severity: Major
        Found in packages/mongo/collection.js - About 2 hrs to fix

          Function insert has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            insert(doc, callback) {
              // Make sure we were passed a document to insert
              if (!doc) {
                throw new Error('insert requires an argument');
              }
          Severity: Minor
          Found in packages/mongo/collection.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 insert has 55 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            insert(doc, callback) {
              // Make sure we were passed a document to insert
              if (!doc) {
                throw new Error('insert requires an argument');
              }
          Severity: Major
          Found in packages/mongo/collection.js - About 2 hrs to fix

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

              update(selector, modifier, ...optionsAndCallback) {
                const callback = popCallbackFromArgs(optionsAndCallback);
            
                // We've already popped off the callback, so we are left with an array
                // of one or zero items
            Severity: Minor
            Found in packages/mongo/collection.js - About 1 hr to fix

              Function update has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                update(selector, modifier, ...optionsAndCallback) {
                  const callback = popCallbackFromArgs(optionsAndCallback);
              
                  // We've already popped off the callback, so we are left with an array
                  // of one or zero items
              Severity: Minor
              Found in packages/mongo/collection.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 createIndex has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                createIndex(index, options) {
                  var self = this;
                  if (!self._collection.createIndex)
                    throw new Error('Can only call createIndex on server collections');
                  // [FIBERS]
              Severity: Minor
              Found in packages/mongo/collection.js - About 1 hr to fix

                Avoid deeply nested control flow statements.
                Open

                          if (keys.length > 0) {
                            var modifier = {};
                            keys.forEach(key => {
                              const value = msg.fields[key];
                              if (EJSON.equals(doc[key], value)) {
                Severity: Major
                Found in packages/mongo/collection.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                            if (!doc) throw new Error('Expected to find a document to change');
                  Severity: Major
                  Found in packages/mongo/collection.js - About 45 mins to fix

                    Function _ensureIndex has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                      _ensureIndex(index, options) {
                        var self = this;
                        if (!self._collection._ensureIndex || !self._collection.createIndex)
                          throw new Error('Can only call createIndex on server collections');
                        if (self._collection.createIndex) {
                    Severity: Minor
                    Found in packages/mongo/collection.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

                    Function createIndex has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                      createIndex(index, options) {
                        var self = this;
                        if (!self._collection.createIndex)
                          throw new Error('Can only call createIndex on server collections');
                        // [FIBERS]
                    Severity: Minor
                    Found in packages/mongo/collection.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