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 = {
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;
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;
`` 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);
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,
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?
- Read upRead up
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;
- Read upRead up
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
Function _runQuery
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
_runQuery: function (options) {
var self = this;
options = options || {};
var newResults, newBuffer;
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))
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)
Avoid deeply nested control flow statements. Open
if (self._phase === PHASE.STEADY) {
self._fetchModifiedDocuments();
}
Avoid deeply nested control flow statements. Open
if (! self._unpublishedBuffer.size()) {
self._needToPollQuery();
}
Avoid deeply nested control flow statements. Open
if (e.name !== "MinimongoError")
throw e;
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
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;
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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;
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
self._multiplexer.onFlush(function () {
_.each(writes, function (w) {
w.committed();
});
});
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76