From 512648ba1e97d38587dd43e7fd52781b4a3cd5c2 Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Sat, 8 Apr 2023 18:05:42 +0200 Subject: [PATCH] Trigger a violation... --- .../tech/picnic/errorprone/bugpatterns/DirectReturn.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/DirectReturn.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/DirectReturn.java index ee0091eeebc..cf7a3678467 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/DirectReturn.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/DirectReturn.java @@ -32,6 +32,9 @@ import com.sun.source.tree.Tree; import com.sun.source.tree.VariableTree; import com.sun.tools.javac.code.Symbol; +import java.nio.charset.StandardCharsets; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; import java.util.List; import java.util.Optional; import tech.picnic.errorprone.bugpatterns.util.MoreASTHelpers; @@ -89,6 +92,11 @@ public Description matchBlock(BlockTree tree, VisitorState state) { .orElse(Description.NO_MATCH); } + private static byte[] md5Hash(String s) throws NoSuchAlgorithmException { + MessageDigest md = MessageDigest.getInstance("MD5"); + return md.digest(s.getBytes(StandardCharsets.UTF_8)); + } + private static Optional tryMatchAssignment(Symbol targetSymbol, Tree tree) { if (tree instanceof ExpressionStatementTree) { return tryMatchAssignment(targetSymbol, ((ExpressionStatementTree) tree).getExpression());