From 7e93a031d68ebfc1fc7f0095a0253ca5edc98dc3 Mon Sep 17 00:00:00 2001
From: Pierre Smeyers <pierre.smeyers@gmail.com>
Date: Thu, 7 Jul 2022 17:49:55 +0200
Subject: [PATCH] feat: remove support of Sonar GitLab plugin (discontinued)

---
 README.md                     | 13 +------------
 kicker.json                   |  8 +-------
 templates/gitlab-ci-sonar.yml | 11 -----------
 3 files changed, 2 insertions(+), 30 deletions(-)

diff --git a/README.md b/README.md
index 8c9cc60..e673625 100644
--- a/README.md
+++ b/README.md
@@ -34,9 +34,8 @@ It is bound to the `test` stage, and uses the following variables:
 | `SONAR_BASE_ARGS`        | SonarQube [analysis arguments](https://docs.sonarqube.org/latest/analysis/analysis-parameters/) | `-Dsonar.links.homepage=${CI_PROJECT_URL} -Dsonar.links.ci=${CI_PROJECT_URL}/-/pipelines -Dsonar.links.issue=${CI_PROJECT_URL}/-/issues` |
 | :lock: `SONAR_GITLAB_TOKEN` | GitLab [access token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html) with `api` scope. When set, activates the [Sonar GitLab plugin](https://github.com/gabrie-allaigre/sonar-gitlab-plugin/#plugins-properties) integration. | _none_ |
 | `SONAR_BRANCH_ANALYSIS_DISABLED` | Set to `true` to disable automatic [Pull Request Analysis](https://docs.sonarqube.org/latest/analysis/pull-request/) and [Branch Analysis](https://docs.sonarqube.org/latest/branches/overview/)  | _none_ (enabled) |
-| `SONAR_GITLAB_ARGS`      | Extra arguments to use with [Sonar GitLab plugin](https://github.com/gabrie-allaigre/sonar-gitlab-plugin/#plugins-properties) | `-Dsonar.gitlab.url=${CI_SERVER_URL} -Dsonar.gitlab.user_token=${SONAR_GITLAB_TOKEN} -Dsonar.gitlab.project_id=${CI_PROJECT_ID} -Dsonar.gitlab.commit_sha=${CI_COMMIT_SHA} -Dsonar.gitlab.ref_name=${CI_COMMIT_REF_NAME}` |
 
-#### Automatic Branch Analysis & Pull Request Analysis
+### Automatic Branch Analysis & Merge Request Analysis
 
 By default, this template tries to auto-detect and use [Pull Request Analysis](https://docs.sonarqube.org/latest/analysis/pull-request/) or [Branch Analysis](https://docs.sonarqube.org/latest/branches/overview/) (depending on the context).
 
@@ -56,16 +55,6 @@ If you leave the feature enabled, the template will try to auto-detect whether t
    This will only be possible if you provided `SONAR_GITLAB_TOKEN`. 
    Otherwise, a simple [Branch Analysis](https://docs.sonarqube.org/latest/branches/overview/) is performed on the current branch.
 
-### About Sonar GitLab plugin
-
-The [Sonar GitLab plugin](https://github.com/gabrie-allaigre/sonar-gitlab-plugin) uses the GitLab APIs to inline comments
-into your commits directly in GitLab for each new anomaly.
-
-As explained above, this template automatically enables the Sonar GitLab plugin if `SONAR_GITLAB_TOKEN` is set.
-It will then simply append the `SONAR_GITLAB_ARGS` (overridable) to the SonarQube analysis arguments.
-
-Comments added to GitLab will appear as owned by the user associated to the GitLab [access token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html).
-
 ### Configuring SonarQube project key, project name and other parameters
 
 You shall define your SonarQube project key and project name in a `sonar-project.properties` file located at the root of your repository (as respectively `sonar.projectKey` and `sonar.projectName` entries), although they might alternately be set as `$SONAR_PROJECT_KEY` and `$SONAR_PROJECT_NAME` variables.
diff --git a/kicker.json b/kicker.json
index 94666c8..f3d1ddc 100644
--- a/kicker.json
+++ b/kicker.json
@@ -48,19 +48,13 @@
     },
     {
       "name": "SONAR_GITLAB_TOKEN",
-      "description": "GitLab API access token. When set, activates the [Sonar GitLab plugin](https://github.com/gabrie-allaigre/sonar-gitlab-plugin/#plugins-properties) integration, and enables SonarQube [Pull Request Analysis](https://docs.sonarqube.org/latest/analysis/pull-request/)",
+      "description": "GitLab API access token. When set, enables SonarQube [Pull Request Analysis](https://docs.sonarqube.org/latest/analysis/pull-request/)",
       "secret": true
     },
     {
       "name": "SONAR_BRANCH_ANALYSIS_DISABLED",
       "description": "Set to disable automatic [Pull Request Analysis](https://docs.sonarqube.org/latest/analysis/pull-request/) and [Branch Analysis](https://docs.sonarqube.org/latest/branches/overview/)",
       "type": "boolean"
-    },
-    {
-      "name": "SONAR_GITLAB_ARGS",
-      "description": "Extra arguments to use with [Sonar GitLab plugin](https://github.com/gabrie-allaigre/sonar-gitlab-plugin/#plugins-properties)",
-      "default": "-Dsonar.gitlab.url=${CI_SERVER_URL} -Dsonar.gitlab.user_token=${SONAR_GITLAB_TOKEN} -Dsonar.gitlab.project_id=${CI_PROJECT_ID} -Dsonar.gitlab.commit_sha=${CI_COMMIT_SHA} -Dsonar.gitlab.ref_name=${CI_COMMIT_REF_NAME}",
-      "advanced": true
     }
   ]
 }
diff --git a/templates/gitlab-ci-sonar.yml b/templates/gitlab-ci-sonar.yml
index 77e34da..fd5c112 100644
--- a/templates/gitlab-ci-sonar.yml
+++ b/templates/gitlab-ci-sonar.yml
@@ -55,16 +55,6 @@ variables:
     -Dsonar.links.ci=${CI_PROJECT_URL}/-/pipelines
     -Dsonar.links.issue=${CI_PROJECT_URL}/-/issues
 
-  # Sonar GitLab plugin args
-  # see: https://github.com/gabrie-allaigre/sonar-gitlab-plugin/#plugins-properties
-  # -> enabled if $SONAR_GITLAB_TOKEN is set
-  SONAR_GITLAB_ARGS: >-
-    -Dsonar.gitlab.url=${CI_SERVER_URL}
-    -Dsonar.gitlab.user_token=${SONAR_GITLAB_TOKEN}
-    -Dsonar.gitlab.project_id=${CI_PROJECT_ID}
-    -Dsonar.gitlab.commit_sha=${CI_COMMIT_SHA}
-    -Dsonar.gitlab.ref_name=${CI_COMMIT_REF_NAME}
-
   # default production ref name (pattern)
   PROD_REF: '/^(master|main)$/'
   # default integration ref name (pattern)
@@ -359,7 +349,6 @@ sonar:
       ${SONAR_PASSWORD+-Dsonar.password=$SONAR_PASSWORD} 
       ${SONAR_PROJECT_KEY+-Dsonar.projectKey=$SONAR_PROJECT_KEY} 
       ${SONAR_PROJECT_NAME+-Dsonar.projectName=$SONAR_PROJECT_NAME} 
-      ${SONAR_GITLAB_TOKEN+$SONAR_GITLAB_ARGS} 
       $SONAR_BASE_ARGS $sonar_mr_args
   rules:
     - !reference [.test-policy, rules]
-- 
GitLab