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

Hide outdated summary comments on GitHub #323

Closed
wants to merge 2 commits into from

Conversation

VanRoy
Copy link
Contributor

@VanRoy VanRoy commented Apr 3, 2021

This pull request enhance the support of the summary comment for GitHub by minimizing previous ( outdated ) comments on Pull Request when new commit is pushed on same branch and the analysis is changed.

Screenshot of comment minimized after re-analysis done by SonarQube :

sonar_github_outdated

@VanRoy
Copy link
Contributor Author

VanRoy commented Jul 9, 2021

Hi @mc1arke , do you think that this enhancement is useful for the project ?
We use it day to day on and it works well for us.

Do not hesitate to tell me if you think it require some changes , more tests or something else.

Thanks a lot.

Copy link
Owner

@mc1arke mc1arke left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution. A few small comments, but I'm happy with the concept of the proposal!

@@ -49,13 +51,81 @@ public PullRequest getPullRequest() {

private final String id;

@GraphQLProperty(name = "comments", arguments = {@GraphQLArgument(name = "last", value = "100", type = "Integer")})
Copy link
Owner

Choose a reason for hiding this comment

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

The default of 100 could cause problems, as an MR with a large number of comments would only have the last 100 checked. This should really be controlled from the calling code, with an additional field of totalCount on the response so we can iterate from start: 100 to start: totalCount in batches of 100 and ensure we've covered all messages

@@ -222,6 +231,42 @@ private void postSummaryComment(String apiUrl, Map<String, String> headers, Stri

}

private void minimizeComment(String graphqlUrl, Map<String, String> headers, String commentId) {

try {
Copy link
Owner

Choose a reason for hiding this comment

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

Nitpick: the IOException can only happen on the executeRequest as far as I can tell, so keep the try block constrained to that line rather than covering the whole method.

@@ -178,29 +180,36 @@ public DecorationResult createCheckRun(AnalysisDetails analysisDetails, AlmSetti

}

private void postSummaryComment(String apiUrl, Map<String, String> headers, String projectPath, String pullRequestKey, String summary) throws IOException {
void postSummaryComment(String graphqlUrl, Map<String, String> headers, String projectPath, String pullRequestKey, String summary) throws IOException {
Copy link
Owner

Choose a reason for hiding this comment

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

If this has been made visible purely for testing, then it indicate this class has potentially got too complex. Is it worth moving this into a SummaryCommentHandler class?

}
}

public static class Comments {
Copy link
Owner

Choose a reason for hiding this comment

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

Nitpick: I'm not sure these classes need to be static nested classes of GetPullRequest. They are part of the response from GetPullRequest, but would also be valid for anything else that uses Comment nodes

@antiqe
Copy link

antiqe commented Aug 3, 2021

Hi @VanRoy, really nice enhancement 👍, thanks for that. I think it's something that really missing right now.

@mc1arke
Copy link
Owner

mc1arke commented Sep 3, 2021

Merged under #435 with a few minor changes. Thanks for the contribution!

@mc1arke mc1arke closed this Sep 3, 2021
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.

None yet

3 participants