| Conditions | 9 |
| Total Lines | 60 |
| Code Lines | 45 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | package com.hltech.vaunt.validator; |
||
| 12 | public static List<String> validate(JsonSchema consumerSchema, JsonSchema providerSchema) { |
||
| 13 | List<String> errors = new ArrayList<>(); |
||
| 14 | |||
| 15 | if (!equals(consumerSchema.get$ref(), providerSchema.get$ref())) { |
||
| 16 | errors.add(String.format(ERROR_FORMAT, |
||
| 17 | consumerSchema.getId(), |
||
| 18 | "$ref", |
||
| 19 | consumerSchema.get$ref(), |
||
| 20 | providerSchema.get$ref())); |
||
| 21 | } |
||
| 22 | |||
| 23 | if (!equals(consumerSchema.get$schema(), providerSchema.get$schema())) { |
||
| 24 | errors.add(String.format(ERROR_FORMAT, |
||
| 25 | consumerSchema.getId(), |
||
| 26 | "$schema", |
||
| 27 | consumerSchema.get$schema(), |
||
| 28 | providerSchema.get$schema())); |
||
| 29 | } |
||
| 30 | |||
| 31 | if (!arraysEquals(consumerSchema.getDisallow(), providerSchema.getDisallow())) { |
||
| 32 | errors.add(String.format(ERROR_FORMAT, |
||
| 33 | consumerSchema.getId(), |
||
| 34 | "disallow", |
||
| 35 | jsonArraysToString(consumerSchema.getDisallow()), |
||
| 36 | jsonArraysToString(providerSchema.getDisallow()))); |
||
| 37 | } |
||
| 38 | |||
| 39 | if (!arraysEquals(consumerSchema.getExtends(), providerSchema.getExtends())) { |
||
| 40 | errors.add(String.format(ERROR_FORMAT, |
||
| 41 | consumerSchema.getId(), |
||
| 42 | "extends", |
||
| 43 | jsonArraysToString(consumerSchema.getExtends()), |
||
| 44 | jsonArraysToString(providerSchema.getExtends()))); |
||
| 45 | } |
||
| 46 | |||
| 47 | if (isRequired(consumerSchema) && !isRequired(providerSchema)) { |
||
| 48 | errors.add(String.format(ERROR_FORMAT, |
||
| 49 | consumerSchema.getId(), |
||
| 50 | "required", |
||
| 51 | consumerSchema.getRequired(), |
||
| 52 | providerSchema.getRequired())); |
||
| 53 | } |
||
| 54 | |||
| 55 | if (!equals(consumerSchema.getReadonly(), providerSchema.getReadonly())) { |
||
| 56 | errors.add(String.format(ERROR_FORMAT, |
||
| 57 | consumerSchema.getId(), |
||
| 58 | "readonly", |
||
| 59 | consumerSchema.getReadonly(), |
||
| 60 | providerSchema.getReadonly())); |
||
| 61 | } |
||
| 62 | |||
| 63 | if (!equals(consumerSchema.getDescription(), providerSchema.getDescription())) { |
||
| 64 | errors.add(String.format(ERROR_FORMAT, |
||
| 65 | consumerSchema.getId(), |
||
| 66 | "description", |
||
| 67 | consumerSchema.getDescription(), |
||
| 68 | providerSchema.getDescription())); |
||
| 69 | } |
||
| 70 | |||
| 71 | return errors; |
||
| 72 | } |
||
| 122 |