Skip to content

Commit 9c9554f

Browse files
glaudeeeclaude
andcommitted
chore: fix trivial SonarQube code smells (S1905, S1118)
Remove three unnecessary (T[]) casts in CollectionPredicates.Default (java:S1905, lines 88/98/108) — the varargs parameters are already typed as T[] so the cast is redundant. Add private constructor to Throws utility class and change abstract to final (java:S1118, line 3) — prevents implicit public constructor and accidental subclassing while keeping the static API intact. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 46a5a1b commit 9c9554f

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/main/java/com/github/zrdj/java/predicates/collections/CollectionPredicates.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public <T> Predicate<Collection<T>> containsAllOf(Collection<T> elements) {
8585

8686
@Override
8787
public <T> Predicate<Collection<T>> containsAllOf(T[] elements) {
88-
return outer -> containsAllOf(Arrays.asList((T[]) elements)).test(outer);
88+
return outer -> containsAllOf(Arrays.asList(elements)).test(outer);
8989
}
9090

9191
@Override
@@ -95,7 +95,7 @@ public <T> Predicate<Collection<T>> containsAnyOf(Collection<T> elements) {
9595

9696
@Override
9797
public <T> Predicate<Collection<T>> containsAnyOf(T[] elements) {
98-
return outer -> containsAnyOf(Arrays.asList((T[]) elements)).test(outer);
98+
return outer -> containsAnyOf(Arrays.asList(elements)).test(outer);
9999
}
100100

101101
@Override
@@ -105,7 +105,7 @@ public <T> Predicate<Collection<T>> containsNoneOf(Collection<T> elements) {
105105

106106
@Override
107107
public <T> Predicate<Collection<T>> containsNoneOf(T[] elements) {
108-
return outer -> containsNoneOf(Arrays.asList((T[]) elements)).test(outer);
108+
return outer -> containsNoneOf(Arrays.asList(elements)).test(outer);
109109
}
110110

111111
@Override

src/main/java/com/github/zrdj/java/predicates/helper/Throws.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.github.zrdj.java.predicates.helper;
22

3-
public abstract class Throws {
3+
public final class Throws {
4+
private Throws() {}
5+
46
public static boolean exception(final Action action) {
57
try {
68
action.execute();

0 commit comments

Comments
 (0)