Skip to content

Commit 2b80288

Browse files
committed
Merge branch 'fix/sonarqube-code-quality-improvements' into develop
2 parents 01ed659 + 31be7be commit 2b80288

File tree

72 files changed

+5332
-4594
lines changed

Some content is hidden

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

72 files changed

+5332
-4594
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
<!-- markdownlint-disable MD024 -->
22
# Corese Changelog
33

4+
## Version 4.6.3
5+
6+
### Changed
7+
8+
- Major code refactoring to improve code quality and maintainability.
9+
- Introduced custom exception hierarchy for better error handling.
10+
- Reorganized format handling classes and package structure.
11+
- Added wrapper classes to encapsulate Corese-Core functionality.
12+
- Standardized error messages and improved code documentation.
13+
14+
### Fixed
15+
16+
- Fixed inconsistent error handling across commands.
17+
- Improved test reliability and code quality.
18+
419
## Version 4.6.2 - 2025-08-01
520

621
### Changed

build.gradle.kts

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,48 @@ repositories {
6060

6161
dependencies {
6262
val coreseVersion = "4.6.4"
63-
val picocliVersion = "4.7.6"
64-
65-
implementation("fr.inria.corese:corese-core:$coreseVersion") // Core module of Corese
63+
val picocliVersion = "4.7.7"
64+
val jacksonVersion = "2.17.1" // Version compatible with WireMock 3.13.1
65+
66+
implementation("fr.inria.corese:corese-core:$coreseVersion") {
67+
// Exclude Log4j2 dependencies to avoid SLF4J multiple bindings warning
68+
// corese-core includes Log4j2, but corese-command uses Logback
69+
exclude(group = "org.apache.logging.log4j", module = "log4j-slf4j2-impl")
70+
exclude(group = "org.apache.logging.log4j", module = "log4j-core")
71+
}
6672
implementation("info.picocli:picocli:$picocliVersion") // Library for building a Command-Line Interface (CLI)
6773

68-
implementation("org.apache.commons:commons-lang3:3.17.0") // Library for utility functions (e.g., StringUtils)
74+
implementation("org.apache.commons:commons-lang3:3.19.0") // Library for utility functions (e.g., StringUtils)
6975
implementation("com.github.jsonld-java:jsonld-java:0.13.6") // Library for JSON-LD support
70-
implementation("jakarta.ws.rs:jakarta.ws.rs-api:3.0.0") // Jakarta REST API specifications
71-
implementation("jakarta.activation:jakarta.activation-api:2.1.3") // Jakarta Activation API
76+
implementation("jakarta.ws.rs:jakarta.ws.rs-api:4.0.0") // Jakarta REST API specifications
77+
implementation("jakarta.activation:jakarta.activation-api:2.2.0-M1") // Jakarta Activation API
7278
implementation("fr.com.hp.hpl.jena.rdf.arp:arp:2.2.b") // Jena implementation for RDF parsing
73-
implementation("org.slf4j:slf4j-api:2.0.16") // Simple Logging Facade for Java (SLF4J)
74-
runtimeOnly("ch.qos.logback:logback-classic:1.5.12") // Logging framework for SLF4J
79+
implementation("org.slf4j:slf4j-api:2.0.17") // Simple Logging Facade for Java (SLF4J)
80+
runtimeOnly("ch.qos.logback:logback-classic:1.5.20") // Logging framework for SLF4J
7581

76-
testImplementation("org.wiremock:wiremock:3.9.2") // HTTP server mocking for API testing
77-
testImplementation("org.junit.jupiter:junit-jupiter:5.11.3") // JUnit 5 for testing
82+
testImplementation("org.wiremock:wiremock:3.13.1") // HTTP server mocking for API testing
83+
testImplementation("org.junit.jupiter:junit-jupiter:6.0.0") // JUnit 5 for testing
84+
testImplementation("org.mockito:mockito-core:5.15.2") // Mockito for mocking in tests
85+
testImplementation("org.mockito:mockito-junit-jupiter:5.15.2") // Mockito JUnit 5 integration
7886
testRuntimeOnly("org.junit.platform:junit-platform-launcher") // JUnit Platform launcher for running tests
87+
88+
// Force Jackson version to fix compatibility issues with WireMock
89+
// WireMock 3.13.1 requires Jackson 2.17.x for the configure(DatatypeFeature, boolean) method
90+
// Without this, running tests from IDE may fail with NoSuchMethodError
91+
testImplementation("com.fasterxml.jackson.core:jackson-core:$jacksonVersion")
92+
testImplementation("com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion")
93+
testImplementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
94+
}
95+
96+
// Force Jackson version across all configurations to prevent version conflicts
97+
// This ensures that transitive dependencies from corese-core or other libraries
98+
// do not introduce older Jackson versions that are incompatible with WireMock
99+
configurations.all {
100+
resolutionStrategy {
101+
force("com.fasterxml.jackson.core:jackson-core:2.17.1")
102+
force("com.fasterxml.jackson.core:jackson-annotations:2.17.1")
103+
force("com.fasterxml.jackson.core:jackson-databind:2.17.1")
104+
}
79105
}
80106

81107
/////////////////////////

packaging/flatpak/appdata/fr.inria.corese.CoreseCommand.appdata.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,20 @@
136136
</screenshots>
137137

138138
<releases>
139+
<release version="4.6.3" date="2025-10-30">
140+
<url type="details">https://github.com/corese-stack/corese-command/releases/tag/v4.6.3</url>
141+
<description>
142+
<ul>
143+
<li>Major code refactoring for improved quality and maintainability.</li>
144+
<li>Introduced custom exception hierarchy and wrapper classes.</li>
145+
<li>Reorganized package structure and standardized error messages.</li>
146+
147+
<li xml:lang="fr">Refonte majeure du code pour améliorer la qualité et la maintenabilité.</li>
148+
<li xml:lang="fr">Introduction d'une hiérarchie d'exceptions personnalisée et de classes wrapper.</li>
149+
<li xml:lang="fr">Réorganisation de la structure des packages et standardisation des messages d'erreur.</li>
150+
</ul>
151+
</description>
152+
</release>
139153
<release version="4.6.2" date="2025-08-01">
140154
<url type="details">https://github.com/corese-stack/corese-command/releases/tag/v4.6.2</url>
141155
<description>

src/main/java/fr/inria/corese/command/App.java

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,40 @@
55
import fr.inria.corese.command.programs.Query;
66
import fr.inria.corese.command.programs.QueryEndpoint;
77
import fr.inria.corese.command.programs.Validate;
8+
import fr.inria.corese.command.utils.wrapper.CoreseVersionProvider;
9+
810
import picocli.AutoComplete.GenerateCompletion;
911
import picocli.CommandLine;
1012
import picocli.CommandLine.Command;
1113
import picocli.CommandLine.Help.Ansi.Style;
1214
import picocli.CommandLine.Help.ColorScheme;
1315

14-
@Command(name = "Corese", versionProvider = VersionProvider.class, mixinStandardHelpOptions = true, subcommands = {
15-
Convert.class, Query.class, QueryEndpoint.class, Validate.class, Canonicalize.class, GenerateCompletion.class })
16+
@Command(
17+
name = "Corese",
18+
versionProvider = CoreseVersionProvider.class,
19+
mixinStandardHelpOptions = true,
20+
subcommands = {
21+
Convert.class,
22+
Query.class,
23+
QueryEndpoint.class,
24+
Validate.class,
25+
Canonicalize.class,
26+
GenerateCompletion.class
27+
})
1628
public final class App implements Runnable {
1729

1830
public static void main(String[] args) {
1931
// Define the color scheme
20-
ColorScheme colorScheme = new ColorScheme.Builder()
21-
.commands(Style.bold) // Commands in blue
22-
.options(Style.fg_yellow) // Options in yellow
23-
.parameters(Style.fg_cyan, Style.bold) // Parameters in cyan and bold
24-
.optionParams(Style.italic, Style.fg_cyan) // Option parameters in italic
25-
.errors(Style.fg_red, Style.bold) // Errors in red and bold
26-
.stackTraces(Style.italic) // Stack traces in italic
27-
.applySystemProperties() // Apply system properties for colors
28-
.build();
32+
ColorScheme colorScheme =
33+
new ColorScheme.Builder()
34+
.commands(Style.bold) // Commands in blue
35+
.options(Style.fg_yellow) // Options in yellow
36+
.parameters(Style.fg_cyan, Style.bold) // Parameters in cyan and bold
37+
.optionParams(Style.italic, Style.fg_cyan) // Option parameters in italic
38+
.errors(Style.fg_red, Style.bold) // Errors in red and bold
39+
.stackTraces(Style.italic) // Stack traces in italic
40+
.applySystemProperties() // Apply system properties for colors
41+
.build();
2942

3043
CommandLine commandLine = new CommandLine(new App()).setColorScheme(colorScheme);
3144

@@ -39,8 +52,9 @@ public static void main(String[] args) {
3952
}
4053

4154
@Override
55+
@SuppressWarnings("java:S106") // Standard output is appropriate for CLI usage display
4256
public void run() {
4357
// Print usage
4458
CommandLine.usage(new App(), System.out);
4559
}
46-
}
60+
}

src/main/java/fr/inria/corese/command/VersionProvider.java

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package fr.inria.corese.command.exceptions;
2+
3+
/**
4+
* Exception thrown when an error occurs while loading or processing configuration.
5+
*
6+
* <p>This includes errors such as:
7+
* <ul>
8+
* <li>Configuration file not found</li>
9+
* <li>Invalid configuration format</li>
10+
* <li>Configuration parsing errors</li>
11+
* </ul>
12+
*/
13+
public class ConfigurationException extends CoreseCommandException {
14+
15+
/**
16+
* Constructs a new ConfigurationException with the specified detail message.
17+
*
18+
* @param message the detail message
19+
*/
20+
public ConfigurationException(String message) {
21+
super(message);
22+
}
23+
24+
/**
25+
* Constructs a new ConfigurationException with the specified detail message and cause.
26+
*
27+
* @param message the detail message
28+
* @param cause the cause of this exception
29+
*/
30+
public ConfigurationException(String message, Throwable cause) {
31+
super(message, cause);
32+
}
33+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package fr.inria.corese.command.exceptions;
2+
3+
/**
4+
* Base exception for all Corese Command errors.
5+
*
6+
* <p>This is an unchecked exception (extends RuntimeException) to simplify
7+
* error handling in the CLI application while still providing structured
8+
* error information.
9+
*/
10+
public class CoreseCommandException extends RuntimeException {
11+
12+
/**
13+
* Constructs a new CoreseCommandException with the specified detail message.
14+
*
15+
* @param message the detail message
16+
*/
17+
public CoreseCommandException(String message) {
18+
super(message);
19+
}
20+
21+
/**
22+
* Constructs a new CoreseCommandException with the specified detail message and cause.
23+
*
24+
* @param message the detail message
25+
* @param cause the cause of this exception
26+
*/
27+
public CoreseCommandException(String message, Throwable cause) {
28+
super(message, cause);
29+
}
30+
31+
/**
32+
* Constructs a new CoreseCommandException with the specified cause.
33+
*
34+
* @param cause the cause of this exception
35+
*/
36+
public CoreseCommandException(Throwable cause) {
37+
super(cause);
38+
}
39+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package fr.inria.corese.command.exceptions;
2+
3+
/**
4+
* Exception thrown when an HTTP error occurs while communicating with a SPARQL endpoint.
5+
*
6+
* <p>This exception includes the HTTP status code to allow for specific error handling
7+
* based on the type of HTTP error encountered.
8+
*/
9+
public class HttpClientException extends CoreseCommandException {
10+
11+
private final int statusCode;
12+
13+
/**
14+
* Constructs a new HttpClientException with the specified detail message and HTTP status code.
15+
*
16+
* @param message the detail message
17+
* @param statusCode the HTTP status code
18+
*/
19+
public HttpClientException(String message, int statusCode) {
20+
super(message);
21+
this.statusCode = statusCode;
22+
}
23+
24+
/**
25+
* Constructs a new HttpClientException with the specified detail message, HTTP status code, and cause.
26+
*
27+
* @param message the detail message
28+
* @param statusCode the HTTP status code
29+
* @param cause the cause of this exception
30+
*/
31+
public HttpClientException(String message, int statusCode, Throwable cause) {
32+
super(message, cause);
33+
this.statusCode = statusCode;
34+
}
35+
36+
/**
37+
* Returns the HTTP status code associated with this exception.
38+
*
39+
* @return the HTTP status code
40+
*/
41+
public int getStatusCode() {
42+
return statusCode;
43+
}
44+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package fr.inria.corese.command.exceptions;
2+
3+
/**
4+
* Exception thrown when an invalid input format is encountered.
5+
*
6+
* <p>This includes errors such as:
7+
* <ul>
8+
* <li>Unknown or unsupported serialization format</li>
9+
* <li>Format detection failures</li>
10+
* <li>Format mismatch with actual data</li>
11+
* </ul>
12+
*/
13+
public class InputFormatException extends CoreseCommandException {
14+
15+
/**
16+
* Constructs a new InputFormatException with the specified detail message.
17+
*
18+
* @param message the detail message
19+
*/
20+
public InputFormatException(String message) {
21+
super(message);
22+
}
23+
24+
/**
25+
* Constructs a new InputFormatException with the specified detail message and cause.
26+
*
27+
* @param message the detail message
28+
* @param cause the cause of this exception
29+
*/
30+
public InputFormatException(String message, Throwable cause) {
31+
super(message, cause);
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package fr.inria.corese.command.exceptions;
2+
3+
/**
4+
* Exception thrown when an error occurs during RDF export operations.
5+
*
6+
* <p>This includes errors such as:
7+
* <ul>
8+
* <li>File write errors</li>
9+
* <li>Unsupported export format</li>
10+
* <li>Serialization errors</li>
11+
* </ul>
12+
*/
13+
public class RdfExportException extends CoreseCommandException {
14+
15+
/**
16+
* Constructs a new RdfExportException with the specified detail message.
17+
*
18+
* @param message the detail message
19+
*/
20+
public RdfExportException(String message) {
21+
super(message);
22+
}
23+
24+
/**
25+
* Constructs a new RdfExportException with the specified detail message and cause.
26+
*
27+
* @param message the detail message
28+
* @param cause the cause of this exception
29+
*/
30+
public RdfExportException(String message, Throwable cause) {
31+
super(message, cause);
32+
}
33+
}

0 commit comments

Comments
 (0)