luanpotter/validum

View on GitHub

Showing 34 of 34 total issues

Function convert has 151 lines of code (exceeds 25 allowed). Consider refactoring.
Open

validum.convert = (function() {

    var ConverterException = validum.ConverterException = function(message) {
        this.name = 'ConverterException';
        this.message = message;
Severity: Major
Found in src/main/js/converter.js - About 6 hrs to fix

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

            if (ann.maxCap === PACKAGE + 'Cap.INCLUSIVE') {
                if (number.gt(ann.max)) {
                    errors.push('Numeric.greaterThan{' + ann.max + '}');
                }
            } else if (ann.maxCap === PACKAGE + 'Cap.EXCLUSIVE') {
    Severity: Major
    Found in src/main/js/validators.js and 1 other location - About 4 hrs to fix
    src/main/js/validators.js on lines 33..41

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

    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 (ann.minCap === PACKAGE + 'Cap.INCLUSIVE') {
                if (number.lt(ann.min)) {
                    errors.push('Numeric.smallerThan{' + ann.min + '}');
                }
            } else if (ann.minCap === PACKAGE + 'Cap.EXCLUSIVE') {
    Severity: Major
    Found in src/main/js/validators.js and 1 other location - About 4 hrs to fix
    src/main/js/validators.js on lines 23..31

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

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

    validum.validate = function(rawObj, className) {
        var parseError = function(errors, fieldPrefix, e) {
            if (e instanceof validum.ConverterException) {
                errors.push(fieldPrefix + e.getMessage());
            } else {
    Severity: Major
    Found in src/main/js/validum.js - About 3 hrs to fix

      Function validators has 70 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      validum.validators = (function() {
          var PACKAGE = '@xyz.luan.validum.validations.';
          var map = {};
      
          map[PACKAGE + 'Required'] = function(obj) {
      Severity: Major
      Found in src/main/js/validators.js - About 2 hrs to fix

        Function validation has 67 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            var validation = function(rawObj, className, prefix, errors) {
                var obj;
                try {
                    obj = validum.convert(rawObj, className);
                } catch (e) {
        Severity: Major
        Found in src/main/js/validum.js - About 2 hrs to fix

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

          validum.validate = function(rawObj, className) {
              var parseError = function(errors, fieldPrefix, e) {
                  if (e instanceof validum.ConverterException) {
                      errors.push(fieldPrefix + e.getMessage());
                  } else {
          Severity: Minor
          Found in src/main/js/validum.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 setupNumbers has 60 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              var setupNumbers = function() {
                  var numbers = {};
                  numbers.byte = numbers['java.lang.Byte'] = {
                      'precision' : new Big(1),
                      'min_value' : new Big('-128'),
          Severity: Major
          Found in src/main/js/converter.js - About 2 hrs to fix

            Function convert has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

            validum.convert = (function() {
            
                var ConverterException = validum.ConverterException = function(message) {
                    this.name = 'ConverterException';
                    this.message = message;
            Severity: Minor
            Found in src/main/js/converter.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

                @Retention(RetentionPolicy.RUNTIME)
                @Target({ ElementType.FIELD, ElementType.TYPE_USE })
                @Validation(defaultType = { DefaultTypes.NUMBER })
                public @interface Max {
                    double value();
            Severity: Major
            Found in src/main/java/xyz/luan/validum/validations/Numeric.java and 1 other location - About 1 hr to fix
            src/main/java/xyz/luan/validum/validations/Numeric.java on lines 89..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 111.

            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

                @Retention(RetentionPolicy.RUNTIME)
                @Target({ ElementType.FIELD, ElementType.TYPE_USE })
                @Validation(defaultType = { DefaultTypes.NUMBER })
                public @interface Min {
                    double value();
            Severity: Major
            Found in src/main/java/xyz/luan/validum/validations/Numeric.java and 1 other location - About 1 hr to fix
            src/main/java/xyz/luan/validum/validations/Numeric.java on lines 137..183

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

            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

                map[PACKAGE + 'Numeric.Min'] = function(number, min) {
                    return map[PACKAGE + 'Numeric'](number, {
                        minCap : min.cap,
                        min : min.value,
                        maxCap : PACKAGE + 'Cap.NONE'
            Severity: Major
            Found in src/main/js/validators.js and 1 other location - About 1 hr to fix
            src/main/js/validators.js on lines 63..69

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

            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

                map[PACKAGE + 'Numeric.Max'] = function(number, max) {
                    return map[PACKAGE + 'Numeric'](number, {
                        maxCap : max.cap,
                        max : max.value,
                        minCap : PACKAGE + 'Cap.NONE'
            Severity: Major
            Found in src/main/js/validators.js and 1 other location - About 1 hr to fix
            src/main/js/validators.js on lines 55..61

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

            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

                private static void validateMinCap(Number number, Numeric annotation, List<String> errors) {
                    if (annotation.minCap() == Cap.INCLUSIVE) {
                        if (number.doubleValue() < annotation.min()) {
                            errors.add("Numeric.smallerThan{" + annotation.min() + "}");
                        }
            Severity: Major
            Found in src/main/java/xyz/luan/validum/util/NumberValidation.java and 1 other location - About 1 hr to fix
            src/main/java/xyz/luan/validum/util/NumberValidation.java on lines 43..53

            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

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

                private static void validateMaxCap(Number number, Numeric annotation, List<String> errors) {
                    if (annotation.maxCap() == Cap.INCLUSIVE) {
                        if (number.doubleValue() > annotation.max()) {
                            errors.add("Numeric.greaterThan{" + annotation.max() + "}");
                        }
            Severity: Major
            Found in src/main/java/xyz/luan/validum/util/NumberValidation.java and 1 other location - About 1 hr to fix
            src/main/java/xyz/luan/validum/util/NumberValidation.java on lines 31..41

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

            module.exports = function(grunt) {
            
              grunt.initConfig({
                pkg: grunt.file.readJSON("package.json"),
                bower: { install: { } },
            Severity: Minor
            Found in Gruntfile.js - About 1 hr to fix

              Method validate has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                          @Override
                          public List<String> validate(Number number, Natural annotation) {
                              return NumberValidation.validate(number, new Numeric() {
              
                                  @Override
              Severity: Minor
              Found in src/main/java/xyz/luan/validum/validations/Numeric.java - About 1 hr to fix

                Method validate has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                            @Override
                            public List<String> validate(Number number, Min annotation) {
                                return NumberValidation.validate(number, new Numeric() {
                
                                    @Override
                Severity: Minor
                Found in src/main/java/xyz/luan/validum/validations/Numeric.java - About 1 hr to fix

                  Method validate has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                              @Override
                              public List<String> validate(Number number, Max annotation) {
                                  return NumberValidation.validate(number, new Numeric() {
                  
                                      @Override
                  Severity: Minor
                  Found in src/main/java/xyz/luan/validum/validations/Numeric.java - About 1 hr to fix

                    Method annotationMethodToJson has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private static String annotationMethodToJson(Object value) {
                            final List<Class<?>> numbers = Arrays.asList(byte.class, short.class, int.class, long.class, float.class, double.class);
                            if (numbers.contains(value.getClass()) || Number.class.isAssignableFrom(value.getClass())) {
                                return value.toString();
                            }
                    Severity: Minor
                    Found in src/main/java/xyz/luan/validum/annotation/ToJson.java - 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

                    Severity
                    Category
                    Status
                    Source
                    Language