-
Notifications
You must be signed in to change notification settings - Fork 720
SONARJAVA-5931 Upgrade S5128 to support the Jakarta package #5410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0705b0f
Add support for Jakarta annotations in S5128
aurelien-coet-sonarsource af6743b
Apply fixes suggested in the review
aurelien-coet-sonarsource 73fbbf3
Move and split the tests between Javax and Jakarta for S5128
aurelien-coet-sonarsource 5c8c737
Update the ground truth for autoscan tests after moving S5128's unit …
aurelien-coet-sonarsource 8d160d3
Use a static import for the path resolution method in tests
aurelien-coet-sonarsource fff7db2
Update rule metadata
aurelien-coet-sonarsource File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
its/autoscan/src/test/resources/autoscan/diffs/diff_S1172.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "ruleKey": "S1172", | ||
| "hasTruePositives": true, | ||
| "falseNegatives": 31, | ||
| "falseNegatives": 32, | ||
| "falsePositives": 0 | ||
| } | ||
| } |
49 changes: 49 additions & 0 deletions
49
...ks-test-sources/default/src/main/java/checks/MissingBeanValidationCheckJakartaSample.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| package checks; | ||
|
|
||
| import jakarta.validation.Constraint; | ||
| import jakarta.validation.ConstraintValidator; | ||
| import jakarta.validation.ConstraintValidatorContext; | ||
| import jakarta.validation.Valid; | ||
| import java.util.List; | ||
|
|
||
| @Constraint(validatedBy = ConstraintChecker.class) | ||
| @interface WellNamed { | ||
| } | ||
|
|
||
| class ConstraintChecker implements ConstraintValidator<WellNamed, Occupant> { | ||
| @Override | ||
| public boolean isValid(Occupant occupant, ConstraintValidatorContext constraintValidatorContext) { | ||
| return occupant.name != null; | ||
| } | ||
| } | ||
|
|
||
| @WellNamed | ||
| class Occupant { | ||
| public String name; | ||
| } | ||
|
|
||
| class Floor { | ||
| private Id id; // Noncompliant {{Add missing "@Valid" on "id" to validate it with "Bean Validation".}} | ||
| // ^^ | ||
|
|
||
| private List<Occupant> occupants; // Noncompliant {{Add missing "@Valid" on "occupants" to validate it with "Bean Validation".}} | ||
| // ^^^^^^^^^^^^^^ | ||
|
|
||
| @Valid | ||
| private List<Occupant> validatedOccupants; // Compliant | ||
|
|
||
| // Preferred style as of Bean Validation 2.0 | ||
| private List<@Valid Occupant> validatedOccupants2; // Compliant | ||
|
|
||
| public void ignore(Occupant occupant) { // Noncompliant {{Add missing "@Valid" on "occupant" to validate it with "Bean Validation".}} | ||
| // ^^^^^^^^ | ||
| } | ||
|
|
||
| public void validate(@Valid Occupant occupant) { // Compliant | ||
| } | ||
| } | ||
|
|
||
| class Id { | ||
| @jakarta.validation.constraints.NotNull | ||
| private String name; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
sonar-java-plugin/src/main/resources/org/sonar/l10n/java/rules/java/S5128.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.