Skip to content

Commit

Permalink
Enable CheckStyle Plugin in pulsar-config-validation (apache#13676)
Browse files Browse the repository at this point in the history
### Motivation

currently, the `pulsar-config-validation` module is not protected by the `checkstyle-plugin`.

### Modifications

- Enable CheckStyle Plugin
- Fix checkstyle violations
  • Loading branch information
fu-turer authored Jan 11, 2022
1 parent 1a3688c commit adcf554
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
13 changes: 13 additions & 0 deletions pulsar-config-validation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@
<artifactId>spotbugs-maven-plugin</artifactId>
<version>${spotbugs-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>checkstyle</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class ConfigValidation {
private static final Class DEFAULT_ANNOTATION_CLASS = ConfigValidationAnnotations.class;

/**
* Validate the config object with annotations from annotationClass
* Validate the config object with annotations from annotationClass.
* @param config config object
* @param annotationClass class with annotations to use
*/
Expand All @@ -53,7 +53,7 @@ public static void validateConfig(Object config, Class annotationClass) {
}

/**
* Validate the config object with default annotation class
* Validate the config object with default annotation class.
* @param config config object
*/
public static void validateConfig(Object config) {
Expand All @@ -68,7 +68,8 @@ private static void validateField(Field field, Object value, Class annotationCla
processAnnotations(field.getAnnotations(), field.getName(), value, annotationClass);
}

private static void processAnnotations(Annotation[] annotations, String fieldName, Object value, Class annotationClass) {
private static void processAnnotations(Annotation[] annotations, String fieldName, Object value,
Class annotationClass) {
try {
for (Annotation annotation : annotations) {
String type = annotation.annotationType().getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public interface FieldValidator {
/**
* Declares a method for validating configuration values that is nestable.
*/
public static abstract class NestableFieldValidator implements FieldValidator {
public abstract static class NestableFieldValidator implements FieldValidator {
@Override
public void validateField(String name, Object field) throws IllegalArgumentException {
validateField(null, name, field);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
*/
package org.apache.pulsar.config.validation;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* System defined Validator Annotations.
Expand Down

0 comments on commit adcf554

Please sign in to comment.