src/index.js
File index.js
has 319 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
//Dependencies
var fs = require('fs'),
url = require('url'),
path = require('path'),
mongo = require('mongodb'),
Function clear
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
Loader.prototype.clear = function (collectionNames, cb) {
//Normalise arguments
if (arguments.length === 1) { //cb
cb = collectionNames;
collectionNames = null;
Function _loadData
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var _loadData = function (loader, data, cb) {
cb = cb || noop;
var collectionNames = Object.keys(data);
Function _dirToObject
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var _dirToObject = function (dir, cb) {
cb = cb || noop;
// Resolve relative paths if necessary.
dir = path.resolve(basePath, dir);
Function clear
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
Open
Loader.prototype.clear = function (collectionNames, cb) {
//Normalise arguments
if (arguments.length === 1) { //cb
cb = collectionNames;
collectionNames = 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 getCollectionNames
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function getCollectionNames(cb) {
//If collectionNames not passed, clear all of them
if (!collectionNames) {
results.db.listCollections().toArray(function (err, names) {
if (err) {
Function Loader
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
var Loader = function (dbOrUri, options) {
//Try parsing uri
var parts = url.parse(dbOrUri);
//Using connection URI
- 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"