This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push:
new ed0747ec42 SonarQube bug fixes
ed0747ec42 is described below
commit ed0747ec42e42449c82ccdeb2d1e09c2f84fe816
Author: James Bognar <[email protected]>
AuthorDate: Wed Feb 18 08:29:20 2026 -0500
SonarQube bug fixes
---
.../jsonschema/JsonSchemaPropertySimpleArray.java | 3 +
.../java/org/apache/juneau/commons/io/Console.java | 2 +-
.../juneau/commons/io/StringBuilderWriter.java | 2 +-
.../apache/juneau/commons/lang/StringFormat.java | 76 +++++++++++++++-------
.../juneau/commons/reflect/ReflectionMap.java | 51 ++++++++-------
.../apache/juneau/commons/time/TimeProvider.java | 8 ++-
.../org/apache/juneau/BasicRuntimeException.java | 6 ++
.../java/org/apache/juneau/BeanPropertyMeta.java | 5 +-
.../org/apache/juneau/BeanTraverseSession.java | 3 +
.../src/main/java/org/apache/juneau/Context.java | 40 +++++++-----
.../org/apache/juneau/collections/JsonList.java | 3 +-
.../org/apache/juneau/collections/JsonMap.java | 3 +
.../main/java/org/apache/juneau/cp/Messages.java | 6 +-
.../http/annotation/StatusCodeAnnotation.java | 2 +-
.../juneau/objecttools/ObjectRestException.java | 2 +-
.../apache/juneau/objecttools/ObjectSorter.java | 6 +-
.../apache/juneau/objecttools/ObjectViewer.java | 10 ++-
.../juneau/objecttools/StringMatcherFactory.java | 4 +-
.../org/apache/juneau/utils/GenericConverter.java | 8 ++-
.../juneau/microservice/resources/LogParser.java | 5 +-
.../org/apache/juneau/rest/client/RestClient.java | 9 ++-
.../juneau/http/response/BasicHttpException.java | 9 +++
.../apache/juneau/rest/beans/BeanDescription.java | 6 ++
.../org/apache/juneau/commons/io/Console_Test.java | 6 +-
scripts/check-fluent-setter-overrides.py | 6 +-
scripts/check-topic-links.py | 2 +-
scripts/cleanup-whitespace.py | 2 +-
scripts/push.py | 10 +--
scripts/test.py | 2 +-
scripts/view-sonar-category.py | 2 +-
30 files changed, 205 insertions(+), 94 deletions(-)
diff --git
a/juneau-bean/juneau-bean-jsonschema/src/main/java/org/apache/juneau/bean/jsonschema/JsonSchemaPropertySimpleArray.java
b/juneau-bean/juneau-bean-jsonschema/src/main/java/org/apache/juneau/bean/jsonschema/JsonSchemaPropertySimpleArray.java
index 2888a0ac81..1845e75fc3 100644
---
a/juneau-bean/juneau-bean-jsonschema/src/main/java/org/apache/juneau/bean/jsonschema/JsonSchemaPropertySimpleArray.java
+++
b/juneau-bean/juneau-bean-jsonschema/src/main/java/org/apache/juneau/bean/jsonschema/JsonSchemaPropertySimpleArray.java
@@ -244,6 +244,9 @@ public class JsonSchemaPropertySimpleArray extends
JsonSchemaProperty {
return this;
}
+ /**
+ * @deprecated Use {@link #setIdUri(Object)} instead.
+ */
@Override /* Overridden from JsonSchemaProperty */
@Deprecated(since = "10.0", forRemoval = true) // Parent method is
deprecated
public JsonSchemaPropertySimpleArray setId(Object value) {
diff --git
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/io/Console.java
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/io/Console.java
index ebd35b3605..66862db3c2 100644
---
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/io/Console.java
+++
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/io/Console.java
@@ -32,7 +32,7 @@ public class Console {
/**
* Constructor.
*/
- public Console() {
+ private Console() {
// No-op: Intentional empty constructor
}
diff --git
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/io/StringBuilderWriter.java
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/io/StringBuilderWriter.java
index dc5ae5b2fd..e4f0893ae2 100644
---
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/io/StringBuilderWriter.java
+++
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/io/StringBuilderWriter.java
@@ -194,7 +194,7 @@ public class StringBuilderWriter extends Writer {
}
@Override /* Overridden from Writer */
- public void write(char cbuf[], int start, int length) {
+ public void write(char[] cbuf, int start, int length) {
assertArgNotNull(ARG_cbuf, cbuf);
sb.append(cbuf, start, length);
}
diff --git
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/lang/StringFormat.java
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/lang/StringFormat.java
index 6687f68cc0..9fda787b78 100644
---
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/lang/StringFormat.java
+++
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/lang/StringFormat.java
@@ -145,18 +145,43 @@ public final class StringFormat {
this.placeholder = "{" + index + "}";
} else if (content.indexOf(',') == -1) {
this.content = null;
- this.index = parseIndexMF(content);
+ this.index = parseIndex(content);
this.format = 's';
this.placeholder = "{" + this.index + "}";
} else {
var tokens = content.split(",", 2);
- this.index = parseIndexMF(tokens[0]);
+ this.index = parseIndex(tokens[0]);
this.content = "{0," + tokens[1] + "}";
this.format = 'o';
this.placeholder = "{" + this.index + "," +
tokens[1] + "}";
}
}
+ /**
+ * Parses the index from a MessageFormat content string.
+ *
+ * @param s The content string (e.g., "0", "1").
+ * @return The parsed index.
+ * @throws IllegalArgumentException If the string is not a
valid number.
+ */
+ private static int parseIndex(String s) {
+ if (! s.matches("\\d+")) throw new
IllegalArgumentException("can't parse argument number: " + s);
+ return Integer.parseInt(s);
+ }
+
+ /**
+ * Creates a MessageFormatToken and adds it to the tokens list.
+ *
+ * @param tokens The list of tokens to add to.
+ * @param pattern The pattern string.
+ * @param start The start index in the pattern.
+ * @param end The end index in the pattern.
+ * @param index The token index.
+ */
+ static void create(List<Token> tokens, String pattern, int
start, int end, int index) {
+ tokens.add(new
MessageFormatToken(pattern.substring(start, end), index));
+ }
+
@Override
public String toString() {
return "[M:" + format + index + (content == null ? "" :
(':' + content)) + "]";
@@ -201,7 +226,7 @@ public final class StringFormat {
// content is everything after '%' (e.g., "s", "1$s", "d",
".2f", "1$.2f")
var dollarIndex = content.indexOf('$');
if (dollarIndex >= 0) {
- index = parseIndexSF(content.substring(0, dollarIndex))
- 1;
+ index = parseIndex(content.substring(0, dollarIndex)) -
1;
content = content.substring(dollarIndex + 1);
}
this.format = content.length() == 1 ?
content.charAt(content.length() - 1) : 'z';
@@ -209,6 +234,29 @@ public final class StringFormat {
this.content = "%" + content;
}
+ /**
+ * Parses the index from a StringFormat content string.
+ *
+ * @param s The content string (e.g., "1", "2").
+ * @return The parsed index.
+ */
+ private static int parseIndex(String s) {
+ return Integer.parseInt(s);
+ }
+
+ /**
+ * Creates a StringFormatToken and adds it to the tokens list.
+ *
+ * @param tokens The list of tokens to add to.
+ * @param pattern The pattern string.
+ * @param start The start index in the pattern.
+ * @param end The end index in the pattern.
+ * @param index The token index.
+ */
+ static void create(List<Token> tokens, String pattern, int
start, int end, int index) {
+ tokens.add(new
StringFormatToken(pattern.substring(start, end), index));
+ }
+
@Override
public String toString() {
return "[S:" + format + index + ":" + content + "]";
@@ -466,19 +514,6 @@ public final class StringFormat {
tokens.add(new LiteralToken(pattern.substring(start, end)));
}
- private static void mf(List<Token> tokens, String pattern, int start,
int end, int index) {
- tokens.add(new MessageFormatToken(pattern.substring(start,
end), index));
- }
-
- private static int parseIndexMF(String s) {
- if (! s.matches("\\d+")) throw new
IllegalArgumentException("can't parse argument number: " + s);
- return Integer.parseInt(s);
- }
-
- private static int parseIndexSF(String s) {
- return Integer.parseInt(s);
- }
-
/**
* Parses the pattern into a list of tokens.
*/
@@ -538,7 +573,7 @@ public final class StringFormat {
} else if (ch == 't' || ch == 'T') {
// Do nothing. Part of 2-character
time conversion.
} else if
(PRINTF_CONVERSION_CHARS.contains(ch)) {
- sf(tokens, pattern, mark, i,
sequentialIndex++);
+ StringFormatToken.create(tokens,
pattern, mark, i, sequentialIndex++);
state = S1;
mark = i;
} else if (PRINTF_FORMAT_CHARS.contains(ch) ||
Character.isDigit(ch)) {
@@ -548,7 +583,7 @@ public final class StringFormat {
// Create StringFormatToken and let
String.format() validate it
// This allows String.format() to throw
IllegalFormatException for invalid conversions like %F
// printfStart is position after '%',
so substring from printfStart-1 (the '%') to i (after the char)
- sf(tokens, pattern, mark, i,
sequentialIndex++);
+ StringFormatToken.create(tokens,
pattern, mark, i, sequentialIndex++);
state = S1;
mark = i;
}
@@ -559,7 +594,7 @@ public final class StringFormat {
if (nestedBracketDepth > 0) {
nestedBracketDepth--;
} else {
- mf(tokens, pattern, mark + 1, i
- 1, sequentialIndex++);
+
MessageFormatToken.create(tokens, pattern, mark + 1, i - 1, sequentialIndex++);
state = S1;
mark = i;
}
@@ -598,9 +633,6 @@ public final class StringFormat {
return tokens;
}
- private static void sf(List<Token> tokens, String pattern, int start,
int end, int index) {
- tokens.add(new StringFormatToken(pattern.substring(start, end),
index));
- }
private static String sf(Locale l, String s, Object o) {
return String.format(l, s, a(o));
diff --git
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/reflect/ReflectionMap.java
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/reflect/ReflectionMap.java
index 77f792f9d5..ed14de4f4d 100644
---
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/reflect/ReflectionMap.java
+++
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/reflect/ReflectionMap.java
@@ -303,6 +303,33 @@ public class ReflectionMap<V> {
public ReflectionMap<V> build() {
return new ReflectionMap<>(this);
}
+
+ /**
+ * Splits a comma-delimited key string into individual keys,
respecting escaped commas within parentheses.
+ *
+ * @param key The key string to split.
+ * @param consumer The consumer to accept each split key.
+ */
+ private void splitNames(String key, Consumer<String> consumer) {
+ if (key.indexOf(',') == -1) {
+ consumer.accept(key);
+ } else {
+ var m = 0;
+ var escaped = false;
+ for (var i = 0; i < key.length(); i++) {
+ var c = key.charAt(i);
+ if (c == '(')
+ escaped = true;
+ else if (c == ')')
+ escaped = false;
+ else if (c == ',' && ! escaped) {
+
consumer.accept(key.substring(m, i).trim());
+ m = i + 1;
+ }
+ }
+ consumer.accept(key.substring(m).trim());
+ }
+ }
}
private static class ClassEntry<V> {
@@ -351,7 +378,7 @@ public class ReflectionMap<V> {
String simpleClassName;
String fullClassName;
- String args[];
+ String[] args;
V value;
ConstructorEntry(String name, V value) {
@@ -446,7 +473,7 @@ public class ReflectionMap<V> {
String simpleClassName;
String fullClassName;
String methodName;
- String args[];
+ String[] args;
V value;
MethodEntry(String name, V value) {
@@ -595,26 +622,6 @@ public class ReflectionMap<V> {
return null;
}
- private static void splitNames(String key, Consumer<String> consumer) {
- if (key.indexOf(',') == -1) {
- consumer.accept(key);
- } else {
- var m = 0;
- var escaped = false;
- for (var i = 0; i < key.length(); i++) {
- var c = key.charAt(i);
- if (c == '(')
- escaped = true;
- else if (c == ')')
- escaped = false;
- else if (c == ',' && ! escaped) {
- consumer.accept(key.substring(m,
i).trim());
- m = i + 1;
- }
- }
- consumer.accept(key.substring(m).trim());
- }
- }
private static String stripGenerics(String type) {
if (type.indexOf('<') == -1)
diff --git
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/time/TimeProvider.java
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/time/TimeProvider.java
index c222f63c6d..dad734721a 100644
---
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/time/TimeProvider.java
+++
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/time/TimeProvider.java
@@ -42,13 +42,17 @@ import java.time.*;
* <li class='jm'>{@link GranularZonedDateTime}
* </ul>
*/
-@SuppressWarnings("java:S6541") // Intentional singleton for extensibility
+@SuppressWarnings({
+ "java:S6541" // Intentional singleton for extensibility
+})
public class TimeProvider {
/**
* The default instance that uses the system's time and timezone.
*/
- @SuppressWarnings("java:S6541") // Intentional singleton for
extensibility
+ @SuppressWarnings({
+ "java:S6541" // Intentional singleton for extensibility
+ })
public static final TimeProvider INSTANCE = new TimeProvider();
/**
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BasicRuntimeException.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BasicRuntimeException.java
index 22788e6f0b..ac58d69119 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BasicRuntimeException.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BasicRuntimeException.java
@@ -28,7 +28,13 @@ import java.text.*;
*/
public class BasicRuntimeException extends RuntimeException {
private static final long serialVersionUID = 1L;
+ @SuppressWarnings({
+ "java:S1104" // Field may be set via setUnmodifiable() method
+ })
boolean unmodifiable;
+ @SuppressWarnings({
+ "java:S1104" // Field reassigned via setMessage() method,
cannot be final
+ })
String message;
/**
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
index 908bea9a45..6f37b88605 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
@@ -1025,7 +1025,10 @@ public class BeanPropertyMeta implements
Comparable<BeanPropertyMeta> {
}
}
- @SuppressWarnings("java:S3776") // Cognitive complexity is acceptable
for this complex property setter
+ @SuppressWarnings({
+ "java:S3776", // Cognitive complexity acceptable for complex
property setter
+ "java:S6541" // Brain method acceptable - complex property
value setting logic requires high LOC/complexity
+ })
private Object setPropertyValue(BeanMap<?> m, String pName, Object
value1, Object bean, boolean isMap, boolean isCollection, BeanSession session)
throws ParseException {
try {
var r = (bc.isBeanMapPutReturnsOldValue() || isMap ||
isCollection) && (nn(getter) || nn(field)) ? get(m, pName) : null;
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanTraverseSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanTraverseSession.java
index 1aa8e45d21..ee6596282c 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanTraverseSession.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanTraverseSession.java
@@ -169,6 +169,9 @@ public class BeanTraverseSession extends BeanSession {
private ClassMeta<?> currentClass;
private boolean isBottom;
// If 'true', then we're at a leaf in the model (i.e. a String, Number,
Boolean, or null).
/** The current indentation depth into the model. */
+ @SuppressWarnings({
+ "java:S1104" // Public field accessed externally (e.g.,
session.indent = 6)
+ })
public int indent;
private int depth;
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Context.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Context.java
index 4669902a04..554e0a1f30 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Context.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Context.java
@@ -472,6 +472,30 @@ public abstract class Context {
return apply(work);
}
+ /**
+ * Traverses the specified object and adds applicable
annotations to the work list.
+ *
+ * @param work The annotation work list to add to.
+ * @param x The object to traverse (Class, ClassInfo, Method,
or MethodInfo).
+ * @return The work list.
+ */
+ private AnnotationWorkList traverse(AnnotationWorkList work,
Object x) {
+ var ap = AP;
+ CollectionUtils.traverse(x, y -> {
+ if (x instanceof Class<?> x2)
+
work.add(rstream(ap.find(info(x2))).filter(CONTEXT_APPLY_FILTER));
+ else if (x instanceof ClassInfo x2)
+
work.add(rstream(ap.find(x2)).filter(CONTEXT_APPLY_FILTER));
+ else if (x instanceof Method x2)
+
work.add(rstream(ap.find(info(x2))).filter(CONTEXT_APPLY_FILTER));
+ else if (x instanceof MethodInfo x2)
+
work.add(rstream(ap.find(x2)).filter(CONTEXT_APPLY_FILTER));
+ else
+ illegalArg("Invalid type passed to
applyAnnotations: {0}", cn(x));
+ });
+ return work;
+ }
+
/**
* Returns this builder cast to the specified subtype if it is
an instance of that type.
*
@@ -844,22 +868,6 @@ public abstract class Context {
}
}
- private static AnnotationWorkList traverse(AnnotationWorkList work,
Object x) {
- var ap = AP;
- CollectionUtils.traverse(x, y -> {
- if (x instanceof Class<?> x2)
-
work.add(rstream(ap.find(info(x2))).filter(CONTEXT_APPLY_FILTER));
- else if (x instanceof ClassInfo x2)
-
work.add(rstream(ap.find(x2)).filter(CONTEXT_APPLY_FILTER));
- else if (x instanceof Method x2)
-
work.add(rstream(ap.find(info(x2))).filter(CONTEXT_APPLY_FILTER));
- else if (x instanceof MethodInfo x2)
-
work.add(rstream(ap.find(x2)).filter(CONTEXT_APPLY_FILTER));
- else
- illegalArg("Invalid type passed to
applyAnnotations: {0}", cn(x));
- });
- return work;
- }
private final AnnotationProvider annotationProvider;
private final boolean debug;
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonList.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonList.java
index 7401a6f895..ce85bf06b8 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonList.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonList.java
@@ -154,7 +154,8 @@ public class JsonList extends LinkedList<Object> {
* @serial exclude
*/
@SuppressWarnings({
- "java:S110" // Anonymous class has many fields, acceptable for
collection implementation
+ "java:S110", // Anonymous class has many fields, acceptable for
collection implementation
+ "java:S2386" // Public static final field accessed externally,
cannot be protected
})
public static final JsonList EMPTY_LIST = new JsonList() {
private static final long serialVersionUID = 1L;
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonMap.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonMap.java
index 4709df0f9b..be8f36a332 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonMap.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonMap.java
@@ -137,6 +137,9 @@ public class JsonMap extends LinkedHashMap<String,Object> {
*
* @serial exclude
*/
+ @SuppressWarnings({
+ "java:S2386" // Public static final field accessed externally,
cannot be protected
+ })
public static final JsonMap EMPTY_MAP = new JsonMap() {
private static final long serialVersionUID = 1L;
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/Messages.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/Messages.java
index 1f9cbfa777..fade0e1b0d 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/Messages.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/Messages.java
@@ -119,9 +119,9 @@ public class Messages extends ResourceBundle {
public static class Builder extends BeanBuilder<Messages> {
private static class MessagesString {
- public String name;
- public String[] baseNames;
- public String locale;
+ private String name;
+ private String[] baseNames;
+ private String locale;
}
Class<?> forClass;
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/StatusCodeAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/StatusCodeAnnotation.java
index 088ca479b5..c73fb04516 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/StatusCodeAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/StatusCodeAnnotation.java
@@ -90,7 +90,7 @@ public class StatusCodeAnnotation {
public static class Builder extends AppliedAnnotationObject.BuilderTM {
private String[] description = {};
- private int value[] = {};
+ private int[] value = {};
/**
* Constructor.
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectRestException.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectRestException.java
index 2dca1e576e..d6ecd71026 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectRestException.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectRestException.java
@@ -48,7 +48,7 @@ public class ObjectRestException extends
BasicRuntimeException {
private static final long serialVersionUID = 1L;
- private int status;
+ private final int status;
/**
* Constructor.
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectSorter.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectSorter.java
index e1555e95d1..99f567c517 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectSorter.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectSorter.java
@@ -55,7 +55,11 @@ import org.apache.juneau.*;
* </ul>
*/
-@SuppressWarnings({ "unchecked", "rawtypes", "java:S6541" }) // Stateless
utility, singleton for convenience
+@SuppressWarnings({
+ "unchecked", // Type erasure requires unchecked casts
+ "rawtypes", // Raw types necessary for generic type handling
+ "java:S6541" // Stateless utility, singleton for convenience
+})
public class ObjectSorter implements ObjectTool<SortArgs> {
private static class SortEntry implements Comparable {
Object o;
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectViewer.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectViewer.java
index 2cc6f43a99..61e3faf710 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectViewer.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/ObjectViewer.java
@@ -52,13 +52,19 @@ import org.apache.juneau.internal.*;
* </ul>
*/
-@SuppressWarnings({ "unchecked", "rawtypes", "java:S6541" }) // Stateless
utility, singleton for convenience
+@SuppressWarnings({
+ "unchecked", // Type erasure requires unchecked casts
+ "rawtypes", // Raw types necessary for generic type handling
+ "java:S6541" // Stateless utility, singleton for convenience
+})
public class ObjectViewer implements ObjectTool<ViewArgs> {
/**
* Default reusable searcher.
*/
- @SuppressWarnings("java:S6541") // Stateless utility, singleton for
convenience
+ @SuppressWarnings({
+ "java:S6541" // Stateless utility, singleton for convenience
+ })
public static final ObjectViewer DEFAULT = new ObjectViewer();
/**
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/StringMatcherFactory.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/StringMatcherFactory.java
index 0a85563283..d0c79e054e 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/StringMatcherFactory.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/objecttools/StringMatcherFactory.java
@@ -46,7 +46,9 @@ import org.apache.juneau.commons.utils.*;
* <li class='link'><a class="doclink"
href="https://juneau.apache.org/docs/topics/ObjectTools">Object Tools</a>
* </ul>
*/
-@SuppressWarnings("java:S6541") // Stateless utility, singleton for convenience
+@SuppressWarnings({
+ "java:S6541" // Stateless utility, singleton for convenience
+})
public class StringMatcherFactory extends MatcherFactory {
/**
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/GenericConverter.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/GenericConverter.java
index f3fadf2360..d057b15e4c 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/GenericConverter.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/GenericConverter.java
@@ -50,7 +50,9 @@ import org.apache.juneau.commons.conversion.*;
* <li class='jm'>{@link BeanSession#convertToType(Object, Class)}
* </ul>
*/
-@SuppressWarnings("java:S6541") // Stateless converter, singleton for
convenience
+@SuppressWarnings({
+ "java:S6541" // Stateless converter, singleton for convenience
+})
public class GenericConverter implements Converter {
/**
@@ -59,7 +61,9 @@ public class GenericConverter implements Converter {
* <p>
* This instance can be safely shared across multiple threads and
reused for all conversion operations.
*/
- @SuppressWarnings("java:S6541") // Stateless converter, singleton for
convenience
+ @SuppressWarnings({
+ "java:S6541" // Stateless converter, singleton for convenience
+ })
public static final GenericConverter INSTANCE = new GenericConverter();
/**
diff --git
a/juneau-microservice/juneau-microservice-core/src/main/java/org/apache/juneau/microservice/resources/LogParser.java
b/juneau-microservice/juneau-microservice-core/src/main/java/org/apache/juneau/microservice/resources/LogParser.java
index 9e37a24b7c..f8df743543 100644
---
a/juneau-microservice/juneau-microservice-core/src/main/java/org/apache/juneau/microservice/resources/LogParser.java
+++
b/juneau-microservice/juneau-microservice-core/src/main/java/org/apache/juneau/microservice/resources/LogParser.java
@@ -38,7 +38,10 @@ public class LogParser implements Iterable<LogParser.Entry>,
Iterator<LogParser.
/**
* Represents a single line from the log file.
*/
- @SuppressWarnings("javadoc")
+ @SuppressWarnings({
+ "javadoc",
+ "java:S1104" // Public fields accessed externally (e.g.,
le.severity)
+ })
public class Entry {
public Date date;
public String severity;
diff --git
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
index b5000b1eef..fb91f8d903 100644
---
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
+++
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
@@ -6973,7 +6973,11 @@ public class RestClient extends BeanContextable
implements HttpClient, Closeable
* <br>Can be <jk>null</jk> (will use the default parser from the
client).
* @return The new proxy interface.
*/
- @SuppressWarnings({ "unchecked", "java:S3776" })
+ @SuppressWarnings({
+ "unchecked", // Type erasure requires unchecked casts
+ "java:S3776", // Cognitive complexity acceptable for remote
proxy creation
+ "java:S6541" // Brain method acceptable - remote proxy creation
requires complex initialization logic
+ })
public <T> T getRemote(Class<T> interfaceClass, Object rootUrl,
Serializer serializer, Parser parser) {
if (rootUrl == null)
@@ -7774,6 +7778,9 @@ public class RestClient extends BeanContextable
implements HttpClient, Closeable
return new RestResponse(this, request, httpResponse, parser);
}
+ /**
+ * @deprecated Object.finalize() is deprecated. Use try-with-resources
or explicit close() calls instead.
+ */
@Override
@Deprecated(since = "9", forRemoval = true) // Object.finalize() is
deprecated
protected void finalize() throws Throwable {
diff --git
a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/BasicHttpException.java
b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/BasicHttpException.java
index df5adc469d..3947660529 100644
---
a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/BasicHttpException.java
+++
b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/response/BasicHttpException.java
@@ -63,8 +63,17 @@ public class BasicHttpException extends
BasicRuntimeException implements HttpRes
private static final long serialVersionUID = 1L;
+ @SuppressWarnings({
+ "java:S1104" // Fields reassigned after construction, cannot be
final
+ })
HeaderList headers = HeaderList.create();
+ @SuppressWarnings({
+ "java:S1104" // Field reassigned after construction, cannot be
final
+ })
transient BasicStatusLine statusLine = new BasicStatusLine();
+ @SuppressWarnings({
+ "java:S1104" // Field reassigned after construction, cannot be
final
+ })
transient HttpEntity content;
/**
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/beans/BeanDescription.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/beans/BeanDescription.java
index c01efa4996..b2c3309e61 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/beans/BeanDescription.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/beans/BeanDescription.java
@@ -38,11 +38,17 @@ import org.apache.juneau.annotation.*;
* </ul>
*/
@Bean(properties = "type,properties")
+@SuppressWarnings({
+ "java:S1104" // Public fields required for @Bean serialization
+})
public class BeanDescription {
/**
* Information about a bean property.
*/
+ @SuppressWarnings({
+ "java:S1104" // Public fields required for @Bean serialization
+ })
public static class BeanPropertyDescription {
/** The bean property name. */
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/commons/io/Console_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/commons/io/Console_Test.java
index ca3f66fb01..02ba06efe0 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/commons/io/Console_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/commons/io/Console_Test.java
@@ -55,9 +55,9 @@ class Console_Test extends TestBase {
@Test
void a00_constructor() {
// Test line 29: class instantiation
- // Console has an implicit public no-arg constructor
- var instance = new Console();
- assertNotNull(instance);
+ // Console is a utility class with private constructor - no
instantiation needed
+ // Constructor is private to prevent instantiation of utility
class
+ assertNotNull(Console.class);
}
//====================================================================================================
diff --git a/scripts/check-fluent-setter-overrides.py
b/scripts/check-fluent-setter-overrides.py
index 6a93d14852..065a164a36 100755
--- a/scripts/check-fluent-setter-overrides.py
+++ b/scripts/check-fluent-setter-overrides.py
@@ -104,7 +104,7 @@ def extract_package(content):
match = re.search(r'^\s*package\s+([\w.]+)\s*;', content, re.MULTILINE)
return match.group(1) if match else None
-# NOSONAR -- S3776: Cognitive complexity is acceptable for this utility
function
+# NOSONAR python:S3776 -- Cognitive complexity is acceptable for this utility
function
def extract_class_info(file_path):
"""Extract class information from a Java file."""
try:
@@ -201,7 +201,7 @@ def extract_class_info(file_path):
print(f"ERROR: Failed to process {file_path}: {e}", file=sys.stderr)
return []
-# NOSONAR -- S3776: Cognitive complexity is acceptable for this utility
function
+# NOSONAR python:S3776 -- Cognitive complexity is acceptable for this utility
function
def find_java_files(source_dir):
"""Find all Java files in the source tree, excluding test directories."""
java_files = []
@@ -237,7 +237,7 @@ def build_class_hierarchy(classes):
return class_map
-# NOSONAR -- S3776: Cognitive complexity is acceptable for this utility
function
+# NOSONAR python:S3776 -- Cognitive complexity is acceptable for this utility
function
def check_missing_overrides(classes, class_map):
"""Check for missing fluent setter overrides."""
missing_overrides = []
diff --git a/scripts/check-topic-links.py b/scripts/check-topic-links.py
index ea3b81e22a..d6f827e1aa 100755
--- a/scripts/check-topic-links.py
+++ b/scripts/check-topic-links.py
@@ -67,7 +67,7 @@ def extract_topic_info(docs_dir):
return topics
-# NOSONAR -- S3776: Cognitive complexity is acceptable for this utility
function
+# NOSONAR python:S3776 -- Cognitive complexity is acceptable for this utility
function
def find_topic_links(source_dir):
"""Find all topic links in the source tree."""
links = []
diff --git a/scripts/cleanup-whitespace.py b/scripts/cleanup-whitespace.py
index 6d14490169..e72efdfaf7 100755
--- a/scripts/cleanup-whitespace.py
+++ b/scripts/cleanup-whitespace.py
@@ -30,7 +30,7 @@ import re
from pathlib import Path
-# NOSONAR -- S3776: Cognitive complexity is acceptable for this utility
function
+# NOSONAR python:S3776 -- Cognitive complexity is acceptable for this utility
function
def clean_java_file(file_path):
"""
Clean whitespace issues in a Java file.
diff --git a/scripts/push.py b/scripts/push.py
index 3bc0562235..52c35c27ee 100755
--- a/scripts/push.py
+++ b/scripts/push.py
@@ -79,7 +79,7 @@ def run_command(cmd, description, cwd=None):
return False
-# NOSONAR -- S3776: Cognitive complexity is acceptable for this utility
function
+# NOSONAR python:S3776 -- Cognitive complexity is acceptable for this utility
function
def play_sound(success=True):
"""
Play a system sound to indicate success or failure.
@@ -146,7 +146,7 @@ def play_sound(success=True):
pass
-# NOSONAR -- S3776: Cognitive complexity is acceptable for this utility
function
+# NOSONAR python:S3776 -- Cognitive complexity is acceptable for this utility
function
def play_sound(success=True):
"""
Play a system sound to indicate success or failure.
@@ -296,7 +296,7 @@ def check_upstream_changes(repo_dir):
return (False, f"Error checking upstream changes: {e}")
-# NOSONAR -- S3776: Cognitive complexity is acceptable for this utility
function
+# NOSONAR python:S3776 -- Cognitive complexity is acceptable for this utility
function
def play_sound(success=True):
"""
Play a system sound to indicate success or failure.
@@ -363,7 +363,7 @@ def play_sound(success=True):
pass
-# NOSONAR -- S3776: Cognitive complexity is acceptable for this main function
+# NOSONAR python:S3776 -- Cognitive complexity is acceptable for this main
function
def main():
parser = argparse.ArgumentParser(
description="Build, test, and push Juneau project to Git repository",
@@ -486,7 +486,7 @@ Examples:
step_num += 1
# Check if local branch is behind upstream
- print(f"\nš Checking for upstream changes...")
+ print("\nš Checking for upstream changes...")
is_behind, error_msg = check_upstream_changes(juneau_root)
if error_msg:
print(f"\nā Warning: Could not check upstream changes: {error_msg}")
diff --git a/scripts/test.py b/scripts/test.py
index c9e6d82f24..50e6c8bcb5 100755
--- a/scripts/test.py
+++ b/scripts/test.py
@@ -86,7 +86,7 @@ def parse_test_results(output):
return total, failures, errors
return None, None, None
-# NOSONAR -- S3776: Cognitive complexity is acceptable for this main function
+# NOSONAR python:S3776 -- Cognitive complexity is acceptable for this main
function
def main():
args = sys.argv[1:]
diff --git a/scripts/view-sonar-category.py b/scripts/view-sonar-category.py
index 4b30fff4f5..8e2ef18294 100755
--- a/scripts/view-sonar-category.py
+++ b/scripts/view-sonar-category.py
@@ -20,7 +20,7 @@ import json
import sys
from pathlib import Path
-# NOSONAR -- S3776: Cognitive complexity is acceptable for this script function
+# NOSONAR python:S3776 -- Cognitive complexity is acceptable for this script
function
def main():
json_file =
Path('/Users/james.bognar/Downloads/SonarQubeIssues.categorized.json')