Skip to content

Commit

Permalink
Fix finding deprecated methods usage
Browse files Browse the repository at this point in the history
  • Loading branch information
mnhock authored and mnhock committed Jun 11, 2024
1 parent 7bdf0ac commit 07be5dd
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/main/java/com/enofex/taikai/java/Deprecations.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@ public void check(JavaClass item, ConditionEvents events) {
item.getName()))));

item.getMethodCallsFromSelf().stream()
.filter(method -> !method.getOwner().getName().equals(Object.class.getName()))
.filter(method -> !method.getOwner().getName().equals(Enum.class.getName()))
.filter(method -> method.getOwner().isAnnotatedWith(Deprecated.class) ||
method.getOwner().getRawReturnType().isAnnotatedWith(Deprecated.class) ||
method.getOwner().getParameterTypes().stream().anyMatch(Deprecations::isDeprecated)
|| method.getOwner().getCallsFromSelf().stream()
.anyMatch(call -> call.getTarget().isAnnotatedWith(Deprecated.class)))
.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 in class %s uses deprecated APIs", method.getName(),
String.format("Method %s used in class %s is deprecated", method.getName(),
item.getName()))));

item.getConstructorCallsFromSelf().stream()
Expand Down

0 comments on commit 07be5dd

Please sign in to comment.