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

Fix problem with unprocessed Pull Requests in SonarQube #796

Closed
wants to merge 3 commits into from
Closed

Fix problem with unprocessed Pull Requests in SonarQube #796

wants to merge 3 commits into from

Conversation

jero-dev
Copy link

@jero-dev jero-dev commented Aug 28, 2023

Related to the issue #738, it's true that any type of project should not be created with a Pull Request that their target branch is not scanned yet.

But the problem comes when the Pull Request, which its target branch is scanned, is waiting for being processed when there's a heavy project in progress status in the Background tasks section. Because SonarQube didn't add the proper Pull Request data to the project until is processed, we have the same problem as was described in the issue mentioned before, even when we have the target branch scan.

So the changes that are added in this Pull Request are simple:

  • We ignore these unprocessed Pull Requests in the listing branches action.
  • Add a test that covers this use case.

If there's any doubt, please, use this Pull Request for the discussion.

- Avoid unprocessed new Pull Requests for listing in projects
- Add test for that use case
@mpet
Copy link

mpet commented Oct 2, 2023

@mc1arke will this be in release 1.15.0?

@@ -177,6 +177,92 @@ void shouldExecuteRequestWithValidParameter() {
assertThat(messageArgumentCaptor.getValue()).usingRecursiveComparison().isEqualTo(expected);
}

@Test
void shouldExExcludePullRequestsWithoutData() {
Copy link
Owner

Choose a reason for hiding this comment

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

Typo? ExEc

Copy link
Author

Choose a reason for hiding this comment

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

Right. I will refactor it.

@@ -115,12 +115,15 @@ private static void checkPermission(ProjectDto project, UserSession userSession)

private static void addPullRequest(ProjectPullRequests.ListWsResponse.Builder response, BranchDto branch, Map<String, BranchDto> mergeBranchesByUuid,
@Nullable LiveMeasureDto qualityGateMeasure, @Nullable String analysisDate) {
DbProjectBranches.PullRequestData pullRequestData = branch.getPullRequestData();

if (pullRequestData == null) return;
Copy link
Owner

Choose a reason for hiding this comment

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

Please use curly braces on all if statements

Copy link
Author

Choose a reason for hiding this comment

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

Sure. I will add them in the new changes.

@jero-dev jero-dev requested a review from mc1arke December 29, 2023 20:04
@mc1arke
Copy link
Owner

mc1arke commented Jan 1, 2024

I'm superceding this with #847 since the Pull Request data fields are not mandatory and I'd rather we didn't end up with data in the database that wasn't visible in the API, as users then don't know if they've got potentially broken data needing cleaned-up. I've also put in a fix for the root cause of the problem reported in the original issue which should mean the data is less likely to get corrupt. Thanks for the contribution though!

@mc1arke mc1arke closed this Jan 1, 2024
@jero-dev
Copy link
Author

jero-dev commented Jan 3, 2024

Awesome! Thank you so much and keep the good work! 😄

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.

3 participants