atsid/schematic-js

View on GitHub

Showing 23 of 23 total issues

Function ModelWrapper has 194 lines of code (exceeds 25 allowed). Consider refactoring.
Open

            ModelWrapper = function (schema, obj, validators, options) {

                var basedOn = obj, data = obj || {}, that = this,
                    lastErrors,
                    createSubModels = options && options.createSubModels,
Severity: Major
Found in js/ModelFactory.js - About 7 hrs to fix

    File ModelFactory.js has 292 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /**
     * @class ModelFactory
     * Factory for creating schema-based models. If Backbone exists, the factory
     * will create a schema-based Backbone model.
     */
    Severity: Minor
    Found in js/ModelFactory.js - About 3 hrs to fix

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

                  var factory = new ModelFactory({
                          resolver: function (name) {
                              if (name.indexOf('EmbeddedSchema') > -1) {
                                  return EmbeddedSchema;
                              } else if (name.indexOf('BaseSchema') > -1) {
      Severity: Major
      Found in test/TestModel.js and 2 other locations - About 2 hrs to fix
      test/TestModel.js on lines 134..145
      test/TestModel.js on lines 179..190

      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 82.

      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 3 locations. Consider refactoring.
      Open

                  var factory = new ModelFactory({
                          resolver: function (name) {
                              if (name.indexOf('EmbeddedSchema') > -1) {
                                  return EmbeddedSchema;
                              } else if (name.indexOf('BaseSchema') > -1) {
      Severity: Major
      Found in test/TestModel.js and 2 other locations - About 2 hrs to fix
      test/TestModel.js on lines 114..125
      test/TestModel.js on lines 179..190

      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 82.

      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 3 locations. Consider refactoring.
      Open

                  var factory = new ModelFactory({
                          resolver: function (name) {
                              if (name.indexOf('EmbeddedSchema') > -1) {
                                  return EmbeddedSchema;
                              } else if (name.indexOf('BaseSchema') > -1) {
      Severity: Major
      Found in test/TestModel.js and 2 other locations - About 2 hrs to fix
      test/TestModel.js on lines 114..125
      test/TestModel.js on lines 134..145

      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 82.

      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

      define([
          'external/validate'
      ], function (
          Validator
      ) {
      Severity: Major
      Found in test/Validator.js and 1 other location - About 2 hrs to fix
      examples/Validator.js on lines 1..23

      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 75.

      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 3 locations. Consider refactoring.
      Open

          var findProperty = function (schema, prop) {
                  var ret = schema && schema.properties && schema.properties[prop];
                  if (!ret && schema['extends']) {
                      ret = findProperty(schema['extends'], prop);
                  }
      Severity: Major
      Found in js/plugins/ConditionallyRequiredValidationPlugin.js and 2 other locations - About 2 hrs to fix
      js/plugins/MatchingPropertiesValidationPlugin.js on lines 17..23
      js/plugins/SchemaValidationPlugin.js on lines 16..22

      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 75.

      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 3 locations. Consider refactoring.
      Open

          var findProperty = function (schema, prop) {
                  var ret = schema && schema.properties && schema.properties[prop];
                  if (!ret && schema['extends']) {
                      ret = findProperty(schema['extends'], prop);
                  }
      Severity: Major
      Found in js/plugins/MatchingPropertiesValidationPlugin.js and 2 other locations - About 2 hrs to fix
      js/plugins/ConditionallyRequiredValidationPlugin.js on lines 17..23
      js/plugins/SchemaValidationPlugin.js on lines 16..22

      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 75.

      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

      define([
          'lib/validate'
      ], function (
          Validator
      ) {
      Severity: Major
      Found in examples/Validator.js and 1 other location - About 2 hrs to fix
      test/Validator.js on lines 1..23

      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 75.

      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 3 locations. Consider refactoring.
      Open

          var findProperty = function (schema, prop) {
                  var ret = schema && schema.properties && schema.properties[prop];
                  if (!ret && schema['extends']) {
                      ret = findProperty(schema['extends'], prop);
                  }
      Severity: Major
      Found in js/plugins/SchemaValidationPlugin.js and 2 other locations - About 2 hrs to fix
      js/plugins/ConditionallyRequiredValidationPlugin.js on lines 17..23
      js/plugins/MatchingPropertiesValidationPlugin.js on lines 17..23

      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 75.

      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

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

      module.exports = function (grunt) {
      
          grunt.initConfig({
              jshint: {
                  src: ['js/**/*.js', 'test/**/*.js', 'example/**/*.js', '!node_modules/**/*.*', '!**/lib/**/*.js', '!js/declare.js'],
      Severity: Minor
      Found in Gruntfile.js - About 1 hr to fix

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

            indexOf: function (val, array) {
                'use strict';
                if (!Array.prototype.indexOf) {
                    Array.prototype.indexOf = function (obj, fromIndex) {
                        if (fromIndex === null) {
        Severity: Minor
        Found in js/util.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 module has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            var module = function (config) {
        
                this.message = {code: 0, message: 'Invalid number'};
                util.mixin(this, config);
        
        
        Severity: Minor
        Found in js/plugins/LuhnValidationPlugin.js - About 1 hr to fix

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

                          if (matchValue && (value === matchValue) !== match)  {
                              if (this.message && this.message.message) {
                                  ret.push(this.message);
                              } else {
                                  ret.push(defaultMessage);
          Severity: Major
          Found in js/plugins/MatchingPropertiesValidationPlugin.js and 1 other location - About 1 hr to fix
          js/plugins/ConditionallyRequiredValidationPlugin.js on lines 37..44

          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 57.

          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

                              if (schemaProp && !value) {
                                  if (this.message && this.message.message) {
                                      ret.push(this.message);
                                  }
                                  else {
          Severity: Major
          Found in js/plugins/ConditionallyRequiredValidationPlugin.js and 1 other location - About 1 hr to fix
          js/plugins/MatchingPropertiesValidationPlugin.js on lines 39..45

          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 57.

          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

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

          module.exports = function(config) {
            config.set({
          
              // base path, that will be used to resolve files and exclude
              basePath: '',
          Severity: Minor
          Found in karma.conf.js - About 1 hr to fix

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

                    this.info = function (message, obj, encode) {
                        if (logLevel <= levels.INFO) {
                            doLog('info', message, obj, encode, arguments);
                        }
                    };
            Severity: Major
            Found in js/Logger.js and 4 other locations - About 40 mins to fix
            js/Logger.js on lines 79..83
            js/Logger.js on lines 92..96
            js/Logger.js on lines 118..122
            js/Logger.js on lines 131..135

            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 49.

            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 5 locations. Consider refactoring.
            Open

                    this.error = function (message, obj, encode) {
                        if (logLevel <= levels.ERROR) {
                            doLog('error', message, obj, encode, arguments);
                        }
                    };
            Severity: Major
            Found in js/Logger.js and 4 other locations - About 40 mins to fix
            js/Logger.js on lines 79..83
            js/Logger.js on lines 92..96
            js/Logger.js on lines 105..109
            js/Logger.js on lines 118..122

            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 49.

            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 5 locations. Consider refactoring.
            Open

                    this.warn = function (message, obj, encode) {
                        if (logLevel <= levels.WARN) {
                            doLog('warn', message, obj, encode, arguments);
                        }
                    };
            Severity: Major
            Found in js/Logger.js and 4 other locations - About 40 mins to fix
            js/Logger.js on lines 79..83
            js/Logger.js on lines 92..96
            js/Logger.js on lines 105..109
            js/Logger.js on lines 131..135

            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 49.

            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 5 locations. Consider refactoring.
            Open

                    this.debug = function (message, obj, encode) {
                        if (logLevel <= levels.DEBUG) {
                            doLog('debug', message, obj, encode, arguments);
                        }
                    };
            Severity: Major
            Found in js/Logger.js and 4 other locations - About 40 mins to fix
            js/Logger.js on lines 79..83
            js/Logger.js on lines 105..109
            js/Logger.js on lines 118..122
            js/Logger.js on lines 131..135

            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 49.

            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

            Severity
            Category
            Status
            Source
            Language