tools/runners/run-mongo.js
Function launchMongo
has a Cognitive Complexity of 114 (exceeds 5 allowed). Consider refactoring. Open
Open
var launchMongo = function(options) {
var onExit = options.onExit || function() {};
var noOplog = false;
var mongod_path = files.pathJoin(
- 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
File run-mongo.js
has 744 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { MongoExitCodes } from '../utils/mongo-exit-codes';
var files = require('../fs/files');
var utils = require('../utils/utils.js');
var fiberHelpers = require('../utils/fiber-helpers.js');
var runLog = require('./run-log.js');
Function launchMongo
has 313 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var launchMongo = function(options) {
var onExit = options.onExit || function() {};
var noOplog = false;
var mongod_path = files.pathJoin(
Function launchOneMongoAndWaitForReadyForInitiate
has 134 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var launchOneMongoAndWaitForReadyForInitiate = function(
dbPath,
port,
portFile
) {
Function initiateReplSetAndWaitForReady
has 86 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var initiateReplSetAndWaitForReady = function () {
try {
// Load mongo so we'll be able to talk to it.
const {MongoClient} = loadIsopackage(
'npm-mongo'
Function _exited
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
_exited: function(code, signal, stderr, detectedErrors) {
var self = this;
self.handle = null;
Function stdoutOnData
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var stdoutOnData = fiberHelpers.bindEnvironment(function(data) {
// note: don't use "else ifs" in this, because 'data' can have multiple
// lines
if (
/replica set config in use/.test(data) ||
Function _exited
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Open
_exited: function(code, signal, stderr, detectedErrors) {
var self = this;
self.handle = null;
- 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 spawnMongod
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function spawnMongod(mongodPath, port, dbPath, replSetName) {
const child_process = require('child_process');
mongodPath = files.convertToOSPath(mongodPath);
dbPath = files.convertToOSPath(dbPath);
Avoid deeply nested control flow statements. Open
Open
if (mongo_pids[found_pid] && (!port || port === found_port)) {
// Note that if the mongo rest interface is enabled the
// initial port + 1000 is also likely to be open.
// So remove the pid so we only match it once.
delete mongo_pids[found_pid];