neotoma/sync-server

View on GitHub
app/lib/jsonapi/saveRelationshipsToDocument.js

Summary

Maintainability
C
1 day
Test Coverage

Function exports has 87 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function(document, relationships, done) {
  var validate = function(done) {
    validateParams([{
      name: 'document', variable: document, required: true, requiredType: ['object', 'constructor']
    }, {
Severity: Major
Found in app/lib/jsonapi/saveRelationshipsToDocument.js - About 3 hrs to fix

    Function saveRelationshipsToDocument has 73 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      var saveRelationshipsToDocument = function(done) {
        // eslint-disable-next-line global-require
        var Model = require(`app/models/${document.modelId()}`);
        
        async.forEachOf(relationships, function(relationship, relationshipName, done) {
    Severity: Major
    Found in app/lib/jsonapi/saveRelationshipsToDocument.js - About 2 hrs to fix

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

            var addRelationshipToDocument = function(done) {
              var validateAndAddResourceIdentifierObjectRelationship = function(resourceObject, done) {
                var validateResourceIdentifierObject = function(done) {
                  var errors = [];
      
      
      Severity: Minor
      Found in app/lib/jsonapi/saveRelationshipsToDocument.js - About 1 hr to fix

        Function validateAndAddResourceIdentifierObjectRelationship has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                var validateAndAddResourceIdentifierObjectRelationship = function(resourceObject, done) {
                  var validateResourceIdentifierObject = function(done) {
                    var errors = [];
        
                    if (!resourceObject.id) {
        Severity: Minor
        Found in app/lib/jsonapi/saveRelationshipsToDocument.js - About 1 hr to fix

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

                    var validateResourceIdentifierObject = function(done) {
                      var errors = [];
          
                      if (!resourceObject.id) {
                        errors.push(new Error(`Relationship resource identifier object for "${relationshipName}" does not have id property`));
          Severity: Minor
          Found in app/lib/jsonapi/saveRelationshipsToDocument.js - About 1 hr to fix

            Definition for rule 'padding-line-between-statements' was not found
            Open

            var _ = require('app/lib/lodash'),

            For more information visit Source: http://eslint.org/docs/rules/

            There are no issues that match your filters.

            Category
            Status