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 7f79b7add3 SonarQube bug fixes
7f79b7add3 is described below
commit 7f79b7add3a03de421374d84b94ca9c0f31fe24e
Author: James Bognar <[email protected]>
AuthorDate: Mon Feb 2 16:31:23 2026 -0500
SonarQube bug fixes
---
TODO-SONARCLOUD_SETUP.md | 120 ---------------------
.../juneau/junit/bct/BasicBeanConverter.java | 4 +-
.../org/apache/juneau/junit/bct/BctAssertions.java | 6 +-
.../apache/juneau/junit/bct/BctConfiguration.java | 30 ++++++
.../apache/juneau/junit/bct/NestedTokenizer.java | 1 +
.../juneau/junit/bct/PropertyExtractors.java | 4 +-
.../org/apache/juneau/junit/bct/Stringifiers.java | 4 +-
.../junit/bct/annotations/BctConfigExtension.java | 5 +-
.../org/apache/juneau/commons/utils/Utils.java | 4 +-
9 files changed, 45 insertions(+), 133 deletions(-)
diff --git a/TODO-SONARCLOUD_SETUP.md b/TODO-SONARCLOUD_SETUP.md
deleted file mode 100644
index da9d2c1d9f..0000000000
--- a/TODO-SONARCLOUD_SETUP.md
+++ /dev/null
@@ -1,120 +0,0 @@
-# SonarCloud Setup Guide for Apache Juneau
-
-This guide explains how to set up SonarCloud analysis for the Apache Juneau
project.
-
-## Prerequisites
-
-1. **SonarCloud Account**: Sign up at [sonarcloud.io](https://sonarcloud.io)
using your GitHub account
-2. **Organization**: The project should be under the `apache` organization on
SonarCloud
-3. **Repository Access**: Ensure you have admin access to the Apache Juneau
repository
-
-## Setup Steps
-
-### 1. Create SonarCloud Project
-
-1. Go to [SonarCloud](https://sonarcloud.io)
-2. Click "Analyze new project"
-3. Select "Apache" organization
-4. Choose "apache/juneau" repository
-5. Set project key to: `apache_juneau`
-6. Choose "With GitHub Actions" as the analysis method
-
-### 2. Configure GitHub Secrets
-
-Add the following secret to your GitHub repository:
-
-- **Secret Name**: `SONAR_TOKEN`
-- **Secret Value**: Generate from SonarCloud → My Account → Security →
Generate Tokens
-
-To add the secret:
-1. Go to GitHub repository → Settings → Secrets and variables → Actions
-2. Click "New repository secret"
-3. Name: `SONAR_TOKEN`
-4. Value: Copy from SonarCloud token generation
-
-### 3. Verify Configuration Files
-
-The following files have been added to the project:
-
-- **`.github/workflows/sonarcloud.yml`** - GitHub Actions workflow
-- **`sonar-project.properties`** - SonarCloud configuration
-- **`pom.xml`** - Updated with SonarCloud Maven plugin
-
-### 4. Test the Setup
-
-1. Push the changes to the repository
-2. Check the Actions tab to see the SonarCloud workflow running
-3. Visit [SonarCloud
Dashboard](https://sonarcloud.io/project/overview?id=apache_juneau) to see
results
-
-## Configuration Details
-
-### Workflow Triggers
-
-The SonarCloud analysis runs:
-- **On every push** to master branch
-- **On every pull request** to master branch
-- **Scheduled**: Every Monday at 2:00 AM UTC
-
-### Analysis Configuration
-
-- **Java Version**: 17
-- **Coverage**: JaCoCo integration
-- **Test Reports**: Surefire reports
-- **Exclusions**: Target directories, documentation, examples
-
-### Quality Gate
-
-The workflow includes a quality gate check that will:
-- ✅ **Pass**: If code meets quality standards
-- ❌ **Fail**: If critical issues are found (but won't block the build)
-
-## Monitoring and Maintenance
-
-### Dashboard Access
-
-- **Public Dashboard**:
[sonarcloud.io/project/overview?id=apache_juneau](https://sonarcloud.io/project/overview?id=apache_juneau)
-- **Quality Gate Status**: Visible in README badges
-- **Security Rating**: Displayed on security page
-
-### Regular Tasks
-
-1. **Review Quality Gate Results**: Check weekly for any failing quality gates
-2. **Address Security Issues**: Prioritize security hotspots and
vulnerabilities
-3. **Monitor Technical Debt**: Track and reduce technical debt over time
-4. **Update Dependencies**: Keep SonarCloud Maven plugin updated
-
-## Troubleshooting
-
-### Common Issues
-
-1. **Token Issues**: Ensure `SONAR_TOKEN` secret is correctly set
-2. **Build Failures**: Check Maven build logs for Java compilation issues
-3. **Coverage Issues**: Verify JaCoCo reports are generated correctly
-4. **Timeout Issues**: Large projects may need longer timeout settings
-
-### Getting Help
-
-- **SonarCloud Documentation**:
[docs.sonarcloud.io](https://docs.sonarcloud.io)
-- **GitHub Actions Logs**: Check workflow execution logs
-- **SonarCloud Community**:
[community.sonarcloud.io](https://community.sonarcloud.io)
-
-## Benefits
-
-With SonarCloud integration, you get:
-
-- **Automated Quality Analysis**: Every commit and PR
-- **Security Vulnerability Detection**: Proactive security scanning
-- **Code Coverage Tracking**: Test coverage metrics
-- **Technical Debt Monitoring**: Maintainability insights
-- **Quality Gate Enforcement**: Consistent code quality standards
-- **Public Quality Metrics**: Transparent project health indicators
-
-## Next Steps
-
-After successful setup:
-
-1. **Review Initial Results**: Check the first analysis results
-2. **Configure Quality Gates**: Set appropriate quality standards
-3. **Address Critical Issues**: Fix high-priority security and quality issues
-4. **Monitor Trends**: Track improvement over time
-5. **Share Results**: Update documentation with quality metrics
diff --git
a/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/BasicBeanConverter.java
b/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/BasicBeanConverter.java
index 97f2603b13..a68f04effb 100644
---
a/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/BasicBeanConverter.java
+++
b/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/BasicBeanConverter.java
@@ -217,7 +217,7 @@ import java.util.stream.*;
*
* @see BeanConverter
*/
-@SuppressWarnings("rawtypes")
+@SuppressWarnings({"rawtypes","java:S115","javabugs:S2259"})
public class BasicBeanConverter implements BeanConverter {
/**
@@ -882,7 +882,7 @@ public class BasicBeanConverter implements BeanConverter {
.findFirst();
// @formatter:on
if (isEmpty.isPresent())
- return isEmpty.get() ? 0 : 1;
+ return isTrue(isEmpty.get()) ? 0 : 1;
throw illegalArg("Object of type {0} does not have a
determinable size.", cns(o));
}
diff --git
a/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/BctAssertions.java
b/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/BctAssertions.java
index b59e40ac2d..bd5660bea4 100644
---
a/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/BctAssertions.java
+++
b/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/BctAssertions.java
@@ -180,6 +180,7 @@ import org.opentest4j.*;
* @see BctConfiguration#set(BeanConverter)
* @see BctConfiguration#clear()
*/
+@SuppressWarnings("java:S1192")
public class BctAssertions {
/**
@@ -749,7 +750,7 @@ public class BctAssertions {
* Can be Strings (readable format comparison),
Predicates (functional testing), or Objects (direct equality).
* @throws AssertionError if the List size or contents don't match
expected values
*/
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({"unchecked","java:S3776"})
public static void assertList(Supplier<String> message, Object actual,
Object...expected) {
assertArgNotNull("expected", expected);
assertArgNotNull("actual", actual);
@@ -768,7 +769,8 @@ public class BctAssertions {
if (neq(e2, converter.stringify(x))) {
errors.add(assertEqualsFailed(e2, converter.stringify(x),
composeMessage(message, "Element at index {0} did not match.", i)));
}
- } else if (e instanceof Predicate e2) {
+ } else if (e instanceof Predicate<?> p) {
+ Predicate<Object> e2 =
(Predicate<Object>) p;
if (! e2.test(x)) {
errors.add(new
AssertionFailedError(composeMessage(message, "Element at index {0} did not pass
predicate. ==> actual: <{1}>", i, converter.stringify(x)).get()));
}
diff --git
a/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/BctConfiguration.java
b/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/BctConfiguration.java
index 77ede9b028..dcc8476538 100644
---
a/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/BctConfiguration.java
+++
b/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/BctConfiguration.java
@@ -80,6 +80,13 @@ import org.apache.juneau.commons.settings.*;
*/
public class BctConfiguration {
+ /**
+ * Private constructor to prevent instantiation.
+ */
+ private BctConfiguration() {
+ // Utility class - prevent instantiation
+ }
+
// Thread-local memoized supplier for default converter (defaults to
BasicBeanConverter.DEFAULT)
private static final ThreadLocal<ResettableSupplier<BeanConverter>>
CONVERTER_SUPPLIER = ThreadLocal.withInitial(() -> memr(() ->
BasicBeanConverter.DEFAULT));
@@ -197,6 +204,28 @@ public class BctConfiguration {
return SETTINGS.get(name, def);
}
+ /**
+ * Gets a boolean configuration value by name with a default value.
+ *
+ * <p>
+ * Returns the configured boolean value if set, otherwise returns the
provided default value.
+ * Thread-local values take precedence over global values.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bjava'>
+ * <jk>boolean</jk> <jv>sortMaps</jv> =
BctConfiguration.<jsm>get</jsm>(BctConfiguration.<jsf>BCT_SORT_MAPS</jsf>,
<jk>false</jk>);
+ * </p>
+ *
+ * @param name The configuration property name (e.g., {@link
#BCT_SORT_MAPS}).
+ * @param def The default boolean value to return if not set.
+ * @return The configured boolean value, or the default if not set.
+ * @see #get(String)
+ * @see #set(String, Object)
+ */
+ public static boolean get(String name, boolean def) {
+ return SETTINGS.get(name, def);
+ }
+
/**
* Clears all thread-local configuration settings.
*
@@ -226,6 +255,7 @@ public class BctConfiguration {
public static void clear() {
SETTINGS.clearLocal();
CONVERTER_OVERRIDE.remove();
+ CONVERTER_SUPPLIER.remove();
}
/**
diff --git
a/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/NestedTokenizer.java
b/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/NestedTokenizer.java
index 16396aa422..5d1bee653e 100644
---
a/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/NestedTokenizer.java
+++
b/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/NestedTokenizer.java
@@ -155,6 +155,7 @@ class NestedTokenizer {
IN_ESCAPE
}
+ @SuppressWarnings({"java:S3776","java:S6541"}) // Intentional Brain
Method.
public static List<Token> tokenize(String in) {
if (in == null)
throw illegalArg("Input was null.");
diff --git
a/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/PropertyExtractors.java
b/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/PropertyExtractors.java
index 66c2c2224a..4bd381b180 100644
---
a/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/PropertyExtractors.java
+++
b/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/PropertyExtractors.java
@@ -221,13 +221,13 @@ public class PropertyExtractors {
return true;
}
- @SuppressWarnings("null")
+ @SuppressWarnings({"null","java:S3011","java:S3776"}) //
Intentional brain method.
@Override
public Object extract(BeanConverter converter, Object o, String
name) {
return safe(() -> {
if (o == null)
return null;
- var f = (Field)null;
+ var f = no(Field.class);
var c = o.getClass();
var n = Character.toUpperCase(name.charAt(0)) +
name.substring(1);
var m = Arrays.stream(c.getMethods()).filter(x
-> x.getName().equals("is" + n) && x.getParameterCount() ==
0).findFirst().orElse(null);
diff --git
a/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/Stringifiers.java
b/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/Stringifiers.java
index 48fed68f33..d9d6c264ca 100644
---
a/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/Stringifiers.java
+++
b/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/Stringifiers.java
@@ -190,9 +190,7 @@ public class Stringifiers {
* @return A {@link Stringifier} for char arrays
*/
public static Stringifier<char[]> charArrayStringifier() {
- return (bc, chars) -> {
- return new String(chars);
- };
+ return (bc, chars) -> new String(chars);
}
/**
diff --git
a/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/annotations/BctConfigExtension.java
b/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/annotations/BctConfigExtension.java
index b98b4d1d5f..0b0cf2a5af 100644
---
a/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/annotations/BctConfigExtension.java
+++
b/juneau-core/juneau-bct/src/main/java/org/apache/juneau/junit/bct/annotations/BctConfigExtension.java
@@ -49,6 +49,7 @@ public class BctConfigExtension implements
BeforeEachCallback, AfterEachCallback
al.stream().map(x -> x.beanConverter()).filter(x -> neq(x,
BeanConverter.class)).findFirst().map(x -> eq(x, BasicBeanConverter.class) ?
null : x).ifPresent(x -> setConverter(x));
}
+ @SuppressWarnings("java:S3011")
private static void setConverter(Class<? extends BeanConverter> x) {
safe(()->{
var c = x.getDeclaredConstructor();
@@ -69,8 +70,8 @@ public class BctConfigExtension implements
BeforeEachCallback, AfterEachCallback
private static List<BctConfig> getAnnotations(ExtensionContext context)
{
var l = new ArrayList<BctConfig>();
- context.getTestMethod().map(x ->
x.getAnnotation(BctConfig.class)).ifPresent(x -> l.add(x));
- context.getTestClass().map(x ->
x.getAnnotation(BctConfig.class)).ifPresent(x -> l.add(x));
+ context.getTestMethod().map(x ->
x.getAnnotation(BctConfig.class)).ifPresent(l::add);
+ context.getTestClass().map(x ->
x.getAnnotation(BctConfig.class)).ifPresent(l::add);
return l;
}
}
diff --git
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/Utils.java
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/Utils.java
index 89a018c3ae..ccc26de52b 100644
---
a/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/Utils.java
+++
b/juneau-core/juneau-commons/src/main/java/org/apache/juneau/commons/utils/Utils.java
@@ -1320,8 +1320,8 @@ public class Utils {
* @param value The value being checked.
* @return <jk>true</jk> if the specified boolean is not <jk>null</jk>
and is <jk>true</jk>.
*/
- public static boolean isTrue(Boolean value) {
- return nn(value) && value;
+ public static boolean isTrue(Object value) {
+ return Boolean.TRUE.equals(value);
}
/**