From ec1ce7eaea39afb7965c23668343848323673e8b Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Mon, 13 Nov 2023 08:25:17 +0100 Subject: [PATCH] Resolve some SonarCloud warnings --- .../bugpatterns/ErrorProneRuntimeClasspath.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ErrorProneRuntimeClasspath.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ErrorProneRuntimeClasspath.java index cafac9cf9ac..205a9396284 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ErrorProneRuntimeClasspath.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/ErrorProneRuntimeClasspath.java @@ -116,7 +116,7 @@ private static SuggestedFix suggestClassReference( original, identifier + ".class.getCanonicalName()" - + (suffix.isEmpty() ? "" : " + " + Constants.format(suffix))) + + (suffix.isEmpty() ? "" : (" + " + Constants.format(suffix)))) .build(); } @@ -136,8 +136,8 @@ public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState /* * This class reference may not be safe; suggest using a string literal instead. (Note that - * dropping the type reference may make the associated import statement (if any) obsolete; - * dropping such imports is left to Error Prone's `RemoveUnusedImports` check.) + * dropping the type reference may make the associated import statement (if any) obsolete. + * Dropping such imports is left to Error Prone's `RemoveUnusedImports` check.) */ return buildDescription(tree) .setMessage("This type may not be on the runtime classpath; use a string literal instead") @@ -150,7 +150,9 @@ public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState private static boolean isTypeOnClasspath(String type, VisitorState state) { try { return ThirdPartyLibrary.canIntroduceUsage(type, state); - } catch (IllegalArgumentException e) { + } catch ( + @SuppressWarnings("java:S1166" /* Not exceptional. */) + IllegalArgumentException e) { return false; } }