Skip to content
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

SONARJAVA-5328 S7190 Before and After transaction methods should respect the contract #5018

Merged
merged 6 commits into from
Feb 11, 2025

Conversation

leonardo-pilastri-sonarsource
Copy link
Contributor

@leonardo-pilastri-sonarsource leonardo-pilastri-sonarsource commented Feb 10, 2025

@org.springframework.beans.factory.annotation.Autowired
Object o;

@Autowired
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@Autowired
@Annotation

Let's be a bit clearer on the intention

}

@Test
void testNoSemantics() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void testNoSemantics() {
void test_no_semantics() {

Let's stay consistent (I think it is the preferred way).


private void checkReturnType(MethodTreeImpl methodTree, String annotationName) {
if (!methodTree.returnType().symbolType().isVoid()) {
reportReturnType(methodTree, String.format(RETURN_VOID_MESSAGE, annotationName));
Copy link
Contributor

@erwan-serandour erwan-serandour Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's inline reportReturnType, it used only here better to give more context when reading the code

private void checkParameters(MethodTreeImpl methodTree, String annotationName) {
List<VariableTree> parameters = methodTree.parameters();
if (!parameters.isEmpty() && parameters.stream().anyMatch(parameter -> !isParameterAllowed(parameter))) {
reportParameters(methodTree, String.format(NO_PARAMETERS_MESSAGE, annotationName));
Copy link
Contributor

@erwan-serandour erwan-serandour Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's inline reportParameters, it used only here better to give more context when reading the code

@erwan-serandour erwan-serandour merged commit 9448587 into master Feb 11, 2025
17 checks passed
@erwan-serandour erwan-serandour deleted the lp/S7190 branch February 11, 2025 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants