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

Azure devops refactor #391

Merged
merged 2 commits into from
Aug 11, 2021
Merged

Azure devops refactor #391

merged 2 commits into from
Aug 11, 2021

Conversation

mc1arke
Copy link
Owner

@mc1arke mc1arke commented Jul 25, 2021

This Splits the AzureDevOpsServerPullRequestDecorator into distinct decorator and client implementations to allow separation of responsibilities. As part of extracting the client logic from the decorator, the decoration flow has been simplified to improve error handling and reduce nested logic, and fields that were not used in the decorator or client, and were not required by the Azure DevOps API have been removed from the client model.

As Sonarqube now requires that the project's ALM binding has the project and repository names set, these were never being read from the scanner properties so the associated environment detection has been removed for everything other than the pull request ID.

The Azure Devops Decorator does not currently close comment threads where the issue no longer exists. As the concept of submitting comments to threads and reporting an overall pipeline status is similar between Gitlab and Azure Devops, the common co-ordination of retrieving existing threads, checking if they contain SonarQube comments, closing any outdated issues, reporting new issues, and submitting a pipeline result has been moved into a DiscussionAwarePullRequestDecorator with both the Gitlab and Azure DevOps decorator extending this base decorator and providing the implementations for the actual interactions and response handling for the relevant ALMs.

As there is no reliable way of obtaining the details of the current user details on the version of the Azure DevOps API used by the plugin, the filtering for messages posted by the SonarQube user presumes that any thread started with a message containing the View in SonarQube link is a SonarQube comment, and therefore includes that thread in any subsequent cleanup activities.

@mc1arke mc1arke force-pushed the azure-devops-refactor branch 4 times, most recently from 4291f56 to 90809e0 Compare August 11, 2021 18:23
Splits the AzureDevOpsServerPullRequestDecorator into distinct decorator and client implementations to allow separation of responsibilities. As part of extracting the client logic from the decorator, the decoration flow has been simplified to improve error handling and reduce nested logic, and fields that were not used in the decorator or client, and were not required by the Azure DevOps API have been removed from the client model.

As Sonarqube now requires that the project's ALM binding has the project and repository names set, these were never being read from the scanner properties so the associated environment detection has been removed for everything other than the pull request ID.
The Azure Devops Decorator does not currently close comment threads where the issue no longer exists. As the concept of submitting comments to threads and reporting an overall pipeline status is similar between Gitlab and Azure Devops, the common co-ordination of retrieving existing threads, checking if they contain SonarQube comments, closing any outdated issues, reporting new issues, and submitting a pipeline result has been moved into a `DiscussionAwarePullRequestDecorator` with both the Gitlab and Azure DevOps decorator extending this base decorator and providing the implementations for the actual interactions and response handling for the relevant ALMs.

As there is no reliable way of obtaining the details of the current user's login on the version of the Azure DevOps API used by the plugin, the filtering for messages posted by the SonarQube user presumes that any thread started with a message containing the `View in SonarQube` link is a SonarQube comment, and therefore includes that thread in any subsequent cleanup activities.

Due to the re-use of the code from the Gitlab decorator, the Azure DevOps decorator is now Monorepo aware, with pipeline results being submitted under individual project keys, and comment cleanup checking the project details contained in each comment.
@mc1arke mc1arke force-pushed the azure-devops-refactor branch from 90809e0 to be7951b Compare August 11, 2021 18:40
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

84.0% 84.0% Coverage
0.0% 0.0% Duplication

@mc1arke mc1arke merged commit 3271a11 into master Aug 11, 2021
@mc1arke mc1arke deleted the azure-devops-refactor branch August 11, 2021 18:48
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.

1 participant