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;
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 {
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) {
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) {
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 {
- Read upRead up
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'),
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;
- Read upRead up
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: { } },
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
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
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
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();
}
- Read upRead up
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) {
Avoid too many return
statements within this method. Open
return annotationToJson((Annotation) value);
Avoid too many return
statements within this method. Open
return arrayToJson(value);
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() + "}");
}
- Read upRead up
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])) {
- Read upRead up
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() + "}");
}
- Read upRead up
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"