luanpotter/validum

View on GitHub

Showing 34 of 34 total issues

Method validate has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    private List<String> validate(List<String> errors, String errorPrefix, Object obj, TypedClass<?> clazz, List<Annotation> globalValidations) {
Severity: Minor
Found in src/main/java/xyz/luan/validum/Validator.java - About 35 mins to fix

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

            numbers.float = numbers['java.lang.Float'] = {
                'precision' : new Big('1.4E-45'),
                'min_value' : new Big('-3.4028235E38'),
                'max_value' : new Big('3.4028235E38')
            };
    Severity: Minor
    Found in src/main/js/converter.js and 1 other location - About 35 mins to fix
    src/main/js/converter.js on lines 42..46

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

    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

            numbers.double = numbers['java.lang.Double'] = {
                'precision' : new Big('-4.9E-324'),
                'min_value' : new Big('-1.7976931348623157E308'),
                'max_value' : new Big('1.7976931348623157E308')
            };
    Severity: Minor
    Found in src/main/js/converter.js and 1 other location - About 35 mins to fix
    src/main/js/converter.js on lines 37..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 47.

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

            numbers.int = numbers['java.lang.Integer'] = {
                'precision' : new Big(1),
                'min_value' : new Big('-2147483648'),
                'max_value' : new Big('2147483647')
            };
    Severity: Major
    Found in src/main/js/converter.js and 3 other locations - About 35 mins to fix
    src/main/js/converter.js on lines 17..21
    src/main/js/converter.js on lines 22..26
    src/main/js/converter.js on lines 32..36

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

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

            numbers.long = numbers['java.lang.Long'] = {
                'precision' : new Big(1),
                'min_value' : new Big('-9223372036854775808'),
                'max_value' : new Big('9223372036854775807')
            };
    Severity: Major
    Found in src/main/js/converter.js and 3 other locations - About 35 mins to fix
    src/main/js/converter.js on lines 17..21
    src/main/js/converter.js on lines 22..26
    src/main/js/converter.js on lines 27..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 47.

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

            numbers.byte = numbers['java.lang.Byte'] = {
                'precision' : new Big(1),
                'min_value' : new Big('-128'),
                'max_value' : new Big('127')
            };
    Severity: Major
    Found in src/main/js/converter.js and 3 other locations - About 35 mins to fix
    src/main/js/converter.js on lines 22..26
    src/main/js/converter.js on lines 27..31
    src/main/js/converter.js on lines 32..36

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

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

            numbers.short = numbers['java.lang.Short'] = {
                'precision' : new Big(1),
                'min_value' : new Big('-32768'),
                'max_value' : new Big('32767')
            };
    Severity: Major
    Found in src/main/js/converter.js and 3 other locations - About 35 mins to fix
    src/main/js/converter.js on lines 17..21
    src/main/js/converter.js on lines 27..31
    src/main/js/converter.js on lines 32..36

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

    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 (annotation.minLength() != -1 && size < annotation.minLength()) {
                    errors.add("Array.lengthBelow{" + annotation.minLength() + "}");
                }
    Severity: Minor
    Found in src/main/java/xyz/luan/validum/validations/Array.java and 1 other location - About 30 mins to fix
    src/main/java/xyz/luan/validum/validations/Array.java on lines 41..43

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

    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 (annotation.maxLength() != -1 && size > annotation.maxLength()) {
                    errors.add("Array.lengthAbove{" + annotation.maxLength() + "}");
                }
    Severity: Minor
    Found in src/main/java/xyz/luan/validum/validations/Array.java and 1 other location - About 30 mins to fix
    src/main/java/xyz/luan/validum/validations/Array.java on lines 37..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 42.

    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

    Avoid too many return statements within this method.
    Open

                return annotationToJson((Annotation) value);
    Severity: Major
    Found in src/main/java/xyz/luan/validum/annotation/ToJson.java - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                  return arrayToJson(value);
      Severity: Major
      Found in src/main/java/xyz/luan/validum/annotation/ToJson.java - About 30 mins to fix

        Method validateMinCap has a Cognitive Complexity of 6 (exceeds 5 allowed). 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: Minor
        Found in src/main/java/xyz/luan/validum/util/NumberValidation.java - About 25 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method validateMaxCap has a Cognitive Complexity of 6 (exceeds 5 allowed). 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: Minor
        Found in src/main/java/xyz/luan/validum/util/NumberValidation.java - About 25 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

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

        validum._.each = function(object, callback) {
            var key;
            for (key in object) {
                if (object.hasOwnProperty(key)) {
                    if (callback(key, object[key])) {
        Severity: Minor
        Found in src/main/js/common.js - About 25 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Severity
        Category
        Status
        Source
        Language