archangel-irk/storage

View on GitHub
lib/document.js

Summary

Maintainability
F
2 wks
Test Coverage

File document.js has 1062 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

/*!
 * Module dependencies.
 */
Severity: Major
Found in lib/document.js - About 2 days to fix

    Function set has a Cognitive Complexity of 76 (exceeds 5 allowed). Consider refactoring.
    Open

    Document.prototype.set = function (path, val, type, options) {
      if (type && 'Object' === utils.getFunctionName(type.constructor)) {
        options = type;
        type = undefined;
      }
    Severity: Minor
    Found in lib/document.js - About 1 day 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 $toObject has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

    Document.prototype.$toObject = function(options, json) {
      var defaultOptions = { transform: true, json: json };
    
      if (options && options.depopulate && !options._skipDepopulateTopLevel && this.$__.wasPopulated) {
        // populated paths that we set to a document
    Severity: Minor
    Found in lib/document.js - About 6 hrs 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 set has 137 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Document.prototype.set = function (path, val, type, options) {
      if (type && 'Object' === utils.getFunctionName(type.constructor)) {
        options = type;
        type = undefined;
      }
    Severity: Major
    Found in lib/document.js - About 5 hrs to fix

      Function Document has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
      Open

      function Document ( data, collectionName, schema, fields, init ){
        if ( !(this instanceof Document) ) {
          return new Document( data, collectionName, schema, fields, init );
        }
      
      
      Severity: Minor
      Found in lib/document.js - About 4 hrs 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 init has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

      function init (self, obj, doc, prefix) {
        prefix = prefix || '';
      
        var keys = Object.keys(obj)
          , len = keys.length
      Severity: Minor
      Found in lib/document.js - About 3 hrs 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 Document has 95 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function Document ( data, collectionName, schema, fields, init ){
        if ( !(this instanceof Document) ) {
          return new Document( data, collectionName, schema, fields, init );
        }
      
      
      Severity: Major
      Found in lib/document.js - About 3 hrs to fix

        Function isSelected has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

        Document.prototype.isSelected = function isSelected (path) {
          if (this.$__.selected) {
        
            if ('_id' === path) {
              return 0 !== this.$__.selected._id;
        Severity: Minor
        Found in lib/document.js - About 3 hrs 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 defineProp has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

        function defineProp (self, prop, subprops, prototype, prefix, keys) {
          prefix = prefix || '';
          var path = (prefix ? prefix + '.' : '') + prop;
        
          if (subprops) {
        Severity: Minor
        Found in lib/document.js - About 2 hrs 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 $__buildDoc has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

        Document.prototype.$__buildDoc = function ( obj, skipId ) {
          var doc = {}
            , self = this;
        
          var paths = Object.keys( this.schema.paths )
        Severity: Minor
        Found in lib/document.js - About 2 hrs 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 $__handleSave has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

        Document.prototype.$__handleSave = function(){
          // Получаем ресурс коллекции, куда будем сохранять данные
          var resource;
          if ( this.collection ){
            resource = this.collection.api;
        Severity: Minor
        Found in lib/document.js - About 2 hrs 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 $toObject has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Document.prototype.$toObject = function(options, json) {
          var defaultOptions = { transform: true, json: json };
        
          if (options && options.depopulate && !options._skipDepopulateTopLevel && this.$__.wasPopulated) {
            // populated paths that we set to a document
        Severity: Major
        Found in lib/document.js - About 2 hrs to fix

          Function validate has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Document.prototype.validate = function (cb) {
            var self = this;
          
            // only validate required fields when necessary
            var paths = Object.keys(this.$__.activePaths.states.require).filter(function (path) {
          Severity: Major
          Found in lib/document.js - About 2 hrs to fix

            Consider simplifying this complex logical expression.
            Open

                    if (null != path[key]
                        // need to know if plain object - no Buffer, ObjectId, ref, etc
                        && _.isPlainObject(path[key])
                        && ( !path[key].constructor || 'Object' === utils.getFunctionName(path[key].constructor) )
                        && 'virtual' !== pathtype
            Severity: Critical
            Found in lib/document.js - About 2 hrs to fix

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

              function defineProp (self, prop, subprops, prototype, prefix, keys) {
                prefix = prefix || '';
                var path = (prefix ? prefix + '.' : '') + prop;
              
                if (subprops) {
              Severity: Minor
              Found in lib/document.js - About 1 hr to fix

                Function $__handleSave has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                Document.prototype.$__handleSave = function(){
                  // Получаем ресурс коллекции, куда будем сохранять данные
                  var resource;
                  if ( this.collection ){
                    resource = this.collection.api;
                Severity: Minor
                Found in lib/document.js - About 1 hr to fix

                  Function validateSync has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  Document.prototype.validateSync = function () {
                    var self = this;
                  
                    // only validate required fields when necessary
                    var paths = Object.keys(this.$__.activePaths.states.require).filter(function (path) {
                  Severity: Minor
                  Found in lib/document.js - About 1 hr to fix

                    Function validateSync has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                    Document.prototype.validateSync = function () {
                      var self = this;
                    
                      // only validate required fields when necessary
                      var paths = Object.keys(this.$__.activePaths.states.require).filter(function (path) {
                    Severity: Minor
                    Found in lib/document.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 save has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    Document.prototype.save = function ( done ) {
                      var self = this;
                      var finalPromise = new Deferred().done( done );
                    
                      // Сохранять документ можно только если он находится в коллекции
                    Severity: Minor
                    Found in lib/document.js - About 1 hr to fix

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

                      function init (self, obj, doc, prefix) {
                        prefix = prefix || '';
                      
                        var keys = Object.keys(obj)
                          , len = keys.length
                      Severity: Minor
                      Found in lib/document.js - About 1 hr to fix

                        Function $__getAllSubdocs has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                        Open

                        Document.prototype.$__getAllSubdocs = function () {
                          DocumentArray || (DocumentArray = require('./types/documentarray'));
                          Embedded = Embedded || require('./types/embedded');
                        
                          function docReducer(seed, path) {
                        Severity: Minor
                        Found in lib/document.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 $__set has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                        Open

                        Document.prototype.$__set = function ( pathToMark, path, constructing, parts, schema, val, priorVal ) {
                          var shouldModify = this.$__shouldModify.apply(this, arguments);
                        
                          if (shouldModify) {
                            this.markModified(pathToMark, val);
                        Severity: Minor
                        Found in lib/document.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 isSelected has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        Document.prototype.isSelected = function isSelected (path) {
                          if (this.$__.selected) {
                        
                            if ('_id' === path) {
                              return 0 !== this.$__.selected._id;
                        Severity: Minor
                        Found in lib/document.js - About 1 hr to fix

                          Function $__buildDoc has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          Document.prototype.$__buildDoc = function ( obj, skipId ) {
                            var doc = {}
                              , self = this;
                          
                            var paths = Object.keys( this.schema.paths )
                          Severity: Minor
                          Found in lib/document.js - About 1 hr to fix

                            Function validate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                            Document.prototype.validate = function (cb) {
                              var self = this;
                            
                              // only validate required fields when necessary
                              var paths = Object.keys(this.$__.activePaths.states.require).filter(function (path) {
                            Severity: Minor
                            Found in lib/document.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 empty has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            Document.prototype.empty = function(){
                              var doc = this
                                , self = this
                                , paths = Object.keys( this.schema.paths )
                                , plen = paths.length
                            Severity: Minor
                            Found in lib/document.js - About 1 hr to fix

                              Function populated has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                              Open

                              Document.prototype.populated = function( path, val, options ){
                                // val and options are internal
                              
                                //TODO: доделать эту проверку, она должна опираться не на $__.populated, а на то, что наш объект имеет родителя
                                // и потом уже выставлять свойство populated == true
                              Severity: Minor
                              Found in lib/document.js - About 55 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

                              Function empty has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                              Open

                              Document.prototype.empty = function(){
                                var doc = this
                                  , self = this
                                  , paths = Object.keys( this.schema.paths )
                                  , plen = paths.length
                              Severity: Minor
                              Found in lib/document.js - About 55 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

                              Function $__shouldModify has 7 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  pathToMark, path, constructing, parts, schema, val, priorVal) {
                              Severity: Major
                              Found in lib/document.js - About 50 mins to fix

                                Function $__set has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                Document.prototype.$__set = function ( pathToMark, path, constructing, parts, schema, val, priorVal ) {
                                Severity: Major
                                Found in lib/document.js - About 50 mins to fix

                                  Function applyGetters has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  function applyGetters (self, json, type, options) {
                                    var schema = self.schema
                                      , paths = Object.keys(schema[type])
                                      , i = paths.length
                                      , path;
                                  Severity: Minor
                                  Found in lib/document.js - About 45 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

                                  Avoid deeply nested control flow statements.
                                  Open

                                            if ('real' === pathtype || 'virtual' === pathtype) {
                                              this.set(prefix + key, path[key], constructing);
                                  
                                            } else if ('throw' === strict) {
                                              throw new Error('Field `' + key + '` is not in schema.');
                                  Severity: Major
                                  Found in lib/document.js - About 45 mins to fix

                                    Function defineProp has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                    function defineProp (self, prop, subprops, prototype, prefix, keys) {
                                    Severity: Minor
                                    Found in lib/document.js - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                              } else if (undefined !== path[key]) {
                                                this.set(prefix + key, path[key], constructing);
                                              }
                                      Severity: Major
                                      Found in lib/document.js - About 45 mins to fix

                                        Function Document has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                        Open

                                        function Document ( data, collectionName, schema, fields, init ){
                                        Severity: Minor
                                        Found in lib/document.js - About 35 mins to fix

                                          Function minimize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                          function minimize (obj) {
                                            var keys = Object.keys(obj)
                                              , i = keys.length
                                              , hasKeys
                                              , key
                                          Severity: Minor
                                          Found in lib/document.js - About 35 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

                                          Avoid too many return statements within this function.
                                          Open

                                            return false;
                                          Severity: Major
                                          Found in lib/document.js - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                return ! inclusive;
                                            Severity: Major
                                            Found in lib/document.js - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                      return inclusive;
                                              Severity: Major
                                              Found in lib/document.js - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                    return this.$__.populated[path];
                                                Severity: Major
                                                Found in lib/document.js - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                    return true;
                                                  Severity: Major
                                                  Found in lib/document.js - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                      return this;
                                                    Severity: Major
                                                    Found in lib/document.js - About 30 mins to fix

                                                      Avoid too many return statements within this function.
                                                      Open

                                                          return this;
                                                      Severity: Major
                                                      Found in lib/document.js - About 30 mins to fix

                                                        Avoid too many return statements within this function.
                                                        Open

                                                          return val;
                                                        Severity: Major
                                                        Found in lib/document.js - About 30 mins to fix

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

                                                          Document.prototype.get = function (path, type) {
                                                            var adhocs;
                                                            if (type) {
                                                              adhocs = this.$__.adhocPaths || (this.$__.adhocPaths = {});
                                                              adhocs[path] = Schema.interpretAsType(path, type);
                                                          Severity: Minor
                                                          Found in lib/document.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

                                                          Identical blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                            for (var i = 0; i < paths.length; ++i) {
                                                              var path = paths[i];
                                                              var val = self.getValue(path);
                                                              if (val instanceof Array && !Buffer.isBuffer(val) &&
                                                                  !val.isStorageDocumentArray) {
                                                          Severity: Major
                                                          Found in lib/document.js and 1 other location - About 5 hrs to fix
                                                          lib/document.js on lines 953..963

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 144.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Identical blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                            for (var i = 0; i < paths.length; ++i) {
                                                              var path = paths[i];
                                                              var val = self.getValue(path);
                                                              if (val instanceof Array && !Buffer.isBuffer(val) &&
                                                                  !val.isStorageDocumentArray) {
                                                          Severity: Major
                                                          Found in lib/document.js and 1 other location - About 5 hrs to fix
                                                          lib/document.js on lines 1037..1047

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 144.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Identical blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                            var paths = Object.keys(this.$__.activePaths.states.require).filter(function (path) {
                                                              if (!self.isSelected(path) && !self.isModified(path)) return false;
                                                              return true;
                                                            });
                                                          Severity: Major
                                                          Found in lib/document.js and 1 other location - About 2 hrs to fix
                                                          lib/document.js on lines 934..937

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 81.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Identical blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                            var paths = Object.keys(this.$__.activePaths.states.require).filter(function (path) {
                                                              if (!self.isSelected(path) && !self.isModified(path)) return false;
                                                              return true;
                                                            });
                                                          Severity: Major
                                                          Found in lib/document.js and 1 other location - About 2 hrs to fix
                                                          lib/document.js on lines 1024..1027

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 81.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                              if (json) {
                                                                options = this.schema.options.toJSON ?
                                                                    clone(this.schema.options.toJSON) :
                                                                {};
                                                                options.json = true;
                                                          Severity: Major
                                                          Found in lib/document.js and 1 other location - About 1 hr to fix
                                                          lib/document.js on lines 1717..1723

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 67.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                              } else {
                                                                options = this.schema.options.toObject ?
                                                                    clone(this.schema.options.toObject) :
                                                                {};
                                                                options.json = false;
                                                          Severity: Major
                                                          Found in lib/document.js and 1 other location - About 1 hr to fix
                                                          lib/document.js on lines 1711..1717

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 67.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                            if (type) {
                                                              adhocs = this.$__.adhocPaths || (this.$__.adhocPaths = {});
                                                              adhocs[path] = Schema.interpretAsType(path, type);
                                                            }
                                                          Severity: Major
                                                          Found in lib/document.js and 1 other location - About 1 hr to fix
                                                          lib/document.js on lines 407..410

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 59.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                            if (adhoc) {
                                                              adhocs = this.$__.adhocPaths || (this.$__.adhocPaths = {});
                                                              adhocs[path] = Schema.interpretAsType(path, type);
                                                            }
                                                          Severity: Major
                                                          Found in lib/document.js and 1 other location - About 1 hr to fix
                                                          lib/document.js on lines 715..718

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 59.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                          Document.prototype.isInit = function (path) {
                                                            return (path in this.$__.activePaths.states.init);
                                                          };
                                                          Severity: Minor
                                                          Found in lib/document.js and 1 other location - About 40 mins to fix
                                                          lib/document.js on lines 832..834

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 48.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          Similar blocks of code found in 2 locations. Consider refactoring.
                                                          Open

                                                          Document.prototype.isDirectModified = function (path) {
                                                            return (path in this.$__.activePaths.states.modify);
                                                          };
                                                          Severity: Minor
                                                          Found in lib/document.js and 1 other location - About 40 mins to fix
                                                          lib/document.js on lines 843..845

                                                          Duplicated Code

                                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                          Tuning

                                                          This issue has a mass of 48.

                                                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                          Refactorings

                                                          Further Reading

                                                          There are no issues that match your filters.

                                                          Category
                                                          Status