Skip to content

Commit 8f75a95

Browse files
Add Jakarta's @Inject annotation to the exceptions for S1258
1 parent 60b0be9 commit 8f75a95

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

java-checks-test-sources/default/src/main/java/checks/AtLeastOneConstructorCheckSample.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ class Inject2 { // Noncompliant
7878
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^<
7979
}
8080

81+
class JakartaInject {
82+
@jakarta.inject.Inject
83+
private MyService myService; // Compliant, fields annotated with Jakarta's @Inject should be ignored.
84+
}
85+
8186
class ABuilder { // Compliant, Builder pattern are excluded
8287
private int field;
8388

java-checks/src/main/java/org/sonar/java/checks/AtLeastOneConstructorCheck.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,13 @@ public class AtLeastOneConstructorCheck extends IssuableSubscriptionVisitor {
5454
"javax.annotation.Resource",
5555
"javax.ejb.EJB",
5656
"javax.inject.Inject",
57+
"jakarta.inject.Inject",
5758
"org.apache.maven.plugins.annotations.Component",
5859
"org.apache.maven.plugins.annotations.Parameter",
5960
"org.codehaus.plexus.component.annotations.Requirement",
6061
"org.codehaus.plexus.component.annotations.Configuration",
6162
"org.springframework.beans.factory.annotation.Value"
62-
);
63+
);
6364

6465
@Override
6566
public List<Kind> nodesToVisit() {

0 commit comments

Comments
 (0)