luanpotter/validum

View on GitHub

Showing 18 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

    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

            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

                    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

                      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

                          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

                          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

                          Severity
                          Category
                          Status
                          Source
                          Language