etnbrd/flx-compiler

View on GitHub
test-set/Moonridge-master/mr-rpc-methods.js

Summary

Maintainability
F
1 wk
Test Coverage

Function expose has a Cognitive Complexity of 153 (exceeds 5 allowed). Consider refactoring.
Open

var expose = function(model, schema, opts) {

  var liveQueries = {};
  var modelName = model.modelName;

Severity: Minor
Found in test-set/Moonridge-master/mr-rpc-methods.js - About 3 days 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 expose has 505 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var expose = function(model, schema, opts) {

  var liveQueries = {};
  var modelName = model.modelName;

Severity: Major
Found in test-set/Moonridge-master/mr-rpc-methods.js - About 2 days to fix

    File mr-rpc-methods.js has 519 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    var _ = require('lodash');
    var Promise = require('bluebird');
    var eventNames = require('./schema-events').eventNames;
    var queryBuilder = require('./query-builder');
    var populateWithClientQuery = require('./utils/populate-doc-util');
    Severity: Major
    Found in test-set/Moonridge-master/mr-rpc-methods.js - About 1 day to fix

      Function syncLogic has 101 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            var syncLogic = function() {
              var cQindex = LQ.getIndexById(doc._id); //index of current doc in the query
      
              if (evName === 'remove' && LQ.docs[cQindex]) {
      
      
      Severity: Major
      Found in test-set/Moonridge-master/mr-rpc-methods.js - About 4 hrs to fix

        Function liveQuery has 74 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            liveQuery: function(clientQuery, LQIndex) {
              if (!opts.checkPermission(this, 'R')) {
                return new Error('You lack a privilege to read this collection');
              }
              def = Promise.defer();
        Severity: Major
        Found in test-set/Moonridge-master/mr-rpc-methods.js - About 2 hrs to fix

          Function update has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                update: function(toUpdate) {
          
                  var def = Promise.defer();
                  var socket = this;
                  var id = toUpdate._id;
          Severity: Minor
          Found in test-set/Moonridge-master/mr-rpc-methods.js - About 1 hr to fix

            Function _distributeChange has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                _distributeChange: function(doc, evName, isInResult) {
                  var self = this;
                  var actuallySend = function() {
                    for (var socketId in self.listeners) {
                      var listener = self.listeners[socketId];
            Severity: Minor
            Found in test-set/Moonridge-master/mr-rpc-methods.js - About 1 hr to fix

              Function accessControlQueryModifier has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                function accessControlQueryModifier(clQuery, schema, userPL, op) { // guards the properties that are marked with higher required permissions for reading
                  var pathPs = schema.pathPermissions;
                  var select;
                  if (clQuery.select) {
                    select = clQuery.select[0];
              Severity: Minor
              Found in test-set/Moonridge-master/mr-rpc-methods.js - About 1 hr to fix

                Function exposeCallback has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  return function exposeCallback(rpcInstance) {
                    var chnlName = 'MR-' + modelName; //prefix MR stands for Moonridge
                    rpcInstance.expose(chnlName, channel, opts.authFn);
                    var chnlSocket = rpcInstance.channels[chnlName]._socket;
                
                
                Severity: Minor
                Found in test-set/Moonridge-master/mr-rpc-methods.js - About 1 hr to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if (cQindex === -1) {
                                        LQ.docs.splice(index, 0, doc);    //insert the document
                                      } else {
                                        if (cQindex !== index) {
                                          if (cQindex < index) {  // if we remove item before, the whole array shifts, so we have to compensate index by 1.
                  Severity: Major
                  Found in test-set/Moonridge-master/mr-rpc-methods.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if (cQindex === -1) {
                                          index = getIndexInSorted(doc, LQ.docs, sortBy);
                                          LQ.docs.splice(index, 0, doc);
                                          if (LQ.indexedByMethods.limit) {
                                            if (LQ.docs.length > LQ.indexedByMethods.limit[0]) {
                    Severity: Major
                    Found in test-set/Moonridge-master/mr-rpc-methods.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if (cQindex === -1) {
                                            LQ.docs.push(doc);
                                            LQ._distributeChange(doc, evName, null);
                                          }
                      Severity: Major
                      Found in test-set/Moonridge-master/mr-rpc-methods.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if (cQindex === -1) {
                                              LQ.docs.push(doc);
                                              LQ._distributeChange(doc, evName, true);    //doc wasn't in the result, but after update is
                        
                                            } else {
                        Severity: Major
                        Found in test-set/Moonridge-master/mr-rpc-methods.js - About 45 mins to fix

                          There are no issues that match your filters.

                          Category
                          Status