Skip to content

Conversation

@NathTouboul
Copy link

No description provided.

@github-actions
Copy link

This PR has been automatically marked as stale because it has no activity for 30 days.
Please add a comment if you want to keep the issue open. Thank you for your contributions!

@github-actions github-actions bot added the stale label Jun 21, 2025
@dedece35 dedece35 requested a review from Copilot July 4, 2025 14:42
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new Sonar check to enforce optimized Spring @Retryable parameters and adds tests to verify compliant and noncompliant usages.

  • Implement SpringMaxRetryableCheck to flag excessive maxAttempts or total backoff timeout
  • Add test input file with compliant/noncompliant examples for @Retryable
  • Add SpringMaxRetryableTest JUnit class to verify the new rule

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/main/java/org/greencodeinitiative/creedengo/java/checks/SpringMaxRetryableCheck.java New rule implementation enforcing maxAttempts ≤ 3 and total timeout ≤ 5000ms
src/test/files/SpringMaxRetryableCheck.java Test file with examples of compliant and noncompliant @Retryable
src/test/java/org/greencodeinitiative/creedengo/java/checks/SpringMaxRetryableTest.java JUnit verifier for the new rule
Comments suppressed due to low confidence (1)

src/test/java/org/greencodeinitiative/creedengo/java/checks/SpringMaxRetryableTest.java:29

  • [nitpick] The test method name test is too generic. Rename it to something more descriptive, e.g., verifyRetryableParametersOptimization.
    void test() {

Comment on lines +141 to +147
if (isGreaterThanMax(maxAttempts, delay, multiplier)) {
reportIssue(params.get(0).getArgument(), MESSAGE_RULE);
}
}

public boolean isGreaterThanMax(Integer maxAttempts, Long delay, Double multiplier) {
return (calculateRetryTimeout(maxAttempts, delay, multiplier) > MAX_TIMEOUT) || maxAttempts > MAX_RETRY;
Copy link

Copilot AI Jul 4, 2025

Choose a reason for hiding this comment

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

Reporting always uses the first parameter, which may not be the one exceeding the limit. Consider tracking which argument caused isGreaterThanMax and report the issue on that specific ExpressionTree.

Suggested change
if (isGreaterThanMax(maxAttempts, delay, multiplier)) {
reportIssue(params.get(0).getArgument(), MESSAGE_RULE);
}
}
public boolean isGreaterThanMax(Integer maxAttempts, Long delay, Double multiplier) {
return (calculateRetryTimeout(maxAttempts, delay, multiplier) > MAX_TIMEOUT) || maxAttempts > MAX_RETRY;
List<String> violatingParams = isGreaterThanMax(maxAttempts, delay, multiplier);
if (!violatingParams.isEmpty()) {
for (String paramName : violatingParams) {
params.stream()
.filter(argumentDetails -> argumentDetails.paramName.equals(paramName))
.findFirst()
.ifPresent(argumentDetails -> reportIssue(argumentDetails.getArgument(), MESSAGE_RULE));
}
}
}
public List<String> isGreaterThanMax(Integer maxAttempts, Long delay, Double multiplier) {
List<String> violatingParams = new ArrayList<>();
if (calculateRetryTimeout(maxAttempts, delay, multiplier) > MAX_TIMEOUT) {
violatingParams.add("backoff.delay or backoff.multiplier");
}
if (maxAttempts > MAX_RETRY) {
violatingParams.add("maxAttempts");
}
return violatingParams;

Copilot uses AI. Check for mistakes.
Comment on lines +18 to +21
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;

Copy link

Copilot AI Jul 4, 2025

Choose a reason for hiding this comment

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

These imports (Arrays, Collection, Collections) are not used in the test file and can be removed to clean up unused dependencies.

Suggested change
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;

Copilot uses AI. Check for mistakes.
@dedece35
Copy link
Member

dedece35 commented Jul 4, 2025

implementation for issue : green-code-initiative/creedengo-rules-specifications#397

@dedece35 dedece35 self-requested a review July 4, 2025 15:08
Copy link
Member

@dedece35 dedece35 left a comment

Choose a reason for hiding this comment

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

waiting for taking into account the review feedbacks of green-code-initiative/creedengo-rules-specifications#397

@github-actions
Copy link

github-actions bot commented Aug 5, 2025

This PR has been automatically marked as stale because it has no activity for 30 days.
Please add a comment if you want to keep the issue open. Thank you for your contributions!

@github-actions github-actions bot added the stale label Aug 5, 2025
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