Skip to content

Commit

Permalink
Resolve some SonarCloud warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan202 committed Dec 18, 2023
1 parent 683e321 commit ec1ce7e
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private static SuggestedFix suggestClassReference(
original,
identifier
+ ".class.getCanonicalName()"
+ (suffix.isEmpty() ? "" : " + " + Constants.format(suffix)))
+ (suffix.isEmpty() ? "" : (" + " + Constants.format(suffix))))
.build();
}

Expand All @@ -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")
Expand All @@ -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;
}
}
Expand Down

0 comments on commit ec1ce7e

Please sign in to comment.