oliversalzburg/sanitizr

View on GitHub

Showing 23 of 23 total issues

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

TypeHelper.prototype.omitHidden = function TypeHelper$omitHidden( instance, userClass, clone ) {
    if( !instance ) {
        return instance;
    }
    userClass          = "undefined" === typeof userClass ? TypeInfo.USERCLASS_USER : userClass;
Severity: Major
Found in lib/type/helper.js and 1 other location - About 2 days to fix
lib/type/helper.js on lines 133..184

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

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

TypeHelper.prototype.omitReadOnly = function TypeHelper$omitReadOnly( instance, userClass, clone ) {
    if( !instance ) {
        return instance;
    }
    userClass          = "undefined" === typeof userClass ? TypeInfo.USERCLASS_USER : userClass;
Severity: Major
Found in lib/type/helper.js and 1 other location - About 2 days to fix
lib/type/helper.js on lines 73..124

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

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

TypeInfo.prototype.isConcealed = function TypeInfo$isConcealed( propertyName, accessClass ) {
    accessClass = ( "undefined" === typeof accessClass ) ? TypeInfo.USERCLASS_USER : accessClass;
    return (
        this.typeInfo.hasOwnProperty( propertyName ) &&
        this.typeInfo[ propertyName ].hasOwnProperty( accessClass ) &&
Severity: Major
Found in lib/type/info.js and 1 other location - About 4 hrs to fix
lib/type/info.js on lines 91..98

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

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

TypeInfo.prototype.isHidden = function TypeInfo$isHidden( propertyName, accessClass ) {
    accessClass = ( "undefined" === typeof accessClass ) ? TypeInfo.USERCLASS_USER : accessClass;
    return (
        this.typeInfo.hasOwnProperty( propertyName ) &&
        this.typeInfo[ propertyName ].hasOwnProperty( accessClass ) &&
Severity: Major
Found in lib/type/info.js and 1 other location - About 4 hrs to fix
lib/type/info.js on lines 129..136

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

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 TypeHelper$conceal has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

TypeHelper.prototype.conceal = function TypeHelper$conceal( instance, userClass, clone, concealWith ) {
    if( !instance ) {
        return instance;
    }
    userClass = "undefined" === typeof userClass ? TypeInfo.USERCLASS_USER : userClass;
Severity: Minor
Found in lib/type/helper.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 TypeHelper$omitHidden has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

TypeHelper.prototype.omitHidden = function TypeHelper$omitHidden( instance, userClass, clone ) {
    if( !instance ) {
        return instance;
    }
    userClass          = "undefined" === typeof userClass ? TypeInfo.USERCLASS_USER : userClass;
Severity: Minor
Found in lib/type/helper.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 TypeHelper$omitReadOnly has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

TypeHelper.prototype.omitReadOnly = function TypeHelper$omitReadOnly( instance, userClass, clone ) {
    if( !instance ) {
        return instance;
    }
    userClass          = "undefined" === typeof userClass ? TypeInfo.USERCLASS_USER : userClass;
Severity: Minor
Found in lib/type/helper.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 exports has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function( grunt ) {

    // Project configuration.
    grunt.initConfig(
        {
Severity: Major
Found in Gruntfile.js - About 2 hrs to fix

    Function TypeHelper$conceal has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    TypeHelper.prototype.conceal = function TypeHelper$conceal( instance, userClass, clone, concealWith ) {
        if( !instance ) {
            return instance;
        }
        userClass = "undefined" === typeof userClass ? TypeInfo.USERCLASS_USER : userClass;
    Severity: Minor
    Found in lib/type/helper.js - About 1 hr to fix

      Function TypeHelper$omitHidden has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      TypeHelper.prototype.omitHidden = function TypeHelper$omitHidden( instance, userClass, clone ) {
          if( !instance ) {
              return instance;
          }
          userClass          = "undefined" === typeof userClass ? TypeInfo.USERCLASS_USER : userClass;
      Severity: Minor
      Found in lib/type/helper.js - About 1 hr to fix

        Function TypeHelper$omitReadOnly has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        TypeHelper.prototype.omitReadOnly = function TypeHelper$omitReadOnly( instance, userClass, clone ) {
            if( !instance ) {
                return instance;
            }
            userClass          = "undefined" === typeof userClass ? TypeInfo.USERCLASS_USER : userClass;
        Severity: Minor
        Found in lib/type/helper.js - About 1 hr to fix

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

          TypeHelper.prototype.omitNull = function TypeHelper$omitNull( instance, clone ) {
              if( !instance ) {
                  return instance;
              }
              var targetInstance = clone ? _.clone( instance ) : instance;
          Severity: Minor
          Found in lib/type/helper.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 assemble has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function assemble( typeName, collectionName, typeDescription ) {
              // Only import mongoose if this module is actually used.
              var mongoose = require( "mongoose" );
              var Schema   = mongoose.Schema;
          
          
          Severity: Minor
          Found in lib/type/factory.js - About 1 hr to fix

            Function TypeHelper$reduceComplex has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            TypeHelper.prototype.reduceComplex = function TypeHelper$reduceComplex( instance, clone ) {
                if( !instance ) {
                    return instance;
                }
                var targetInstance = clone ? _.clone( instance ) : instance;
            Severity: Minor
            Found in lib/type/helper.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 internalDecorate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            function internalDecorate( typeDescription, propertyName, userClass, attribute ) {
                if( propertyName && Array.isArray( typeDescription[ propertyName ] ) ) {
                    internalDecorate( typeDescription[ propertyName ], 0, userClass, attribute );
                    return;
                }
            Severity: Minor
            Found in lib/type/decorator.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 TypeHelper$omitNull has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            TypeHelper.prototype.omitNull = function TypeHelper$omitNull( instance, clone ) {
                if( !instance ) {
                    return instance;
                }
                var targetInstance = clone ? _.clone( instance ) : instance;
            Severity: Minor
            Found in lib/type/helper.js - About 1 hr to fix

              Function TypeDecorator$decorateComposite has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              TypeDecorator.prototype.decorateComposite = function TypeDecorator$decorateComposite( compositeName, userClass, attribute ) {
                  // Refuse to decorate existing properties on the type, unless it's a composite
                  if( this.typeDescription[ compositeName ] ) {
                      if( !this.typeDescription.__COMPOSITES__ ||
                          ( this.typeDescription.__COMPOSITES__ && -1 === this.typeDescription.__COMPOSITES__.indexOf( compositeName ) ) ) {
              Severity: Minor
              Found in lib/type/decorator.js - About 1 hr to fix

                Function TypeHelper$reduceComplex has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                TypeHelper.prototype.reduceComplex = function TypeHelper$reduceComplex( instance, clone ) {
                    if( !instance ) {
                        return instance;
                    }
                    var targetInstance = clone ? _.clone( instance ) : instance;
                Severity: Minor
                Found in lib/type/helper.js - About 1 hr to fix

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

                      if( Array.isArray( instance ) ) {
                          var self = this;
                  
                          //noinspection UnnecessaryLocalVariableJS
                          var results = instance.map( function withComplexReduced( element ) {
                  Severity: Minor
                  Found in lib/type/helper.js and 1 other location - About 55 mins to fix
                  lib/type/helper.js on lines 31..39

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

                  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( Array.isArray( instance ) ) {
                          var self = this;
                  
                          //noinspection UnnecessaryLocalVariableJS
                          var results = instance.map( function withoutNullValues( element ) {
                  Severity: Minor
                  Found in lib/type/helper.js and 1 other location - About 55 mins to fix
                  lib/type/helper.js on lines 261..269

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

                  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