fogine/json-inspector

View on GitHub

Showing 74 of 74 total issues

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

    eq: function() {
        var filter = inspectRef(this.filter, this.overallData, this.keywordPrefix);
        this.success = this.val == filter;

        transformErrMessage.call(this, function(context) {
Severity: Major
Found in lib/assertions.js and 1 other location - About 3 hrs to fix
lib/assertions.js on lines 736..746

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

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 getExpressInjector has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function getExpressInjector(options) {

    options = options || {};

    // validator definitions
Severity: Major
Found in lib/expressInjectorMiddleware.js - About 2 hrs to fix

    Function like has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        like: function() {
            var keywordAny = (this.keywordPrefix || '') + 'any';
    
            if (_.isPlainObject(this.filter) && this.filter[keywordAny] instanceof Array) {
                for (var i = 0, len = this.filter[keywordAny].length; i < len; i++) {
    Severity: Minor
    Found in lib/assertions.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

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

    function ValidationMultiError(message, errors) {
    
        Error.call(this);
        Error.captureStackTrace(this, this.constructor);
    
    
    Severity: Major
    Found in lib/error/validationMultiError.js and 1 other location - About 2 hrs to fix
    lib/error/validatorError.js on lines 6..15

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

    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

    function ValidatorError(message, errors) {
    
        Error.call(this);
        Error.captureStackTrace(this, this.constructor);
    
    
    Severity: Major
    Found in lib/error/validatorError.js and 1 other location - About 2 hrs to fix
    lib/error/validationMultiError.js on lines 6..15

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

    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 like has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        like: function() {
            var keywordAny = (this.keywordPrefix || '') + 'any';
    
            if (_.isPlainObject(this.filter) && this.filter[keywordAny] instanceof Array) {
                for (var i = 0, len = this.filter[keywordAny].length; i < len; i++) {
    Severity: Minor
    Found in lib/assertions.js - About 1 hr to fix

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

              function transformErr() {
                  transformErrMessage.call(this, function(context) {
      
                      var messageType = minMaxOrBoth({
                          both: 'between.byte',
      Severity: Major
      Found in lib/assertions.js and 1 other location - About 1 hr to fix
      lib/assertions.js on lines 569..580

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

      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 validate has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Validator.prototype.validate = function(data, customSchema, options) {
          var self = this;
          options = options || {};
      
          this.error = null; //TODO ?
      Severity: Minor
      Found in lib/validator.js - About 1 hr to fix

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

                    function transformErr() {
                        transformErrMessage.call(this, function(context) {
        
                            var messageType = minMaxOrBoth({
                                both: 'between.string',
        Severity: Major
        Found in lib/assertions.js and 1 other location - About 1 hr to fix
        lib/assertions.js on lines 184..195

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

        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 getExpressInjector has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        function getExpressInjector(options) {
        
            options = options || {};
        
            // validator definitions
        Severity: Minor
        Found in lib/expressInjectorMiddleware.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 and has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function and(opt) {
            opt = opt || {};
        
            return function() {
                var assertions = this.pool;
        Severity: Minor
        Found in lib/conditions.js - About 1 hr to fix

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

              hasLengthOf: function() {
                  if (this.val instanceof Array) {
                      var defaults = {
                          min: 0,
                          max: undefined
          Severity: Minor
          Found in lib/assertions.js - About 1 hr to fix

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

            function or(opt) {
                opt = opt || {};
            
                return function() {
                    var assertions = this.pool;
            Severity: Minor
            Found in lib/conditions.js - About 1 hr to fix

              Function filterData has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              Validator.prototype.filterData = function(data, filter, callback) {
              
                  if (_.isPlainObject(data)) {
                      var allowedKeys = Object.keys(filter);
                      var dataKeys = Object.keys(data);
              Severity: Minor
              Found in lib/validator.js - About 1 hr to fix

                Function validatorMiddleware has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function validatorMiddleware(req, res, next) {
                
                        var valManager = new ValidatorManager();
                
                        //builds new Validators from validator json schema definitions
                Severity: Minor
                Found in lib/expressInjectorMiddleware.js - About 1 hr to fix

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

                  function Validator(schema, options, valManager) {
                      var defaults = {
                          context              : {},
                          required             : false,
                          sanitizers           : [],
                  Severity: Minor
                  Found in lib/validator.js - About 1 hr to fix

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

                    Validator.prototype.buildArrayCondition = function(prop, data, where, options, parentTreeObj) {
                        var andCondPool = [];
                        var keywordPrefix = options.keywordPrefix;
                        var requiredKeyword = keywordPrefix + 'required';
                        var messageKeyword = keywordPrefix + 'message';
                    Severity: Minor
                    Found in lib/validator.js - About 1 hr to fix

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

                      Validator.prototype.buildArrayCondition = function(prop, data, where, options, parentTreeObj) {
                          var andCondPool = [];
                          var keywordPrefix = options.keywordPrefix;
                          var requiredKeyword = keywordPrefix + 'required';
                          var messageKeyword = keywordPrefix + 'message';
                      Severity: Minor
                      Found in lib/validator.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 is has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          is: function() {
                              if (this.filter === Object || this.filter === isMap[Object]) {
                                  this.success = _.isPlainObject(this.val);
                              } else if (this.filter === Array || this.filter === isMap[Array]) {
                                  this.success = this.val instanceof Array;
                      Severity: Minor
                      Found in lib/assertions.js - About 1 hr to fix

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

                        function recursivelyIterate(entity, callback) {
                        
                            if (typeof entity === 'string'){
                                entity = callback(entity);
                            } else if( _.isPlainObject(entity) ) {
                        Severity: Minor
                        Found in lib/sanitizers.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

                        Severity
                        Category
                        Status
                        Source
                        Language