Skip to content

Replace deprecated SonarQube logger with SLF4J#374

Merged
vdiez merged 1 commit into
masterfrom
remediate-master-20260609-050229-8f8b101d
Jun 9, 2026
Merged

Replace deprecated SonarQube logger with SLF4J#374
vdiez merged 1 commit into
masterfrom
remediate-master-20260609-050229-8f8b101d

Conversation

@sonarqube-agent

Copy link
Copy Markdown
Contributor

This PR was automatically created by the Remediation Agent's Scheduled backlog remediation feature.

Why these issues? These issues target deprecated API usage (S1874 rule) in production source code with MINOR severity and clear, actionable fixes. The changes are focused on core plugin files and have high automation success rates, making them ideal candidates for automated remediation.

This change replaces deprecated logging API usage across three files in the Flex plugin by importing and using SLF4J Logger and LoggerFactory instead of the obsolete SonarQube logging classes. Modernizing to SLF4J ensures compatibility with current SonarQube versions and eliminates deprecation warnings.

View Project in SonarCloud


Fixed Issues

java:S1874 - Remove this use of "Logger"; it is deprecated. • MINORView issue

Location: sonar-flex-plugin/src/main/java/org/sonar/plugins/flex/FlexSquidSensor.java:65

Why is this an issue?

Code is sometimes annotated as deprecated by developers maintaining libraries or APIs to indicate that the method, class, or other programming element is no longer recommended for use. This is typically due to the introduction of a newer or more effective alternative. For example, when a better solution has been identified, or when the existing code presents potential errors or security risks.

What changed

Adds the new non-deprecated imports for org.slf4j.Logger and org.slf4j.LoggerFactory, which replace the deprecated org.sonar.api.utils.log.Logger and org.sonar.api.utils.log.Loggers classes. This is necessary to support the replacement of the deprecated logger usage on line 65.

--- a/sonar-flex-plugin/src/main/java/org/sonar/plugins/flex/FlexSquidSensor.java
+++ b/sonar-flex-plugin/src/main/java/org/sonar/plugins/flex/FlexSquidSensor.java
@@ -29,0 +30,2 @@ import java.util.stream.Collectors;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
java:S1874 - Remove this use of "Loggers"; it is deprecated. • MINORView issue

Location: sonar-flex-plugin/src/main/java/org/sonar/plugins/flex/FlexSquidSensor.java:65

Why is this an issue?

Code is sometimes annotated as deprecated by developers maintaining libraries or APIs to indicate that the method, class, or other programming element is no longer recommended for use. This is typically due to the introduction of a newer or more effective alternative. For example, when a better solution has been identified, or when the existing code presents potential errors or security risks.

What changed

Adds the new non-deprecated imports for org.slf4j.Logger and org.slf4j.LoggerFactory, which replace the deprecated org.sonar.api.utils.log.Logger and org.sonar.api.utils.log.Loggers classes. This is necessary to support the replacement of the deprecated logger usage on line 65.

--- a/sonar-flex-plugin/src/main/java/org/sonar/plugins/flex/FlexSquidSensor.java
+++ b/sonar-flex-plugin/src/main/java/org/sonar/plugins/flex/FlexSquidSensor.java
@@ -29,0 +30,2 @@ import java.util.stream.Collectors;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
java:S1874 - Remove this use of "Logger"; it is deprecated. • MINORView issue

Location: sonar-flex-plugin/src/main/java/org/sonar/plugins/flex/cobertura/CoberturaReportParser.java:45

Why is this an issue?

Code is sometimes annotated as deprecated by developers maintaining libraries or APIs to indicate that the method, class, or other programming element is no longer recommended for use. This is typically due to the introduction of a newer or more effective alternative. For example, when a better solution has been identified, or when the existing code presents potential errors or security risks.

What changed

Adds the import statements for org.slf4j.Logger and org.slf4j.LoggerFactory, which are the non-deprecated replacements for the deprecated org.sonar.api.utils.log.Logger and org.sonar.api.utils.log.Loggers. This supports the migration away from the deprecated SonarQube logging API.

--- a/sonar-flex-plugin/src/main/java/org/sonar/plugins/flex/cobertura/CoberturaReportParser.java
+++ b/sonar-flex-plugin/src/main/java/org/sonar/plugins/flex/cobertura/CoberturaReportParser.java
@@ -32,0 +33,2 @@ import org.codehaus.staxmate.in.SMInputCursor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
java:S1874 - Remove this use of "Logger"; it is deprecated. • MINORView issue

Location: sonar-flex-plugin/src/main/java/org/sonar/plugins/flex/cobertura/CoberturaSensor.java:32

Why is this an issue?

Code is sometimes annotated as deprecated by developers maintaining libraries or APIs to indicate that the method, class, or other programming element is no longer recommended for use. This is typically due to the introduction of a newer or more effective alternative. For example, when a better solution has been identified, or when the existing code presents potential errors or security risks.

What changed

Adds the new non-deprecated imports for org.slf4j.Logger and org.slf4j.LoggerFactory, which replace the deprecated org.sonar.api.utils.log.Logger and org.sonar.api.utils.log.Loggers. This hunk provides the necessary imports for the replacement logging classes used in Hunk 3.

--- a/sonar-flex-plugin/src/main/java/org/sonar/plugins/flex/cobertura/CoberturaSensor.java
+++ b/sonar-flex-plugin/src/main/java/org/sonar/plugins/flex/cobertura/CoberturaSensor.java
@@ -19,0 +20,2 @@ import java.io.File;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
java:S1874 - Remove this use of "Loggers"; it is deprecated. • MINORView issue

Location: sonar-flex-plugin/src/main/java/org/sonar/plugins/flex/cobertura/CoberturaSensor.java:32

Why is this an issue?

Code is sometimes annotated as deprecated by developers maintaining libraries or APIs to indicate that the method, class, or other programming element is no longer recommended for use. This is typically due to the introduction of a newer or more effective alternative. For example, when a better solution has been identified, or when the existing code presents potential errors or security risks.

What changed

Adds the new non-deprecated imports for org.slf4j.Logger and org.slf4j.LoggerFactory, which replace the deprecated org.sonar.api.utils.log.Logger and org.sonar.api.utils.log.Loggers. This hunk provides the necessary imports for the replacement logging classes used in Hunk 3.

--- a/sonar-flex-plugin/src/main/java/org/sonar/plugins/flex/cobertura/CoberturaSensor.java
+++ b/sonar-flex-plugin/src/main/java/org/sonar/plugins/flex/cobertura/CoberturaSensor.java
@@ -19,0 +20,2 @@ import java.io.File;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;

Have a suggestion or found an issue? Share your feedback here.


SonarQube Remediation Agent uses AI. Check for mistakes.

Fixed issues:
- AZggADINxdvKFWvLKVB_ for java:S1874 rule
- AZggADINxdvKFWvLKVCA for java:S1874 rule
- AZggADG_xdvKFWvLKVB8 for java:S1874 rule
- AZggADG_xdvKFWvLKVB9 for java:S1874 rule
- AZggADIYxdvKFWvLKVCB for java:S1874 rule

Generated by SonarQube Agent (task: 51ba4474-6aeb-4612-810b-885c2c74591b)
@sonarqube-next

sonarqube-next Bot commented Jun 9, 2026

Copy link
Copy Markdown

@vdiez vdiez merged commit 18609d8 into master Jun 9, 2026
11 checks passed
@vdiez vdiez deleted the remediate-master-20260609-050229-8f8b101d branch June 9, 2026 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants