Skip to content

Commit

Permalink
Split method to fix critical sonar issue
Browse files Browse the repository at this point in the history
  • Loading branch information
timyates committed Feb 12, 2024
1 parent eb6e0c4 commit b092bd8
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,21 @@ public void visitClass(ClassElement element, VisitorContext context) {
if (annType != null && element.hasStereotype(annType)) {
List<AnnotationValue<? extends Annotation>> values = element.getAnnotationValuesByType(annType);
if (!values.isEmpty()) {
for (AnnotationValue<?> av : values) {
AnnotationClassValue<?>[] acv = av.annotationClassValues(AnnotationMetadata.VALUE_MEMBER);
for (AnnotationClassValue<?> a : acv) {
String className = a.getName();
context.getClassElement(className).ifPresent(typeToImport -> {
if (typeToImport.isPublic()) {
handleImport(element, context, typeToImport);
}
});
visitValues(element, context, values);
}
}
}

private void visitValues(ClassElement element, VisitorContext context, List<AnnotationValue<? extends Annotation>> values) {
for (AnnotationValue<?> av : values) {
AnnotationClassValue<?>[] acv = av.annotationClassValues(AnnotationMetadata.VALUE_MEMBER);
for (AnnotationClassValue<?> a : acv) {
String className = a.getName();
context.getClassElement(className).ifPresent(typeToImport -> {
if (typeToImport.isPublic()) {
handleImport(element, context, typeToImport);
}
}
});
}
}
}
Expand Down

0 comments on commit b092bd8

Please sign in to comment.