meteor/meteor

View on GitHub
packages/mongo/oplog_observe_driver.js

Summary

Maintainability
F
4 days
Test Coverage

File oplog_observe_driver.js has 636 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { oplogV2V1Converter } from "./oplog_v2_converter";

var Future = Npm.require('fibers/future');

var PHASE = {
Severity: Major
Found in packages/mongo/oplog_observe_driver.js - About 1 day to fix

    Function _handleDoc has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      _handleDoc: function (id, newDoc) {
        var self = this;
        Meteor._noYieldsAllowed(function () {
          var matchesNow = newDoc && self._matcher.documentMatches(newDoc).result;
    
    
    Severity: Major
    Found in packages/mongo/oplog_observe_driver.js - About 2 hrs to fix

      Function _handleOplogEntrySteadyOrFetching has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _handleOplogEntrySteadyOrFetching: function (op) {
          var self = this;
          Meteor._noYieldsAllowed(function () {
            var id = idForOp(op);
            // If we're already fetching this one, or about to, we can't optimize;
      Severity: Major
      Found in packages/mongo/oplog_observe_driver.js - About 2 hrs to fix

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

        _.extend(OplogObserveDriver.prototype, {
          _addPublished: function (id, doc) {
            var self = this;
            Meteor._noYieldsAllowed(function () {
              var fields = _.clone(doc);
        Severity: Minor
        Found in packages/mongo/oplog_observe_driver.js - About 2 hrs to fix

          Function _fetchModifiedDocuments has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            _fetchModifiedDocuments: function () {
              var self = this;
              Meteor._noYieldsAllowed(function () {
                self._registerPhaseChange(PHASE.FETCHING);
                // Defer, because nothing called from the oplog entry handler may yield,
          Severity: Minor
          Found in packages/mongo/oplog_observe_driver.js - About 1 hr to fix

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

            OplogObserveDriver.cursorSupported = function (cursorDescription, matcher) {
              // First, check the options.
              var options = cursorDescription.options;
            
              // Did the user say no explicitly?
            Severity: Minor
            Found in packages/mongo/oplog_observe_driver.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 _runQuery has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

              _runQuery: function (options) {
                var self = this;
                options = options || {};
                var newResults, newBuffer;
            
            
            Severity: Minor
            Found in packages/mongo/oplog_observe_driver.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 _publishNewResults has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              _publishNewResults: function (newResults, newBuffer) {
                var self = this;
                Meteor._noYieldsAllowed(function () {
            
                  // If the query is limited and there is a buffer, shut down so it doesn't
            Severity: Minor
            Found in packages/mongo/oplog_observe_driver.js - About 1 hr to fix

              Function _runQuery has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                _runQuery: function (options) {
                  var self = this;
                  options = options || {};
                  var newResults, newBuffer;
              
              
              Severity: Minor
              Found in packages/mongo/oplog_observe_driver.js - About 1 hr to fix

                Function _addMatching has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  _addMatching: function (doc) {
                    var self = this;
                    Meteor._noYieldsAllowed(function () {
                      var id = doc._id;
                      if (self._published.has(id))
                Severity: Minor
                Found in packages/mongo/oplog_observe_driver.js - About 1 hr to fix

                  Avoid deeply nested control flow statements.
                  Open

                          } else if (!canDirectlyModifyDoc ||
                                     self._matcher.canBecomeTrueByModifier(op.o) ||
                                     (self._sorter && self._sorter.affectedByModifier(op.o))) {
                            self._needToFetch.set(id, op);
                            if (self._phase === PHASE.STEADY)
                  Severity: Major
                  Found in packages/mongo/oplog_observe_driver.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                if (self._phase === PHASE.STEADY) {
                                  self._fetchModifiedDocuments();
                                }
                    Severity: Major
                    Found in packages/mongo/oplog_observe_driver.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                  if (! self._unpublishedBuffer.size()) {
                                    self._needToPollQuery();
                                  }
                      Severity: Major
                      Found in packages/mongo/oplog_observe_driver.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                    if (e.name !== "MinimongoError")
                                      throw e;
                        Severity: Major
                        Found in packages/mongo/oplog_observe_driver.js - About 45 mins to fix

                          Consider simplifying this complex logical expression.
                          Open

                                  } else if (bufferedBefore) {
                                    oldDoc = self._unpublishedBuffer.get(id);
                                    // remove the old version manually instead of using _removeBuffered so
                                    // we don't trigger the querying immediately.  if we end this block
                                    // with the buffer empty, we will need to trigger the query poll
                          Severity: Major
                          Found in packages/mongo/oplog_observe_driver.js - About 40 mins to fix

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

                                  var maxPublished = (limit && self._published.size() > 0) ?
                                    self._published.get(self._published.maxElementId()) : null;
                            Severity: Minor
                            Found in packages/mongo/oplog_observe_driver.js and 1 other location - About 55 mins to fix
                            packages/mongo/oplog_observe_driver.js on lines 342..344

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

                            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

                                  var maxBuffered = (limit && self._unpublishedBuffer.size() > 0)
                                    ? self._unpublishedBuffer.get(self._unpublishedBuffer.maxElementId())
                                    : null;
                            Severity: Minor
                            Found in packages/mongo/oplog_observe_driver.js and 1 other location - About 55 mins to fix
                            packages/mongo/oplog_observe_driver.js on lines 340..341

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

                            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

                                  self._multiplexer.onFlush(function () {
                                    _.each(writes, function (w) {
                                      w.committed();
                                    });
                                  });
                            Severity: Minor
                            Found in packages/mongo/oplog_observe_driver.js and 1 other location - About 35 mins to fix
                            packages/mongo/polling_observe_driver.js on lines 204..208

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

                            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

                            There are no issues that match your filters.

                            Category
                            Status