luislobo/lobo-mongodb-fixtures

View on GitHub
src/index.js

Summary

Maintainability
D
1 day
Test Coverage

File index.js has 319 lines of code (exceeds 250 allowed). Consider refactoring.
Open

//Dependencies
var fs = require('fs'),
  url = require('url'),
  path = require('path'),
  mongo = require('mongodb'),
Severity: Minor
Found in src/index.js - About 3 hrs to fix

    Function clear has 69 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Loader.prototype.clear = function (collectionNames, cb) {
      //Normalise arguments
      if (arguments.length === 1) { //cb
        cb = collectionNames;
        collectionNames = null;
    Severity: Major
    Found in src/index.js - About 2 hrs to fix

      Function _loadData has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var _loadData = function (loader, data, cb) {
        cb = cb || noop;
      
        var collectionNames = Object.keys(data);
      
      
      Severity: Minor
      Found in src/index.js - About 1 hr to fix

        Function _dirToObject has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        var _dirToObject = function (dir, cb) {
          cb = cb || noop;
        
          // Resolve relative paths if necessary.
          dir = path.resolve(basePath, dir);
        Severity: Minor
        Found in src/index.js - About 1 hr to fix

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

          Loader.prototype.clear = function (collectionNames, cb) {
            //Normalise arguments
            if (arguments.length === 1) { //cb
              cb = collectionNames;
              collectionNames = null;
          Severity: Minor
          Found in src/index.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 getCollectionNames has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function getCollectionNames(cb) {
                //If collectionNames not passed, clear all of them
                if (!collectionNames) {
                  results.db.listCollections().toArray(function (err, names) {
                    if (err) {
          Severity: Minor
          Found in src/index.js - About 1 hr to fix

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

            var Loader = function (dbOrUri, options) {
              //Try parsing uri
              var parts = url.parse(dbOrUri);
            
              //Using connection URI
            Severity: Minor
            Found in src/index.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