You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-commits@db.apache.org by mb...@apache.org on 2026/04/04 14:43:18 UTC
(db-jdo) 01/02: JDO-823: use @SuppressWarnings to diable sonar rules
This is an automated email from the ASF dual-hosted git repository.
mbo pushed a commit to branch JDO-823-3
in repository https://gitbox.apache.org/repos/asf/db-jdo.git
commit c4527d8db4b4fd6190541093baebe60e1d1f565c
Author: Michael Bouschen <Mi...@spree.de>
AuthorDate: Sat Apr 4 16:41:39 2026 +0200
JDO-823: use @SuppressWarnings to diable sonar rules
---
api/src/main/java/javax/jdo/Enhancer.java | 6 ++-
.../java/org/apache/jdo/exectck/PropertyUtils.java | 3 +-
.../main/java/org/apache/jdo/exectck/RunTCK.java | 44 +++++++++++-----------
.../java/org/apache/jdo/exectck/SQLFileLoader.java | 3 +-
4 files changed, 31 insertions(+), 25 deletions(-)
diff --git a/api/src/main/java/javax/jdo/Enhancer.java b/api/src/main/java/javax/jdo/Enhancer.java
index 0805e987..cc92466c 100644
--- a/api/src/main/java/javax/jdo/Enhancer.java
+++ b/api/src/main/java/javax/jdo/Enhancer.java
@@ -269,7 +269,8 @@ public class Enhancer {
*
* @param args the command line arguments
*/
- private void parseArgs(String[] args) { // NOSONAR Cognitive Complexity
+ @SuppressWarnings("java:S3776") // Cognitive Complexity of methods should not be too high
+ private void parseArgs(String[] args) {
boolean doneWithOptions = false;
fileNames = new ArrayList<>();
for (int i = 0; i < args.length; ++i) {
@@ -368,7 +369,8 @@ public class Enhancer {
*
* If the recursion flag is set, directories contained in directories are examined, recursively.
*/
- private void parseFiles( // NOSONAR Cognitive Complexity
+ @SuppressWarnings("java:S3776") // Cognitive Complexity of methods should not be too high
+ private void parseFiles(
String[] fileNames, boolean search, boolean recurse) {
for (String fileName : fileNames) {
if (fileName.endsWith(JAR_FILE_SUFFIX)) {
diff --git a/exectck/src/main/java/org/apache/jdo/exectck/PropertyUtils.java b/exectck/src/main/java/org/apache/jdo/exectck/PropertyUtils.java
index 78d0e104..3aab3c09 100644
--- a/exectck/src/main/java/org/apache/jdo/exectck/PropertyUtils.java
+++ b/exectck/src/main/java/org/apache/jdo/exectck/PropertyUtils.java
@@ -48,6 +48,7 @@ public class PropertyUtils {
* @param confDir directory where config files are found
* @param mappings object to containg mapping values
*/
+ @SuppressWarnings("java:S106") // Standard outputs should not be used directly to log anything
public static void mappingsSet(
Collection<String> cfglist, String confDir, Collection<String> mappings) {
@@ -56,7 +57,7 @@ public class PropertyUtils {
String confName = confDir + File.separator + cfg;
if (!new File(confName).exists()) {
// Conf file nor found => continue
- System.out.println( // NOSONAR System.out
+ System.out.println(
"ERROR: Configuration file " + confName + " not found.");
continue;
}
diff --git a/exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java b/exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java
index 09aabdf5..40318333 100644
--- a/exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java
+++ b/exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java
@@ -40,6 +40,7 @@ import org.apache.maven.plugins.annotations.Parameter;
* test (IUT).
*/
@Mojo(name = "runtck")
+@SuppressWarnings("java:S106") // Standard outputs should not be used directly to log anything
public class RunTCK extends AbstractTCKMojo {
private static final String TCK_PARAM_ON_FAILURE_FAIL_FAST = "failFast"; // NOI18N
@@ -187,7 +188,7 @@ public class RunTCK extends AbstractTCKMojo {
@Override
public void execute() throws MojoExecutionException {
if (!doRunTCK) {
- System.out.println("Skipping RunTCK goal!"); // NOSONAR System.out
+ System.out.println("Skipping RunTCK goal!");
return;
}
@@ -257,7 +258,7 @@ public class RunTCK extends AbstractTCKMojo {
String confFileName = confDirectory + FS + cfg;
if (!new File(confFileName).exists()) {
// Conf file nor found => continue
- System.out.println( // NOSONAR System.out
+ System.out.println(
"ERROR: Configuration file " + confFileName + " not found.");
continue;
}
@@ -268,7 +269,7 @@ public class RunTCK extends AbstractTCKMojo {
}
List<String> classesList = getTestClasses(props, cfg, excludeFile);
if (classesList.isEmpty()) {
- System.out.println( // NOSONAR System.out
+ System.out.println(
"Skipping configuration " + cfg + ": classes excluded");
continue;
}
@@ -345,7 +346,7 @@ public class RunTCK extends AbstractTCKMojo {
PropertyUtils.string2Collection(dblist, dbs);
PropertyUtils.string2Collection(identitytypes, idtypes);
- System.out.println( // NOSONAR System.out
+ System.out.println(
"*>TCK to be run for implementation '"
+ impl
+ "' on \n"
@@ -359,7 +360,7 @@ public class RunTCK extends AbstractTCKMojo {
+ identitytypes);
// Properties required for test execution
- System.out.println("cleanupaftertest is " + cleanupaftertest); // NOSONAR System.out
+ System.out.println("cleanupaftertest is " + cleanupaftertest);
List<String> propsString = new ArrayList<>();
propsString.add("-Dverbose=" + verbose);
@@ -410,7 +411,7 @@ public class RunTCK extends AbstractTCKMojo {
URL url1 = enhancedDir.toURI().toURL();
URL url2 = new File(buildDirectory + FS + CLASSES_DIR_NAME + FS).toURI().toURL();
if (runtckVerbose) {
- System.out.println("url2 is " + url2.toString()); // NOSONAR System.out
+ System.out.println("url2 is " + url2.toString());
}
cpList.add(url1);
cpList.add(url2);
@@ -428,7 +429,7 @@ public class RunTCK extends AbstractTCKMojo {
}
cpString = Utilities.urls2ClasspathString(cpList);
if (runtckVerbose) {
- System.out.println("\nClasspath is " + cpString); // NOSONAR System.out
+ System.out.println("\nClasspath is " + cpString);
}
return cpString;
}
@@ -534,7 +535,8 @@ public class RunTCK extends AbstractTCKMojo {
* @param logFilePrefix
* @return
*/
- private int executeTestClass( // NOSONAR Methods should not have too many parameters
+ @SuppressWarnings("java:S00107") // Methods should not have too many parameters
+ private int executeTestClass(
String cpString,
List<String> cfgPropsString,
List<String> classesList,
@@ -579,11 +581,11 @@ public class RunTCK extends AbstractTCKMojo {
}
if (debugTCK) {
- System.out.println("Using debug arguments: \n" + debugDirectives); // NOSONAR System.out
+ System.out.println("Using debug arguments: \n" + debugDirectives);
}
// invoke class runner
- System.out.print( // NOSONAR System.out
+ System.out.print(
"*> Running tests for "
+ cfg
+ " with "
@@ -600,18 +602,18 @@ public class RunTCK extends AbstractTCKMojo {
try {
resultValue = Utilities.invokeCommand(command, new File(buildDirectory), junitLogFilename);
if (resultValue == 0) {
- System.out.println("success"); // NOSONAR System.out
+ System.out.println("success");
} else {
- System.out.println("FAIL"); // NOSONAR System.out
+ System.out.println("FAIL");
}
if (runtckVerbose) {
- System.out.println("\nCommand line is: \n" + command.toString()); // NOSONAR System.out
- System.out.println("Test exit value is " + resultValue); // NOSONAR System.out
- System.out.println( // NOSONAR System.out
+ System.out.println("\nCommand line is: \n" + command.toString());
+ System.out.println("Test exit value is " + resultValue);
+ System.out.println(
"Test result output:\n" + fileToString(junitLogFilename));
}
} catch (java.lang.RuntimeException re) {
- System.out.println("Exception on command " + command); // NOSONAR System.out
+ System.out.println("Exception on command " + command);
}
return resultValue;
}
@@ -628,7 +630,7 @@ public class RunTCK extends AbstractTCKMojo {
File logFile = new File(implLogFile);
FileUtils.moveFile(logFile, new File(testLogFilename));
} catch (Exception e) {
- System.out.println( // NOSONAR System.out
+ System.out.println(
">> Error moving implementation log file: " + e.getMessage());
}
String tckLogFilename = logFilePrefix + TCK_LOG_FILE;
@@ -636,7 +638,7 @@ public class RunTCK extends AbstractTCKMojo {
File logFile = new File(tckLogFile);
FileUtils.moveFile(logFile, new File(tckLogFilename));
} catch (Exception e) {
- System.out.println(">> Error moving tck log file: " + e.getMessage()); // NOSONAR System.out
+ System.out.println(">> Error moving tck log file: " + e.getMessage());
}
}
@@ -657,12 +659,12 @@ public class RunTCK extends AbstractTCKMojo {
try {
FileUtils.forceDeleteOnExit(new File(implLogFile));
} catch (Exception e) {
- System.out.println(">> Error deleting log file: " + e.getMessage()); // NOSONAR System.out
+ System.out.println(">> Error deleting log file: " + e.getMessage());
}
try {
FileUtils.forceDeleteOnExit(new File(TCK_LOG_FILE));
} catch (Exception e) {
- System.out.println(">> Error deleting log file: " + e.getMessage()); // NOSONAR System.out
+ System.out.println(">> Error deleting log file: " + e.getMessage());
}
// Output results
@@ -674,7 +676,7 @@ public class RunTCK extends AbstractTCKMojo {
command.add("org.apache.jdo.tck.util.ResultSummary");
command.add(logDir);
Utilities.invokeCommand(command, new File(buildDirectory), resultSummaryLogFile);
- System.out.println(fileToString(resultSummaryLogFile)); // NOSONAR System.out
+ System.out.println(fileToString(resultSummaryLogFile));
// Create system configuration description file
command.set(3, "org.apache.jdo.tck.util.SystemCfgSummary");
diff --git a/exectck/src/main/java/org/apache/jdo/exectck/SQLFileLoader.java b/exectck/src/main/java/org/apache/jdo/exectck/SQLFileLoader.java
index ddee82ee..bad13349 100644
--- a/exectck/src/main/java/org/apache/jdo/exectck/SQLFileLoader.java
+++ b/exectck/src/main/java/org/apache/jdo/exectck/SQLFileLoader.java
@@ -132,7 +132,8 @@ public class SQLFileLoader {
* @return the next non comment character
* @throws IOException If an I/O error occurs
*/
- private int next() throws IOException { // NOSONAR Cognitive Complexity
+ @SuppressWarnings("java:S3776") // Cognitive Complexity of methods should not be too high
+ private int next() throws IOException {
int result = this.nextChar;
switch (this.nextChar) {
case '\'':