Skip to content

Commit

Permalink
Align to naming conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
mnhock committed Jun 12, 2024
1 parent 8217497 commit 2355d20
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions src/main/java/com/enofex/taikai/java/Deprecations.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,37 @@ private Deprecations() {
static ArchCondition<JavaClass> notUseDeprecatedAPIs() {
return new ArchCondition<JavaClass>("not use deprecated APIs") {
@Override
public void check(JavaClass item, ConditionEvents events) {
item.getFieldAccessesFromSelf().stream()
public void check(JavaClass javaClass, ConditionEvents events) {
javaClass.getFieldAccessesFromSelf().stream()
.filter(access -> access.getTarget().isAnnotatedWith(Deprecated.class))
.forEach(access -> events.add(SimpleConditionEvent.violated(access.getTarget(),
String.format("Field %s in class %s is deprecated and is being accessed by %s",
access.getTarget().getName(), access.getTarget().getOwner().getName(),
item.getName()))));
javaClass.getName()))));

item.getMethodCallsFromSelf().stream()
javaClass.getMethodCallsFromSelf().stream()
.filter(method -> !method.getTarget().getName().equals(Object.class.getName()))
.filter(method -> !method.getTarget().getName().equals(Enum.class.getName()))
.filter(method -> method.getTarget().isAnnotatedWith(Deprecated.class) ||
method.getTarget().getRawReturnType().isAnnotatedWith(Deprecated.class) ||
method.getTarget().getParameterTypes().stream().anyMatch(Deprecations::isDeprecated))
.forEach(method -> events.add(SimpleConditionEvent.violated(method,
String.format("Method %s used in class %s is deprecated", method.getName(),
item.getName()))));
javaClass.getName()))));

item.getConstructorCallsFromSelf().stream()
javaClass.getConstructorCallsFromSelf().stream()
.filter(constructor -> constructor.getTarget().isAnnotatedWith(Deprecated.class) ||
constructor.getTarget().getParameterTypes().stream()
.anyMatch(Deprecations::isDeprecated))
.forEach(constructor -> events.add(SimpleConditionEvent.violated(constructor,
String.format("Constructor %s in class %s uses deprecated APIs",
constructor.getTarget().getFullName(), item.getName()))));
constructor.getTarget().getFullName(), javaClass.getName()))));

item.getDirectDependenciesFromSelf().stream()
javaClass.getDirectDependenciesFromSelf().stream()
.filter(dependency -> dependency.getTargetClass().isAnnotatedWith(Deprecated.class))
.forEach(dependency -> events.add(
SimpleConditionEvent.violated(dependency.getTargetClass(),
String.format("Class %s depends on deprecated class %s", item.getName(),
String.format("Class %s depends on deprecated class %s", javaClass.getName(),
dependency.getTargetClass().getName()))));
}
}.as("no usage of deprecated APIs");
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/enofex/taikai/java/NamingConfigurer.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ public NamingConfigurer interfacesShouldNotHavePrefixI(Configuration configurati
private static ArchCondition<JavaClass> notBePrefixedWithI() {
return new ArchCondition<>("not be prefixed with I.") {
@Override
public void check(JavaClass clazz, ConditionEvents events) {
if (clazz.getSimpleName().startsWith("I") && Character.isUpperCase(
clazz.getSimpleName().charAt(1))) {
events.add(SimpleConditionEvent.violated(clazz, clazz.getSimpleName()));
public void check(JavaClass javaClass, ConditionEvents events) {
if (javaClass.getSimpleName().startsWith("I") && Character.isUpperCase(
javaClass.getSimpleName().charAt(1))) {
events.add(SimpleConditionEvent.violated(javaClass, javaClass.getSimpleName()));
}
}
};
Expand Down

0 comments on commit 2355d20

Please sign in to comment.