Skip to content

Commit 95629c1

Browse files
author
James Bognar
committed
Minor fixes
1 parent 0418185 commit 95629c1

219 files changed

Lines changed: 805 additions & 380 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

juneau-bean/juneau-bean-html5/src/main/java/org/apache/juneau/bean/html5/HtmlBuilder.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,9 @@ public static final Link link(Object href) {
12201220
*
12211221
* @return The new element.
12221222
*/
1223+
@SuppressWarnings({
1224+
"java:S3051" // Named 'main' to match the HTML element name, not a program entry point
1225+
})
12231226
public static final Main main() {
12241227
return new Main();
12251228
}
@@ -1230,6 +1233,9 @@ public static final Main main() {
12301233
* @param children The child nodes.
12311234
* @return The new element.
12321235
*/
1236+
@SuppressWarnings({
1237+
"java:S3051" // Named 'main' to match the HTML element name, not a program entry point
1238+
})
12331239
public static final Main main(Object...children) {
12341240
return new Main(children);
12351241
}

juneau-bean/juneau-bean-openapi-v3/src/main/java/org/apache/juneau/bean/openapi3/ui/OpenApiUI.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
* </ul>
4343
*/
4444
@SuppressWarnings({
45-
"java:S1192" // String literals repeated for clarity in UI generation
45+
"java:S1192", // String literals repeated for clarity in UI generation
46+
"javabugs:S2259" // Null accesses are guarded by nn() checks; Sonar's flow analysis does not track nn() as a null guard
4647
})
4748
public class OpenApiUI extends ObjectSwap<OpenApi,Div> {
4849

juneau-bean/juneau-bean-swagger-v2/src/main/java/org/apache/juneau/bean/swagger/ui/SwaggerUI.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
* </ul>
4242
*/
4343
@SuppressWarnings({
44-
"java:S1192" // String literals repeated for clarity in UI generation
44+
"java:S1192", // String literals repeated for clarity in UI generation
45+
"javabugs:S2259" // Null accesses are guarded by nn() checks; Sonar's flow analysis does not track nn() as a null guard
4546
})
4647
public class SwaggerUI extends ObjectSwap<Swagger,Div> {
4748

juneau-core/juneau-assertions/src/main/java/org/apache/juneau/assertions/AssertionPredicate.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@
6060
* @param <T> the type of input being tested.
6161
*/
6262
@SuppressWarnings({
63-
"java:S115" // Constants use UPPER_snakeCase convention (e.g., MSG_predicateTestFailed, MSG_valueDidNotPassTest)
63+
"java:S115", // Constants use UPPER_snakeCase convention (e.g., MSG_predicateTestFailed, MSG_valueDidNotPassTest)
64+
"java:S3740" // Raw Predicate/Function types used for dynamic assertion dispatch where T cannot be bounded further
6465
})
6566
public class AssertionPredicate<T> implements Predicate<T> {
6667

juneau-core/juneau-assertions/src/main/java/org/apache/juneau/assertions/FluentPrimitiveArrayAssertion.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,9 @@ public FluentPrimitiveArrayAssertion<E,T,R> setThrowable(Class<? extends java.la
379379
}
380380

381381
@Override
382+
@SuppressWarnings({
383+
"java:S2225" // Returning null from toString() is intentional; null value signals absent/unset array in assertion context
384+
})
382385
public String toString() {
383386
if (valueIsNull())
384387
return null;

juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/BctAssertions.java

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ public class BctAssertions {
193193
private static final String ARG_pattern = "pattern";
194194
private static final String ARG_properties = "properties";
195195

196+
// Message constants
197+
private static final String MSG_value_was_null = "Value was null.";
198+
private static final String JOINER_comma_space = "\", \"";
199+
196200
/**
197201
* Asserts that the fields/properties on the specified bean are the specified values after being converted to strings.
198202
*
@@ -473,7 +477,7 @@ public static void assertBeans(Object actual, String fields, String...expected)
473477
* @see #assertBean(Object, String, String)
474478
*/
475479
public static void assertBeans(Supplier<String> message, Object actual, String fields, String...expected) {
476-
assertNotNull(actual, "Value was null.");
480+
assertNotNull(actual, MSG_value_was_null);
477481
assertArgNotNull(ARG_fields, fields);
478482
assertArgNotNull(ARG_expected, expected);
479483

@@ -503,8 +507,8 @@ public static void assertBeans(Supplier<String> message, Object actual, String f
503507
actualStrings.add(tokens.stream().map(x -> converter.getNested(o, x)).collect(joining(",")));
504508
}
505509

506-
throw assertEqualsFailed(Stream.of(expected).map(StringUtils::escapeForJava).collect(joining("\", \"", "\"", "\"")),
507-
actualStrings.stream().map(StringUtils::escapeForJava).collect(joining("\", \"", "\"", "\"")),
510+
throw assertEqualsFailed(Stream.of(expected).map(StringUtils::escapeForJava).collect(joining(JOINER_comma_space, "\"", "\"")),
511+
actualStrings.stream().map(StringUtils::escapeForJava).collect(joining(JOINER_comma_space, "\"", "\"")),
508512
composeMessage(message, "{0} bean assertions failed:\n{1}", errors.size(), errors.stream().map(x -> x.getMessage()).collect(joining("\n"))));
509513
}
510514

@@ -551,7 +555,7 @@ public static void assertContains(String expected, Object actual) {
551555
public static void assertContains(Supplier<String> message, String expected, Object actual) {
552556
assertArgNotNull(ARG_expected, expected);
553557
assertArgNotNull(ARG_actual, actual);
554-
assertNotNull(actual, "Value was null.");
558+
assertNotNull(actual, MSG_value_was_null);
555559

556560
var a = BctConfiguration.getConverter().stringify(actual);
557561
assertTrue(a.contains(expected), composeMessage(message, "String did not contain expected substring. ==> expected: <{0}> but was: <{1}>", expected, a));
@@ -598,7 +602,7 @@ public static void assertContainsAll(Object actual, String...expected) {
598602
*/
599603
public static void assertContainsAll(Supplier<String> message, Object actual, String...expected) {
600604
assertArgNotNull(ARG_expected, expected);
601-
assertNotNull(actual, "Value was null.");
605+
assertNotNull(actual, MSG_value_was_null);
602606

603607
var a = BctConfiguration.getConverter().stringify(actual);
604608
var errors = new ArrayList<AssertionFailedError>();
@@ -622,7 +626,7 @@ public static void assertContainsAll(Supplier<String> message, Object actual, St
622626
}
623627
}
624628

625-
throw assertEqualsFailed(missingSubstrings.stream().map(StringUtils::escapeForJava).collect(joining("\", \"", "\"", "\"")), escapeForJava(a),
629+
throw assertEqualsFailed(missingSubstrings.stream().map(StringUtils::escapeForJava).collect(joining(JOINER_comma_space, "\"", "\"")), escapeForJava(a),
626630
composeMessage(message, "{0} substring assertions failed:\n{1}", errors.size(), errors.stream().map(x -> x.getMessage()).collect(joining("\n"))));
627631
}
628632

@@ -686,7 +690,7 @@ public static void assertEmpty(Object value) {
686690
* @see #assertSize(int, Object) for testing specific sizes
687691
*/
688692
public static void assertEmpty(Supplier<String> message, Object value) {
689-
assertNotNull(value, "Value was null.");
693+
assertNotNull(value, MSG_value_was_null);
690694
var size = BctConfiguration.getConverter().size(value);
691695
assertEquals(0, size, composeMessage(message, "Value was not empty. Size=<{0}>", size));
692696
}
@@ -806,8 +810,8 @@ public static void assertList(Supplier<String> message, Object actual, Object...
806810
if (errors.size() == 1)
807811
throw errors.get(0);
808812

809-
throw assertEqualsFailed(Stream.of(expected).map(converter::stringify).map(StringUtils::escapeForJava).collect(joining("\", \"", "[\"", "\"]")),
810-
actualStrings.stream().map(StringUtils::escapeForJava).collect(joining("\", \"", "[\"", "\"]")),
813+
throw assertEqualsFailed(Stream.of(expected).map(converter::stringify).map(StringUtils::escapeForJava).collect(joining(JOINER_comma_space, "[\"", "\"]")),
814+
actualStrings.stream().map(StringUtils::escapeForJava).collect(joining(JOINER_comma_space, "[\"", "\"]")),
811815
composeMessage(message, "{0} list assertions failed:\n{1}", errors.size(), errors.stream().map(x -> x.getMessage()).collect(joining("\n"))));
812816
}
813817

@@ -915,7 +919,7 @@ public static void assertMap(Supplier<String> message, Map<?,?> actual, Object..
915919
* @see BasicBeanConverter
916920
*/
917921
public static <T> void assertMapped(Supplier<String> message, T actual, BiFunction<T,String,Object> function, String properties, String expected) {
918-
assertNotNull(actual, "Value was null.");
922+
assertNotNull(actual, MSG_value_was_null);
919923
assertArgNotNull(ARG_function, function);
920924
assertArgNotNull(ARG_properties, properties);
921925
assertArgNotNull(ARG_expected, expected);
@@ -996,7 +1000,7 @@ public static void assertMatchesGlob(String pattern, Object value) {
9961000
*/
9971001
public static void assertMatchesGlob(Supplier<String> message, String pattern, Object value) {
9981002
assertArgNotNull(ARG_pattern, pattern);
999-
assertNotNull(value, "Value was null.");
1003+
assertNotNull(value, MSG_value_was_null);
10001004

10011005
var v = BctConfiguration.getConverter().stringify(value);
10021006
var m = StringUtils.getGlobMatchPattern(pattern).matcher(v);
@@ -1063,7 +1067,7 @@ public static void assertNotEmpty(Object value) {
10631067
* @see #assertSize(Supplier, int, Object) for testing specific sizes
10641068
*/
10651069
public static void assertNotEmpty(Supplier<String> message, Object value) {
1066-
assertNotNull(value, "Value was null.");
1070+
assertNotNull(value, MSG_value_was_null);
10671071
int size = BctConfiguration.getConverter().size(value);
10681072
assertTrue(size > 0, composeMessage(message, "Value was empty."));
10691073
}
@@ -1109,7 +1113,7 @@ public static void assertSize(int expected, Object actual) {
11091113
* @throws AssertionError if the object is null or not the expected size.
11101114
*/
11111115
public static void assertSize(Supplier<String> message, int expected, Object actual) {
1112-
assertNotNull(actual, "Value was null.");
1116+
assertNotNull(actual, MSG_value_was_null);
11131117
var size = BctConfiguration.getConverter().size(actual);
11141118
assertEquals(expected, size, composeMessage(message, "Value not expected size."));
11151119
}
@@ -1158,7 +1162,7 @@ public static void assertString(String expected, Object actual) {
11581162
* @see #assertMatchesGlob(Supplier, String, Object) for pattern-based matching
11591163
*/
11601164
public static void assertString(Supplier<String> message, String expected, Object actual) {
1161-
assertNotNull(actual, "Value was null.");
1165+
assertNotNull(actual, MSG_value_was_null);
11621166

11631167
var messageSupplier = message != null ? message : fs("");
11641168
assertEquals(expected, BctConfiguration.getConverter().stringify(actual), messageSupplier);

juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/annotation/AppliedAnnotationObject.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@
120120
* </ul>
121121
*/
122122
@SuppressWarnings({
123-
"java:S115" // Constants use UPPER_snakeCase convention (e.g., ARG_value, ARG_values)
123+
"java:S115", // Constants use UPPER_snakeCase convention (e.g., ARG_value, ARG_values)
124+
"java:S2160" // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields accessed via those methods
124125
})
125126
public class AppliedAnnotationObject extends AnnotationObject {
126127

juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/collections/BidiMap.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@
8080
* @param <K> The key type.
8181
* @param <V> The value type.
8282
*/
83+
@SuppressWarnings({
84+
"java:S3740" // Raw Map/Iterator types used intentionally for bidirectional map operations where erased types are required for structural compatibility
85+
})
8386
public class BidiMap<K,V> implements Map<K,V> {
8487

8588
/**

juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/collections/Lists.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@
111111
* @param <E> The element type.
112112
*/
113113
@SuppressWarnings({
114-
"java:S115" // Constants use UPPER_snakeCase convention
114+
"java:S115", // Constants use UPPER_snakeCase convention
115+
"java:S3740" // Raw List/Iterable types used in utility methods where element type is not statically known
115116
})
116117
public class Lists<E> {
117118

juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/collections/Maps.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@
121121
* @param <V> The value type.
122122
*/
123123
@SuppressWarnings({
124-
"java:S115" // Constants use UPPER_snakeCase convention
124+
"java:S115", // Constants use UPPER_snakeCase convention
125+
"java:S3740" // Raw Map/Entry types used in utility methods where key/value types are not statically known
125126
})
126127
public class Maps<K,V> {
127128

0 commit comments

Comments
 (0)